|
| 1 | +<?php |
| 2 | +declare( strict_types = 1 ); |
| 3 | + |
| 4 | +namespace TheWebSolver\Codegarage\Test\Adapter; |
| 5 | + |
| 6 | +use Composer\InstalledVersions; |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use TheWebSolver\Codegarage\Cli\Cli; |
| 9 | +use Psr\Container\ContainerInterface; |
| 10 | +use PHPUnit\Framework\Attributes\Test; |
| 11 | +use TheWebSolver\Codegarage\Iso\Cli\Iso3166Command; |
| 12 | +use TheWebSolver\Codegarage\Iso\Cli\Iso4217Command; |
| 13 | +use TheWebSolver\Codegarage\Cli\Adapter\CompilableCommandLoader; |
| 14 | + |
| 15 | +class CompilableCommandLoaderTest extends TestCase { |
| 16 | + #[Test] |
| 17 | + public function createsCompilableCommandsForIsoPackage(): void { |
| 18 | + $isoCli = InstalledVersions::getInstallPath( 'thewebsolver/iso-cli' ); |
| 19 | + $loader = CompilableCommandLoader::start() |
| 20 | + ->inDirectory( "{$isoCli}/Src", 'TheWebSolver\Codegarage\Iso\Cli' ) |
| 21 | + ->load( $this->getContainerMock() ); |
| 22 | + |
| 23 | + $this->assertArrayHasKey( Iso3166Command::class, $loader->getArrayFile()->getContent() ); |
| 24 | + $this->assertArrayHasKey( Iso4217Command::class, $loader->getArrayFile()->getContent() ); |
| 25 | + } |
| 26 | + |
| 27 | + private function getContainerMock(): ContainerInterface { |
| 28 | + ( $container = $this->createMock( Container::class ) ) |
| 29 | + ->method( 'get' ) |
| 30 | + ->with( Cli::class ) |
| 31 | + ->willReturn( $this->createStub( Cli::class ) ); |
| 32 | + |
| 33 | + return $container; |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound |
| 38 | + |
| 39 | +class Container implements ContainerInterface { |
| 40 | + public function set( string $id ): void {} |
| 41 | + public function get( string $id ): mixed { |
| 42 | + return null; |
| 43 | + } |
| 44 | + public function has( string $id ): bool { |
| 45 | + return false; |
| 46 | + } |
| 47 | +} |
0 commit comments