-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dumazeau
committed
Oct 11, 2023
1 parent
236701f
commit 0b8b1ed
Showing
17 changed files
with
416 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests; | ||
|
||
use RichCongress\TestFramework\TestConfiguration\Annotation\TestConfig; | ||
use RichCongress\TestSuite\TestCase\TestCase; | ||
use RichId\TermsModuleBundle\Domain\Entity\TermsVersionSignature; | ||
use RichId\TermsModuleSnappyBundle\Infrastructure\Pdf\TermsVersionSignaturePdfSnappyGenerator; | ||
use RichId\TermsModuleSnappyBundle\Tests\Resources\Entity\DummyUser; | ||
|
||
/** | ||
* @covers \RichId\TermsModuleSnappyBundle\Infrastructure\Pdf\TermsVersionSignaturePdfSnappyGenerator | ||
* @TestConfig("fixtures") | ||
*/ | ||
final class GeneratorTest extends TestCase | ||
{ | ||
/** @var TermsVersionSignaturePdfSnappyGenerator */ | ||
public $generator; | ||
|
||
public function testGeneratorWithoutEditor(): void | ||
{ | ||
$signature = $this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests\Resources\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use RichId\TermsModuleBundle\Domain\Entity\TermsUserInterface; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
/** | ||
* @ORM\Entity() | ||
* @ORM\Table(name="app_user") | ||
*/ | ||
final class DummyUser implements UserInterface, TermsUserInterface | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Id | ||
* @ORM\Column(type="integer", options={"unsigned":true}) | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255, nullable=false) | ||
*/ | ||
private $username; | ||
|
||
/** | ||
* @var array<string> | ||
* | ||
* @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<string> */ | ||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures; | ||
|
||
use RichCongress\RecurrentFixturesTestBundle\DataFixture\AbstractFixture; | ||
use RichId\TermsModuleSnappyBundle\Tests\Resources\Entity\DummyUser; | ||
|
||
final class DummyUserFixtures extends AbstractFixture | ||
{ | ||
public const USER = '1'; | ||
|
||
protected function loadFixtures(): void | ||
{ | ||
$this->createObject( | ||
DummyUser::class, | ||
self::USER, | ||
[ | ||
'username' => 'my_user_1', | ||
'roles' => ['ROLE_USER'], | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures; | ||
|
||
use RichCongress\RecurrentFixturesTestBundle\DataFixture\AbstractFixture; | ||
use RichId\TermsModuleBundle\Domain\Entity\Terms; | ||
|
||
final class TermsFixtures extends AbstractFixture | ||
{ | ||
protected function loadFixtures(): void | ||
{ | ||
$this->createObject( | ||
Terms::class, | ||
'1', | ||
[ | ||
'slug' => 'terms-1', | ||
'name' => 'Terms 1', | ||
'isPublished' => true, | ||
'isDepublicationLocked' => true, | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures; | ||
|
||
use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||
use RichCongress\RecurrentFixturesTestBundle\DataFixture\AbstractFixture; | ||
use RichId\TermsModuleBundle\Domain\Entity\Terms; | ||
use RichId\TermsModuleBundle\Domain\Entity\TermsVersion; | ||
|
||
final class TermsVersionFixtures extends AbstractFixture implements DependentFixtureInterface | ||
{ | ||
protected function loadFixtures(): void | ||
{ | ||
$terms1 = $this->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, | ||
]; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/Resources/Fixtures/TermsVersionSignatureFixtures.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests\Resources\Fixtures; | ||
|
||
use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||
use RichCongress\RecurrentFixturesTestBundle\DataFixture\AbstractFixture; | ||
use RichId\TermsModuleBundle\Domain\Entity\TermsVersion; | ||
use RichId\TermsModuleBundle\Domain\Entity\TermsVersionSignature; | ||
|
||
final class TermsVersionSignatureFixtures extends AbstractFixture implements DependentFixtureInterface | ||
{ | ||
protected function loadFixtures(): void | ||
{ | ||
$termsVersion1 = $this->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, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleSnappyBundle\Tests\Resources\Kernel; | ||
|
||
use RichCongress\WebTestBundle\Kernel\DefaultTestKernel; | ||
|
||
final class TestKernel extends DefaultTestKernel | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('test', true); | ||
} | ||
|
||
public function getConfigurationDir(): ?string | ||
{ | ||
return __DIR__ . '/config'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
use RichId\TermsModuleSnappyBundle\Tests\Resources\Kernel\TestKernel; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\ArgvInput; | ||
|
||
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { | ||
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; | ||
} | ||
|
||
set_time_limit(0); | ||
|
||
require dirname(__DIR__).'/../../../vendor/autoload.php'; | ||
|
||
if (!class_exists(Application::class)) { | ||
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.'); | ||
} | ||
|
||
$input = new ArgvInput(); | ||
$kernel = new TestKernel(); | ||
$application = new Application($kernel); | ||
$application->run($input); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['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], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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%' |
Oops, something went wrong.