mapado /
rest-client-sdk
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Mapado\RestClientSdk\Tests\Units; |
||
| 6 | |||
| 7 | use atoum; |
||
| 8 | use Mapado\RestClientSdk\Mapping as RestMapping; |
||
| 9 | use Mapado\RestClientSdk\Mapping\ClassMetadata; |
||
| 10 | use Mapado\RestClientSdk\Model\Serializer; |
||
| 11 | use Mapado\RestClientSdk\UnitOfWork; |
||
|
0 ignored issues
–
show
|
|||
| 12 | |||
| 13 | /** |
||
| 14 | * SdkClient |
||
| 15 | * |
||
| 16 | * @uses \atoum |
||
| 17 | * |
||
| 18 | * @author Julien Deniau <[email protected]> |
||
| 19 | */ |
||
| 20 | class SdkClient extends atoum |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * testGetRepository |
||
| 24 | */ |
||
| 25 | public function testGetRepository() |
||
| 26 | { |
||
| 27 | $this->mockGenerator->orphanize('__construct'); |
||
| 28 | $this->mockGenerator->shuntParentClassCalls(); |
||
| 29 | $restClient = new \mock\Mapado\RestClientSdk\RestClient(); |
||
|
0 ignored issues
–
show
The type
mock\Mapado\RestClientSdk\RestClient was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 30 | $this->mockGenerator->unshuntParentClassCalls(); |
||
| 31 | |||
| 32 | $mapping = new RestMapping(); |
||
| 33 | $mapping->setMapping([ |
||
| 34 | new ClassMetadata( |
||
| 35 | 'orders', |
||
| 36 | 'Mapado\RestClientSdk\Tests\Model\JsonLd\Model', |
||
| 37 | 'Mapado\RestClientSdk\Tests\Model\JsonLd\ModelRepository' |
||
| 38 | ), |
||
| 39 | ]); |
||
| 40 | |||
| 41 | $unitOfWork = new UnitOfWork($mapping); |
||
| 42 | $serializer = new Serializer($mapping, $unitOfWork); |
||
| 43 | |||
| 44 | $this |
||
| 45 | ->given($testedInstance = $this->newTestedInstance($restClient, $mapping, $unitOfWork, $serializer)) |
||
| 46 | ->then |
||
| 47 | ->object($testedInstance->getRestClient()) |
||
| 48 | ->isIdenticalTo($restClient) |
||
| 49 | |||
| 50 | ->then |
||
| 51 | ->object($testedInstance->getMapping()) |
||
| 52 | ->isIdenticalTo($mapping) |
||
| 53 | |||
| 54 | ->then |
||
| 55 | ->object($testedInstance->getSerializer()) |
||
| 56 | ->isIdenticalTo($serializer) |
||
| 57 | |||
| 58 | ->then |
||
| 59 | ->object($testedInstance->getRepository('Mapado\RestClientSdk\Tests\Model\JsonLd\Model')) |
||
| 60 | ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\ModelRepository') |
||
| 61 | |||
| 62 | ->object($testedInstance->getRepository('orders')) |
||
| 63 | ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\ModelRepository') |
||
| 64 | |||
| 65 | ->exception(function () use ($testedInstance) { |
||
| 66 | $testedInstance->getRepository('foo'); |
||
| 67 | }) |
||
| 68 | ->isInstanceOf('Mapado\RestClientSdk\Exception\MappingException') |
||
| 69 | ; |
||
| 70 | } |
||
| 71 | } |
||
| 72 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: