|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +namespace Articulate\Concise\Tests; |
| 5 | + |
| 6 | +use App\Components\AuthCredentials; |
| 7 | +use App\Components\Timestamps; |
| 8 | +use App\Entities\User; |
| 9 | +use App\Mappers\Components\AuthCredentialsMapper; |
| 10 | +use App\Mappers\Components\TimestampsMapper; |
| 11 | +use App\Mappers\Entities\UserMapper; |
| 12 | +use App\Providers\MapperServiceProvider; |
| 13 | +use Articulate\Concise\Concise; |
| 14 | +use Articulate\Concise\ConciseServiceProvider; |
| 15 | +use PHPUnit\Framework\Attributes\Test; |
| 16 | + |
| 17 | +class ConciseTest extends TestCase |
| 18 | +{ |
| 19 | + protected function getPackageProviders($app) |
| 20 | + { |
| 21 | + return [ |
| 22 | + MapperServiceProvider::class, |
| 23 | + ]; |
| 24 | + } |
| 25 | + |
| 26 | + #[Test] |
| 27 | + public function serviceProviderHasBeenRegistered(): void |
| 28 | + { |
| 29 | + $this->assertTrue($this->app->providerIsLoaded(ConciseServiceProvider::class)); |
| 30 | + } |
| 31 | + |
| 32 | + #[Test] |
| 33 | + public function isBoundToTheContainer(): void |
| 34 | + { |
| 35 | + $this->assertTrue($this->app->bound(Concise::class)); |
| 36 | + } |
| 37 | + |
| 38 | + #[Test] |
| 39 | + public function hasRegisteredMappersSuccessfully(): void |
| 40 | + { |
| 41 | + $this->assertTrue($this->app->providerIsLoaded(MapperServiceProvider::class)); |
| 42 | + |
| 43 | + $concise = $this->app->make(Concise::class); |
| 44 | + |
| 45 | + $entityMappers = $concise->getEntityMappers(); |
| 46 | + |
| 47 | + $this->assertNotEmpty($entityMappers); |
| 48 | + $this->assertCount(1, $entityMappers); |
| 49 | + $this->assertArrayHasKey(User::class, $entityMappers); |
| 50 | + $this->assertInstanceOf(UserMapper::class, $entityMappers[User::class]); |
| 51 | + |
| 52 | + $componentMappers = $concise->getComponentMappers(); |
| 53 | + |
| 54 | + $this->assertNotEmpty($componentMappers); |
| 55 | + $this->assertCount(2, $componentMappers); |
| 56 | + $this->assertArrayHasKey(AuthCredentials::class, $componentMappers); |
| 57 | + $this->assertArrayHasKey(Timestamps::class, $componentMappers); |
| 58 | + $this->assertInstanceOf(AuthCredentialsMapper::class, $componentMappers[AuthCredentials::class]); |
| 59 | + $this->assertInstanceOf(TimestampsMapper::class, $componentMappers[Timestamps::class]); |
| 60 | + } |
| 61 | +} |
0 commit comments