-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(phpat): test shared infrastructure architecture
- Loading branch information
1 parent
4ae23d9
commit ebdca74
Showing
6 changed files
with
113 additions
and
43 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,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CodelyTv\Tests\Mooc; | ||
|
||
use CodelyTv\Tests\Shared\Infrastructure\ArchitectureTest; | ||
use PHPat\Selector\Selector; | ||
use PHPat\Test\Builder\Rule; | ||
use PHPat\Test\PHPat; | ||
|
||
final class MoocArchitectureTest | ||
{ | ||
public function test_mooc_domain_should_only_import_itself_and_shared(): Rule | ||
{ | ||
return PHPat::rule() | ||
->classes(Selector::inNamespace('/^CodelyTv\\\\Mooc\\\\.+\\\\Domain/', true)) | ||
->canOnlyDependOn() | ||
->classes(...array_merge(ArchitectureTest::languageClasses(), [ | ||
// Itself | ||
Selector::inNamespace('/^CodelyTv\\\\Mooc\\\\.+\\\\Domain/', true), | ||
// Shared | ||
Selector::inNamespace('CodelyTv\Shared\Domain'), | ||
])) | ||
->because('mooc domain can only import itself and shared domain'); | ||
} | ||
|
||
public function test_mooc_application_should_only_import_itself_and_domain(): Rule | ||
{ | ||
return PHPat::rule() | ||
->classes(Selector::inNamespace('/^CodelyTv\\\\Mooc\\\\.+\\\\Application/', true)) | ||
->canOnlyDependOn() | ||
->classes(...array_merge(ArchitectureTest::languageClasses(), [ | ||
// Itself | ||
Selector::inNamespace('/^CodelyTv\\\\Mooc\\\\.+\\\\Application/', true), | ||
Selector::inNamespace('/^CodelyTv\\\\Mooc\\\\.+\\\\Domain/', true), | ||
// Shared | ||
Selector::inNamespace('CodelyTv\Shared'), | ||
])) | ||
->because('mooc application can only import itself and shared'); | ||
} | ||
|
||
public function test_mooc_infrastructure_should_not_import_other_contexts_beside_shared(): Rule | ||
{ | ||
return PHPat::rule() | ||
->classes(Selector::inNamespace('CodelyTv\Mooc')) | ||
->shouldNotDependOn() | ||
->classes(Selector::inNamespace('CodelyTv')) | ||
->excluding( | ||
// Itself | ||
Selector::inNamespace('CodelyTv\Mooc'), | ||
// Shared | ||
Selector::inNamespace('CodelyTv\Shared'), | ||
); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CodelyTv\Tests\Shared\Infrastructure; | ||
|
||
use ArrayIterator; | ||
use BackedEnum; | ||
use Countable; | ||
use DateTimeImmutable; | ||
use DateTimeInterface; | ||
use DomainException; | ||
use InvalidArgumentException; | ||
use IteratorAggregate; | ||
use PHPat\Selector\Selector; | ||
use RuntimeException; | ||
use Stringable; | ||
use Throwable; | ||
use Traversable; | ||
|
||
final class ArchitectureTest | ||
{ | ||
public static function languageClasses(): array | ||
{ | ||
return [ | ||
Selector::classname(Throwable::class), | ||
Selector::classname(InvalidArgumentException::class), | ||
Selector::classname(RuntimeException::class), | ||
Selector::classname(DateTimeImmutable::class), | ||
Selector::classname(DateTimeInterface::class), | ||
Selector::classname(DomainException::class), | ||
Selector::classname(Stringable::class), | ||
Selector::classname(BackedEnum::class), | ||
Selector::classname(Countable::class), | ||
Selector::classname(IteratorAggregate::class), | ||
Selector::classname(Traversable::class), | ||
Selector::classname(ArrayIterator::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