generated from rich-id/bundle-template
-
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
Jul 19, 2021
1 parent
b91ffe1
commit 9fba2a2
Showing
16 changed files
with
184 additions
and
20 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
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 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleBundle\Domain\UseCase; | ||
|
||
use RichId\TermsModuleBundle\Domain\Entity\TermsSubjectInterface; | ||
|
||
class HasSignedLastTermsVersion | ||
{ | ||
/** @var HasSignedTerms */ | ||
protected $hasSignedTerms; | ||
|
||
public function __construct(HasSignedTerms $hasSignedTerms) | ||
{ | ||
$this->hasSignedTerms = $hasSignedTerms; | ||
} | ||
|
||
public function __invoke(string $termsSlug, TermsSubjectInterface $subject): bool | ||
{ | ||
return ($this->hasSignedTerms)($termsSlug, $subject) === HasSignedTerms::HAS_SIGNED_LATEST_VERSION; | ||
} | ||
} |
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
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleBundle\Tests\Domain\Exception; | ||
|
||
use RichCongress\TestSuite\TestCase\TestCase; | ||
use RichId\TermsModuleBundle\Domain\Exception\InvalidValueException; | ||
use RichId\TermsModuleBundle\Domain\Exception\TermsModuleException; | ||
|
||
/** | ||
* @covers \RichId\TermsModuleBundle\Domain\Exception\InvalidValueException | ||
*/ | ||
final class InvalidValueExceptionTest extends TestCase | ||
{ | ||
public function testException(): void | ||
{ | ||
$exception = new InvalidValueException('title', 'invalid'); | ||
|
||
$this->assertInstanceOf(TermsModuleException::class, $exception); | ||
$this->assertSame('title', $exception->getPropertyPath()); | ||
$this->assertSame('invalid', $exception->getValue()); | ||
} | ||
} |
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
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,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleBundle\Tests\Domain\UseCase; | ||
|
||
use RichCongress\TestFramework\TestConfiguration\Annotation\TestConfig; | ||
use RichCongress\TestSuite\TestCase\TestCase; | ||
use RichId\TermsModuleBundle\Domain\Exception\NotFoundTermsException; | ||
use RichId\TermsModuleBundle\Domain\Model\DummySubject; | ||
use RichId\TermsModuleBundle\Domain\UseCase\HasSignedLastTermsVersion; | ||
|
||
/** | ||
* @covers \RichId\TermsModuleBundle\Domain\UseCase\HasSignedLastTermsVersion | ||
* @TestConfig("fixtures") | ||
*/ | ||
final class HasSignedLastTermsVersionTest extends TestCase | ||
{ | ||
/** @var HasSignedLastTermsVersion */ | ||
public $useCase; | ||
|
||
public function testUseCaseTermsNotExist(): void | ||
{ | ||
$this->expectException(NotFoundTermsException::class); | ||
$this->expectDeprecationMessage('Not found terms terms-999.'); | ||
|
||
$subject = DummySubject::create('user', '42'); | ||
($this->useCase)('terms-999', $subject); | ||
} | ||
|
||
public function testUseCaseTermsNotPublished(): void | ||
{ | ||
$subject = DummySubject::create('user', '42'); | ||
$hasSign = ($this->useCase)('terms-2', $subject); | ||
|
||
$this->assertFalse($hasSign); | ||
} | ||
|
||
public function testUseCaseSubjectNotExist(): void | ||
{ | ||
$subject = DummySubject::create('user', '999'); | ||
$hasSign = ($this->useCase)('terms-1', $subject); | ||
|
||
$this->assertFalse($hasSign); | ||
} | ||
|
||
public function testUseCaseHasSignOldVersion(): void | ||
{ | ||
$subject = DummySubject::create('user', '42'); | ||
$hasSign = ($this->useCase)('terms-1', $subject); | ||
|
||
$this->assertFalse($hasSign); | ||
} | ||
|
||
public function testUseCaseHasSignLatestVersion(): void | ||
{ | ||
$subject = DummySubject::create('user', '43'); | ||
$hasSign = ($this->useCase)('terms-1', $subject); | ||
|
||
$this->assertTrue($hasSign); | ||
} | ||
} |
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