diff --git a/src/Infrastructure/Pdf/TermsVersionSignaturePdfSnappyGenerator.php b/src/Infrastructure/Pdf/TermsVersionSignaturePdfSnappyGenerator.php
index a1e900b..440cfd6 100644
--- a/src/Infrastructure/Pdf/TermsVersionSignaturePdfSnappyGenerator.php
+++ b/src/Infrastructure/Pdf/TermsVersionSignaturePdfSnappyGenerator.php
@@ -40,7 +40,7 @@ public function __invoke(TermsVersionSignature $termsVersionSignature, ?TermsUse
]
);
- if ($pdf === null) {
+ if (!\is_string($pdf)) {
throw new \Exception('An error occured on pdf generation.');
}
diff --git a/src/Infrastructure/Resources/config/services.xml b/src/Infrastructure/Resources/config/services.xml
index 8283d1f..d0d568b 100644
--- a/src/Infrastructure/Resources/config/services.xml
+++ b/src/Infrastructure/Resources/config/services.xml
@@ -7,6 +7,6 @@
-
+
diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php
new file mode 100644
index 0000000..ad731a2
--- /dev/null
+++ b/tests/GeneratorTest.php
@@ -0,0 +1,39 @@
+getReference(TermsVersionSignature::class, 'u42-signature-v1-terms-1');
+
+ $output = ($this->generator)($signature);
+
+ self::assertNotEmpty($output);
+ }
+
+ public function testGeneratorWithEditor(): void
+ {
+ $signature = $this->getReference(TermsVersionSignature::class, 'u42-signature-v1-terms-1');
+
+ $output = ($this->generator)($signature, $this->getReference(DummyUser::class, '1'));
+
+ self::assertNotEmpty($output);
+ }
+}
diff --git a/tests/Resources/Entity/DummyUser.php b/tests/Resources/Entity/DummyUser.php
new file mode 100644
index 0000000..38e07da
--- /dev/null
+++ b/tests/Resources/Entity/DummyUser.php
@@ -0,0 +1,84 @@
+
+ *
+ * @ORM\Column(type="array", nullable=false, name="roles")
+ */
+ private $roles = [];
+
+ public function getId(): ?int
+ {
+ return $this->id;
+ }
+
+ public function getUsername(): string
+ {
+ return $this->username;
+ }
+
+ /** @return array */
+ public function getRoles(): array
+ {
+ return $this->roles;
+ }
+
+ public function getPassword(): string
+ {
+ return '';
+ }
+
+ public function getSalt(): ?string
+ {
+ return null;
+ }
+
+ public function eraseCredentials(): void
+ {
+ }
+
+ public function getUserIdentifier(): string
+ {
+ return $this->getUsername();
+ }
+
+ public function getTermsDisplayName(): ?string
+ {
+ return $this->getUsername();
+ }
+
+ public function getTermsDisplayNameForSort(): ?string
+ {
+ return $this->getUsername();
+ }
+}
diff --git a/tests/Resources/Fixtures/DummyUserFixtures.php b/tests/Resources/Fixtures/DummyUserFixtures.php
new file mode 100644
index 0000000..aadbd39
--- /dev/null
+++ b/tests/Resources/Fixtures/DummyUserFixtures.php
@@ -0,0 +1,25 @@
+createObject(
+ DummyUser::class,
+ self::USER,
+ [
+ 'username' => 'my_user_1',
+ 'roles' => ['ROLE_USER'],
+ ]
+ );
+ }
+}
diff --git a/tests/Resources/Fixtures/TermsFixtures.php b/tests/Resources/Fixtures/TermsFixtures.php
new file mode 100644
index 0000000..040e90a
--- /dev/null
+++ b/tests/Resources/Fixtures/TermsFixtures.php
@@ -0,0 +1,25 @@
+createObject(
+ Terms::class,
+ '1',
+ [
+ 'slug' => 'terms-1',
+ 'name' => 'Terms 1',
+ 'isPublished' => true,
+ 'isDepublicationLocked' => true,
+ ]
+ );
+ }
+}
diff --git a/tests/Resources/Fixtures/TermsVersionFixtures.php b/tests/Resources/Fixtures/TermsVersionFixtures.php
new file mode 100644
index 0000000..14e53b0
--- /dev/null
+++ b/tests/Resources/Fixtures/TermsVersionFixtures.php
@@ -0,0 +1,37 @@
+getReference(Terms::class, '1');
+
+ $this->createObject(
+ TermsVersion::class,
+ 'v1-terms-1',
+ [
+ 'version' => 1,
+ 'isEnabled' => true,
+ 'title' => 'Title Version 1',
+ 'content' => 'Content Version 1',
+ 'terms' => $terms1,
+ ]
+ );
+ }
+
+ public function getDependencies(): array
+ {
+ return [
+ TermsFixtures::class,
+ ];
+ }
+}
diff --git a/tests/Resources/Fixtures/TermsVersionSignatureFixtures.php b/tests/Resources/Fixtures/TermsVersionSignatureFixtures.php
new file mode 100644
index 0000000..2b78d70
--- /dev/null
+++ b/tests/Resources/Fixtures/TermsVersionSignatureFixtures.php
@@ -0,0 +1,37 @@
+getReference(TermsVersion::class, 'v1-terms-1');
+
+ $this->createObject(
+ TermsVersionSignature::class,
+ 'u42-signature-v1-terms-1',
+ [
+ 'date' => new \DateTime(),
+ 'subjectType' => 'user',
+ 'subjectIdentifier' => '42',
+ 'subjectName' => 'Mr John SMITH',
+ 'version' => $termsVersion1,
+ ]
+ );
+ }
+
+ public function getDependencies(): array
+ {
+ return [
+ TermsVersionFixtures::class,
+ ];
+ }
+}
diff --git a/tests/Resources/Kernel/TestKernel.php b/tests/Resources/Kernel/TestKernel.php
new file mode 100755
index 0000000..bfba520
--- /dev/null
+++ b/tests/Resources/Kernel/TestKernel.php
@@ -0,0 +1,20 @@
+run($input);
diff --git a/tests/Resources/Kernel/config/bundles.php b/tests/Resources/Kernel/config/bundles.php
new file mode 100644
index 0000000..e4a2ef6
--- /dev/null
+++ b/tests/Resources/Kernel/config/bundles.php
@@ -0,0 +1,16 @@
+ ['all' => true],
+ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
+ Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
+ Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
+ RichCongress\RecurrentFixturesTestBundle\RichCongressRecurrentFixturesTestBundle::class => ['all' => true],
+ RichId\TermsModuleBundle\Infrastructure\RichIdTermsModuleBundle::class => ['all' => true],
+ RichId\TermsModuleSnappyBundle\Infrastructure\RichIdTermsModuleSnappyBundle::class => ['all' => true],
+ FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
+ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
+ Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true],
+];
diff --git a/tests/Resources/Kernel/config/packages/doctrine.yaml b/tests/Resources/Kernel/config/packages/doctrine.yaml
new file mode 100644
index 0000000..860ef27
--- /dev/null
+++ b/tests/Resources/Kernel/config/packages/doctrine.yaml
@@ -0,0 +1,54 @@
+doctrine:
+ dbal:
+ default_connection: default
+ connections:
+ default:
+ driver: pdo_sqlite
+ user: test
+ path: '%kernel.cache_dir%/__DBNAME__.db'
+ url: null
+ memory: true
+ empty_database:
+ driver: pdo_sqlite
+ user: test
+ path: '%kernel.cache_dir%/__DBNAME___empty.db'
+ url: null
+ memory: true
+ orm:
+ auto_generate_proxy_classes: '%kernel.debug%'
+ default_entity_manager: default
+ entity_managers:
+ default:
+ naming_strategy: doctrine.orm.naming_strategy.underscore
+ auto_mapping: true
+ connection: default
+ mappings:
+ App:
+ is_bundle: false
+ type: annotation
+ dir: '%kernel.project_dir%/vendor/rich-id/terms-module-bundle/src/Domain/Entity'
+ prefix: 'RichId\TermsModuleBundle\Domain\Entity'
+ alias: App
+ Test:
+ is_bundle: false
+ type: annotation
+ dir: '%kernel.project_dir%/tests/Resources/Entity'
+ prefix: 'RichId\TermsModuleSnappyBundle\Tests\Resources\Entity'
+ alias: Test
+ empty_database:
+ connection: empty_database
+ naming_strategy: doctrine.orm.naming_strategy.underscore
+ auto_mapping: false
+ mappings:
+ App:
+ is_bundle: false
+ type: annotation
+ dir: '%kernel.project_dir%/vendor/rich-id/terms-module-bundle/src/Domain/Entity'
+ prefix: 'RichId\TermsModuleBundle\Domain\Entity'
+ alias: App
+ Test:
+ is_bundle: false
+ type: annotation
+ dir: '%kernel.project_dir%/tests/Resources/Entity'
+ prefix: 'RichId\TermsModuleSnappyBundle\Tests\Resources\Entity'
+ alias: Test
diff --git a/tests/Resources/Kernel/config/packages/framework.yaml b/tests/Resources/Kernel/config/packages/framework.yaml
new file mode 100644
index 0000000..ab281b2
--- /dev/null
+++ b/tests/Resources/Kernel/config/packages/framework.yaml
@@ -0,0 +1,7 @@
+framework:
+ test: true
+ secret: 'ThisIsASecret'
+ session:
+ handler_id: session.handler.native_file
+ storage_id: session.storage.mock_file
+ save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
diff --git a/tests/Resources/Kernel/config/packages/monolog.yaml b/tests/Resources/Kernel/config/packages/monolog.yaml
new file mode 100644
index 0000000..2c5e682
--- /dev/null
+++ b/tests/Resources/Kernel/config/packages/monolog.yaml
@@ -0,0 +1,12 @@
+monolog:
+ handlers:
+ main:
+ type: rotating_file
+ path: '%kernel.logs_dir%/%kernel.environment%.log'
+ level: warning
+ max_files: 14
+ channels: ['!event', '!app']
+ console:
+ type: console
+ process_psr_3_messages: false
+ bubble: false
diff --git a/tests/Resources/Kernel/config/packages/rich_id_terms_module.yaml b/tests/Resources/Kernel/config/packages/rich_id_terms_module.yaml
new file mode 100644
index 0000000..f8ee0ec
--- /dev/null
+++ b/tests/Resources/Kernel/config/packages/rich_id_terms_module.yaml
@@ -0,0 +1,7 @@
+rich_id_terms_module:
+ admin_roles: [ ROLE_ADMIN ]
+ default_redirection_routes:
+ acceptation: app_acceptation_front
+ refusal: app_refusal_front
+ ignore: app_ignore_front
+ terms_version_signature_pdf_generator: RichId\TermsModuleSnappyBundle\Infrastructure\Pdf\TermsVersionSignaturePdfSnappyGenerator
diff --git a/tests/Resources/Kernel/config/packages/security.yaml b/tests/Resources/Kernel/config/packages/security.yaml
new file mode 100644
index 0000000..6c0ae45
--- /dev/null
+++ b/tests/Resources/Kernel/config/packages/security.yaml
@@ -0,0 +1,16 @@
+security:
+ providers:
+ database:
+ entity:
+ class: RichId\TermsModuleSnappyBundle\Tests\Resources\Entity\DummyUser
+ property: username
+ firewalls:
+ dev:
+ pattern: ^/(_(profiler|wdt)|css|images|js)/
+ security: false
+ main:
+ anonymous: ~
+ http_basic: ~
+ pattern: ^/
+ provider: database
+ stateless: false
diff --git a/tests/Resources/Kernel/config/services.yaml b/tests/Resources/Kernel/config/services.yaml
new file mode 100755
index 0000000..3d76ed1
--- /dev/null
+++ b/tests/Resources/Kernel/config/services.yaml
@@ -0,0 +1,12 @@
+services:
+ _defaults:
+ autoconfigure: true
+ autowire: true
+ public: true
+
+ RichId\TermsModuleSnappyBundle\Infrastructure\Pdf\TermsVersionSignaturePdfSnappyGenerator: ~
+
+ RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures\DummyUserFixtures: ~
+ RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures\TermsFixtures: ~
+ RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures\TermsVersionFixtures: ~
+ RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures\TermsVersionSignatureFixtures: ~