diff --git a/composer.json b/composer.json index 2d9d0ed3..b31b5588 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,8 @@ "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/phpstan": "^1.9", "phpstan/phpstan-deprecation-rules": "^1.1", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.3", + "fakerphp/faker": "^1.23" }, "autoload": { "psr-4": { diff --git a/tests/Assets/AnotherListenerStub.php b/tests/Assets/AnotherListenerStub.php new file mode 100644 index 00000000..7c9f560f --- /dev/null +++ b/tests/Assets/AnotherListenerStub.php @@ -0,0 +1,7 @@ +password = 'myPassword'; + } +} diff --git a/tests/Assets/Auth/AuthenticableWithNonEmptyConstructorMock.php b/tests/Assets/Auth/AuthenticableWithNonEmptyConstructorMock.php new file mode 100644 index 00000000..47fc362d --- /dev/null +++ b/tests/Assets/Auth/AuthenticableWithNonEmptyConstructorMock.php @@ -0,0 +1,16 @@ +password = $passwords[0]; + } +} diff --git a/tests/Assets/Auth/Passwords/UserMock.php b/tests/Assets/Auth/Passwords/UserMock.php new file mode 100644 index 00000000..c106b527 --- /dev/null +++ b/tests/Assets/Auth/Passwords/UserMock.php @@ -0,0 +1,28 @@ +assertTrue(true); + } + + /** + * @return mixed[] + */ + public function getFilters(): array + { + return []; + } +} diff --git a/tests/Assets/Extensions/ExtensionMock2.php b/tests/Assets/Extensions/ExtensionMock2.php new file mode 100644 index 00000000..b4c7c636 --- /dev/null +++ b/tests/Assets/Extensions/ExtensionMock2.php @@ -0,0 +1,22 @@ + 'FilterMock', + 'filter2' => 'FilterMock' + ]; + } +} diff --git a/tests/Assets/FakeConnection.php b/tests/Assets/FakeConnection.php new file mode 100644 index 00000000..504b72ad --- /dev/null +++ b/tests/Assets/FakeConnection.php @@ -0,0 +1,9 @@ +id; + } + + public function getName() + { + return strtolower($this->name); + } +} diff --git a/tests/Assets/Middleware/BindableEntityWithInterface.php b/tests/Assets/Middleware/BindableEntityWithInterface.php new file mode 100644 index 00000000..97f4fab5 --- /dev/null +++ b/tests/Assets/Middleware/BindableEntityWithInterface.php @@ -0,0 +1,25 @@ +id; + } + + public function getName() + { + return strtolower($this->name); + } + + public static function getRouteKeyNameStatic(): string + { + return 'name'; + } +} diff --git a/tests/Assets/Middleware/EntityController.php b/tests/Assets/Middleware/EntityController.php new file mode 100644 index 00000000..768e14e7 --- /dev/null +++ b/tests/Assets/Middleware/EntityController.php @@ -0,0 +1,35 @@ +getName(); + } + + public function interfacer(BindableEntityWithInterface $entity) + { + return $entity->getId(); + } + + public function returnValue(string $value) + { + return $value; + } + + public function returnEntity(BindableEntity $entity = null) { + return $entity; + } + + public function returnEntityName(BindableEntity $entity) { + return $entity->getName(); + } + + public function checkRequest(Request $request) { + return $request instanceof Request ? 'request' : 'something else'; + } +} diff --git a/tests/Assets/Mock/CountableEntityMock.php b/tests/Assets/Mock/CountableEntityMock.php new file mode 100644 index 00000000..c5bb1ad0 --- /dev/null +++ b/tests/Assets/Mock/CountableEntityMock.php @@ -0,0 +1,7 @@ +name; + } +} diff --git a/tests/Assets/Testing/ChildHydrateableClass.php b/tests/Assets/Testing/ChildHydrateableClass.php new file mode 100644 index 00000000..0366d621 --- /dev/null +++ b/tests/Assets/Testing/ChildHydrateableClass.php @@ -0,0 +1,13 @@ +description; + } +} diff --git a/tests/Feature/Auth/DoctrineUserProviderTest.php b/tests/Feature/Auth/DoctrineUserProviderTest.php index c8841a70..ffda1daa 100644 --- a/tests/Feature/Auth/DoctrineUserProviderTest.php +++ b/tests/Feature/Auth/DoctrineUserProviderTest.php @@ -1,11 +1,13 @@ setPassword('originalPassword'); $this->hasher->shouldReceive('needsRehash')->once()->andReturn(false); @@ -189,23 +191,3 @@ protected function tearDown(): void m::close(); } } - -class AuthenticableMock implements AuthenticatableContract -{ - use Authenticatable; - - public function __construct() - { - $this->password = 'myPassword'; - } -} - -class AuthenticableWithNonEmptyConstructorMock implements AuthenticatableContract -{ - use Authenticatable; - - public function __construct(array $passwords) - { - $this->password = $passwords[0]; - } -} diff --git a/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php b/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php index 3d32fd89..b59bd44b 100644 --- a/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php +++ b/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php @@ -1,12 +1,14 @@ once() ->andReturn(true); - $this->repository->delete(new UserMock); + $this->repository->delete(new UserMock()); $this->assertTrue(true); } @@ -274,26 +276,3 @@ protected function tearDown(): void m::close(); } } - -class UserMock implements CanResetPassword -{ - /** - * Get the e-mail address where password reset links are sent. - * @return string - */ - public function getEmailForPasswordReset() - { - return 'user@mockery.mock'; - } - - /** - * Send the password reset notification. - * - * @param string $token - * @return void - */ - public function sendPasswordResetNotification($token) - { - // TODO: Implement sendPasswordResetNotification() method. - } -} diff --git a/tests/Feature/Configuration/Cache/AbstractCacheProviderTest.php b/tests/Feature/Configuration/Cache/AbstractCacheProviderTest.php index 91d58929..3b608496 100644 --- a/tests/Feature/Configuration/Cache/AbstractCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/AbstractCacheProviderTest.php @@ -1,5 +1,8 @@ getType('non_existing'); } } - -class TypeMock extends Type -{ - public function getSQLDeclaration(array $column, AbstractPlatform $platform): string - { - return ''; - } - - public function getName() - { - } -} -class TypeMock2 extends Type -{ - public function getSQLDeclaration(array $column, AbstractPlatform $platform): string - { - return ''; - } - - public function getName() - { - } -} diff --git a/tests/Feature/Configuration/LaravelNamingStategyTest.php b/tests/Feature/Configuration/LaravelNamingStrategyTest.php similarity index 98% rename from tests/Feature/Configuration/LaravelNamingStategyTest.php rename to tests/Feature/Configuration/LaravelNamingStrategyTest.php index b145b8ca..e9f63a8d 100644 --- a/tests/Feature/Configuration/LaravelNamingStategyTest.php +++ b/tests/Feature/Configuration/LaravelNamingStrategyTest.php @@ -1,5 +1,7 @@ shouldReceive('store')->with('myStoreName')->andReturn($cache); - $container->singleton(Illuminate\Contracts\Cache\Factory::class, function () use ($factory) { + $container->singleton(\Illuminate\Contracts\Cache\Factory::class, function () use ($factory) { return $factory; }); @@ -584,12 +594,12 @@ public function test_illuminate_cache_provider_redis() return $config; }); - $cache = M::mock(Illuminate\Contracts\Cache\Repository::class); + $cache = M::mock(\Illuminate\Contracts\Cache\Repository::class); $factory = M::mock(\Illuminate\Contracts\Cache\Factory::class); $factory->shouldReceive('store')->with('redis')->andReturn($cache); - $container->singleton(Illuminate\Contracts\Cache\Factory::class, function () use ($factory) { + $container->singleton(\Illuminate\Contracts\Cache\Factory::class, function () use ($factory) { return $factory; }); @@ -642,12 +652,12 @@ public function test_illuminate_cache_provider_invalid_store() return $config; }); - $cache = M::mock(Illuminate\Contracts\Cache\Repository::class); + $cache = M::mock(\Illuminate\Contracts\Cache\Repository::class); $factory = M::mock(\Illuminate\Contracts\Cache\Factory::class); $factory->shouldReceive('store')->with('myStoreName')->andReturn($cache); - $container->singleton(Illuminate\Contracts\Cache\Factory::class, function () use ($factory) { + $container->singleton(\Illuminate\Contracts\Cache\Factory::class, function () use ($factory) { return $factory; }); @@ -1208,45 +1218,3 @@ private function getDummyBaseInputConfig() ]; } } - -class FakeEventManager extends \Doctrine\Common\EventManager -{ -} - -class FakeConnection extends Connection -{ -} - -class FilterStub extends \Doctrine\ORM\Query\Filter\SQLFilter -{ - public function addFilterConstraint(\Doctrine\ORM\Mapping\ClassMetadata $targetEntity, string $targetTableAlias): string - { - return ''; - } -} - -class ListenerStub -{ -} - -class AnotherListenerStub -{ -} - -class SubscriberStub implements EventSubscriber -{ - /** - * Returns an array of events this subscriber wants to listen to. - * @return array - */ - public function getSubscribedEvents() - { - return [ - 'onFlush' - ]; - } -} - -class Decorator extends EntityManagerDecorator -{ -} diff --git a/tests/Feature/Extensions/ExtensionManagerTest.php b/tests/Feature/Extensions/ExtensionManagerTest.php index 49fc433e..5b2cfeeb 100644 --- a/tests/Feature/Extensions/ExtensionManagerTest.php +++ b/tests/Feature/Extensions/ExtensionManagerTest.php @@ -1,13 +1,18 @@ em = m::mock(EntityManagerInterface::class); $this->evm = m::mock(EventManager::class); $this->configuration = m::mock(Configuration::class); - $this->driver = m::mock(\Doctrine\ORM\Mapping\Driver\XmlDriver::class); - $this->reader = m::mock(Reader::class); + $this->driver = m::mock(XmlDriver::class); $this->manager = $this->newManager(); } @@ -93,7 +92,7 @@ public function test_boot_manager_with_one_manager_and_one_extension() // Should be inside booted extensions now $booted = $this->manager->getBootedExtensions(); - $this->assertTrue($booted['default']['ExtensionMock']); + $this->assertTrue((bool) $booted['default']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionMock']); } public function test_boot_manager_with_two_managers_and_one_extension() @@ -114,8 +113,8 @@ public function test_boot_manager_with_two_managers_and_one_extension() // Should be inside booted extensions now $booted = $this->manager->getBootedExtensions(); - $this->assertTrue($booted['default']['ExtensionMock']); - $this->assertTrue($booted['custom']['ExtensionMock']); + $this->assertTrue((bool) $booted['default']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionMock']); + $this->assertTrue((bool) $booted['custom']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionMock']); } public function test_boot_manager_with_one_manager_and_two_extensions() @@ -138,8 +137,8 @@ public function test_boot_manager_with_one_manager_and_two_extensions() // Should be inside booted extensions now $booted = $this->manager->getBootedExtensions(); - $this->assertTrue($booted['default']['ExtensionMock']); - $this->assertTrue($booted['default']['ExtensionMock2']); + $this->assertTrue((bool) $booted['default']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionMock']); + $this->assertTrue((bool) $booted['default']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionMock2']); } public function test_extension_will_only_be_booted_once() @@ -161,7 +160,7 @@ public function test_extension_will_only_be_booted_once() // Should be inside booted extensions now $booted = $this->manager->getBootedExtensions(); - $this->assertTrue($booted['default']['ExtensionMock']); + $this->assertTrue((bool) $booted['default']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionMock']); } public function test_filters_get_registered_on_boot() @@ -191,7 +190,8 @@ public function test_filters_get_registered_on_boot() // Should be inside booted extensions now $booted = $this->manager->getBootedExtensions(); - $this->assertTrue($booted['default']['ExtensionWithFiltersMock']); + + $this->assertTrue((bool) $booted['default']['LaravelDoctrineTest\ORM\Assets\Extensions\ExtensionWithFiltersMock']); } protected function tearDown(): void @@ -206,53 +206,3 @@ protected function newManager() return new ExtensionManager($this->container); } } - -class ExtensionMock implements Extension -{ - public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void - { - // Confirm it get's called - (new ExtensionManagerTest)->assertTrue(true); - } - - /** - * @return mixed[] - */ - public function getFilters(): array - { - return []; - } -} - -class ExtensionMock2 implements Extension -{ - public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void - { - } - - /** - * @return mixed[] - */ - public function getFilters(): array - { - return []; - } -} - -class ExtensionWithFiltersMock implements Extension -{ - public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void - { - } - - /** - * @return mixed[] - */ - public function getFilters(): array - { - return [ - 'filter' => 'FilterMock', - 'filter2' => 'FilterMock' - ]; - } -} diff --git a/tests/Feature/Extensions/MappingDriverChainTest.php b/tests/Feature/Extensions/MappingDriverChainTest.php index 283688e3..0da97cbe 100644 --- a/tests/Feature/Extensions/MappingDriverChainTest.php +++ b/tests/Feature/Extensions/MappingDriverChainTest.php @@ -1,5 +1,7 @@ registry = m::mock(ManagerRegistry::class); $this->em = m::mock(EntityManager::class); - $this->repository = m::mock(\Doctrine\Persistence\ObjectRepository::class); + $this->repository = m::mock(ObjectRepository::class); } protected function getRouter() @@ -57,7 +62,7 @@ protected function getRouter() protected function mockRegistry() { - $this->registry->shouldReceive('getRepository')->once()->with('BindableEntity')->andReturn($this->repository); + $this->registry->shouldReceive('getRepository')->once()->with('LaravelDoctrineTest\ORM\Assets\Middleware\BindableEntity')->andReturn($this->repository); } public function test_entity_binding() @@ -65,7 +70,7 @@ public function test_entity_binding() $router = $this->getRouter(); $router->get('foo/{entity}', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@returnEntityName', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@returnEntityName', ]); $this->mockRegistry(); @@ -85,7 +90,7 @@ public function test_entity_binding_expect_entity_not_found_exception() $router->get('foo/{entity}', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@returnEntityName', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@returnEntityName', ]); $this->mockRegistry(); @@ -99,7 +104,7 @@ public function test_entity_binding_get_null_entity() $router = $this->getRouter(); $router->get('foo/{entity}', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@returnEntity', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@returnEntity', ]); $this->mockRegistry(); @@ -113,14 +118,14 @@ public function test_binding_value() $router = $this->getRouter(); $router->get('foo/{value}', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@returnValue', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@returnValue', ]); $this->assertEquals(123456, $router->dispatch(Request::create('foo/123456', 'GET'))->getContent()); $router->get('doc/trine', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@checkRequest', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@checkRequest', ]); $this->assertEquals('request', $router->dispatch(Request::create('doc/trine', 'GET'))->getContent()); @@ -130,7 +135,7 @@ public function test_controller_entity_binding() { $router = $this->getRouter(); $router->get('foo/{entity}', [ - 'uses' => 'EntityController@index', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@index', 'middleware' => SubstituteBindings::class, ]); @@ -147,11 +152,11 @@ public function test_not_id_binding() { $router = $this->getRouter(); $router->get('foo/{entity}', [ - 'uses' => 'EntityController@interfacer', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@interfacer', 'middleware' => SubstituteBindings::class, ]); - $this->registry->shouldReceive('getRepository')->once()->with('BindableEntityWithInterface')->andReturn($this->repository); + $this->registry->shouldReceive('getRepository')->once()->with('LaravelDoctrineTest\ORM\Assets\Middleware\BindableEntityWithInterface')->andReturn($this->repository); $entity = new BindableEntityWithInterface(); $entity->id = 1; $entity->name = 'NAMEVALUE'; @@ -165,7 +170,7 @@ public function test_for_typed_value_binding() $router = $this->getRouter(); $router->get('foo/{value}', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@returnValue', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@returnValue', ]); $this->assertEquals('test', $router->dispatch(Request::create('foo/test', 'GET'))->getContent()); @@ -173,14 +178,14 @@ public function test_for_typed_value_binding() $router = $this->getRouter(); $router->get('bar/{value}', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@returnValue', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@returnValue', ]); $this->assertEquals(123456, $router->dispatch(Request::create('bar/123456', 'GET'))->getContent()); $router->get('doc/trine', [ 'middleware' => SubstituteBindings::class, - 'uses' => 'EntityController@checkRequest', + 'uses' => 'LaravelDoctrineTest\ORM\Assets\Middleware\EntityController@checkRequest', ]); $this->assertEquals('request', $router->dispatch(Request::create('doc/trine', 'GET'))->getContent()); @@ -191,72 +196,3 @@ protected function tearDown(): void m::close(); } } - -class BindableEntity -{ - public $id; - - public $name; - - public function getId() - { - return $this->id; - } - - public function getName() - { - return strtolower($this->name); - } -} - -class BindableEntityWithInterface implements \LaravelDoctrine\ORM\Contracts\UrlRoutable -{ - public $id; - - public $name; - - public function getId() - { - return $this->id; - } - - public function getName() - { - return strtolower($this->name); - } - - public static function getRouteKeyNameStatic(): string - { - return 'name'; - } -} - -class EntityController -{ - public function index(BindableEntity $entity) - { - return $entity->getName(); - } - - public function interfacer(BindableEntityWithInterface $entity) - { - return $entity->getId(); - } - - public function returnValue(string $value) - { - return $value; - } - - public function returnEntity(BindableEntity $entity = null) { - return $entity; - } - - public function returnEntityName(BindableEntity $entity) { - return $entity->getName(); - } - - public function checkRequest(Request $request) { - return $request instanceof Request ? 'request' : 'something else'; - } -} diff --git a/tests/Feature/Notifications/DoctrineChannelTest.php b/tests/Feature/Notifications/DoctrineChannelTest.php index 86320132..514afd01 100644 --- a/tests/Feature/Notifications/DoctrineChannelTest.php +++ b/tests/Feature/Notifications/DoctrineChannelTest.php @@ -1,12 +1,20 @@ channel->send(new CustomNotifiableStub(), new NotificationStub()); } } - -class NotificationStub extends \Illuminate\Notifications\Notification -{ - public function toEntity() - { - return (new \LaravelDoctrine\ORM\Notifications\Notification); - } -} - -class NotificationDatabaseStub extends \Illuminate\Notifications\Notification -{ - public function toDatabase() - { - return (new \LaravelDoctrine\ORM\Notifications\Notification); - } -} - -class NotificationInvalidStub extends \Illuminate\Notifications\Notification -{ -} - -class NotifiableStub -{ - use Notifiable; -} - -class CustomNotifiableStub -{ - use Notifiable; - - public function routeNotificationForDoctrine() - { - return 'custom'; - } -} diff --git a/tests/Feature/Notifications/NotificationTest.php b/tests/Feature/Notifications/NotificationTest.php index b00c11bd..79faca83 100644 --- a/tests/Feature/Notifications/NotificationTest.php +++ b/tests/Feature/Notifications/NotificationTest.php @@ -1,8 +1,14 @@ success(); $this->assertEquals('success', $entity->getLevel()); diff --git a/tests/Feature/Pagination/PaginatorAdapterTest.php b/tests/Feature/Pagination/PaginatorAdapterTest.php index 2fa21ae2..112f728b 100644 --- a/tests/Feature/Pagination/PaginatorAdapterTest.php +++ b/tests/Feature/Pagination/PaginatorAdapterTest.php @@ -1,5 +1,7 @@ mockEntityManager(); - $query = (new Query($em))->setDQL('SELECT f FROM Foo f'); + $query = (new Query($em))->setDQL('SELECT f FROM LaravelDoctrineTest\ORM\Assets\Entity\Foo f'); $adapter = PaginatorAdapter::fromParams($query, 15, 2); $paginator = $adapter->make(); @@ -35,7 +39,7 @@ public function testMakesLaravelsPaginatorFromRequest() }); $em = $this->mockEntityManager(); - $query = (new Query($em))->setDQL('SELECT f FROM Foo f'); + $query = (new Query($em))->setDQL('SELECT f FROM LaravelDoctrineTest\ORM\Assets\Entity\Foo f'); $adapter = PaginatorAdapter::fromRequest($query); $paginator = $adapter->make(); @@ -47,7 +51,7 @@ public function testMakesLaravelsPaginatorFromRequest() public function testQueryParametersAreProducedInUrlFromParams() { $em = $this->mockEntityManager(); - $query = (new Query($em))->setDQL('SELECT f FROM Foo f'); + $query = (new Query($em))->setDQL('SELECT f FROM LaravelDoctrineTest\ORM\Assets\Entity\Foo f'); $adapter = PaginatorAdapter::fromParams($query, 15, 2, false) ->queryParams(['foo' => 'bar']); @@ -61,7 +65,7 @@ public function testQueryParametersAreProducedInUrlFromParams() public function testQueryParametersAreProducedInUrlFromRequest() { $em = $this->mockEntityManager(); - $query = (new Query($em))->setDQL('SELECT f FROM Foo f'); + $query = (new Query($em))->setDQL('SELECT f FROM LaravelDoctrineTest\ORM\Assets\Entity\Foo f'); $adapter = PaginatorAdapter::fromRequest($query) ->queryParams(['foo' => 'bar']); @@ -76,12 +80,12 @@ public function testQueryParametersAreProducedInUrlFromRequest() private function mockEntityManager() { /** @var EntityManagerInterface|\Mockery\Mock $em */ - $em = \Mockery::mock(EntityManagerInterface::class); - $config = \Mockery::mock(Configuration::class); - $metadata = \Mockery::mock(ClassMetadata::class); - $connection = \Mockery::mock(Connection::class); - $platform = \Mockery::mock(AbstractPlatform::class); - $hydrator = \Mockery::mock(AbstractHydrator::class); + $em = Mockery::mock(EntityManagerInterface::class); + $config = Mockery::mock(Configuration::class); + $metadata = Mockery::mock(ClassMetadata::class); + $connection = Mockery::mock(Connection::class); + $platform = Mockery::mock(AbstractPlatform::class); + $hydrator = Mockery::mock(AbstractHydrator::class); $config->shouldReceive('getDefaultQueryHints')->andReturn([]); $config->shouldReceive('isSecondLevelCacheEnabled')->andReturn(false); @@ -143,7 +147,7 @@ private function mockEntityManager() $hydrator->shouldReceive('hydrateAll')->andReturn([]); $em->shouldReceive('getConfiguration')->andReturn($config); - $em->shouldReceive('getClassMetadata')->with('Foo')->andReturn($metadata); + $em->shouldReceive('getClassMetadata')->with('LaravelDoctrineTest\ORM\Assets\Entity\Foo')->andReturn($metadata); $em->shouldReceive('getConnection')->andReturn($connection); $em->shouldReceive('hasFilters')->andReturn(false); $em->shouldReceive('newHydrator')->andReturn($hydrator); @@ -151,10 +155,3 @@ private function mockEntityManager() return $em; } } - -class Foo -{ - private $id; - - private $name; -} diff --git a/tests/Feature/Resolvers/EntityListenerResolverTest.php b/tests/Feature/Resolvers/EntityListenerResolverTest.php index 676734e9..40f183db 100644 --- a/tests/Feature/Resolvers/EntityListenerResolverTest.php +++ b/tests/Feature/Resolvers/EntityListenerResolverTest.php @@ -1,10 +1,14 @@ 'Patrick', ]); - $this->assertInstanceOf(BaseHydrateableClass::class, $entity); + $this->assertInstanceOf(AncestorHydrateableClass::class, $entity); $this->assertEquals('Patrick', $entity->getName()); } @@ -27,23 +31,3 @@ public function test_can_hydrate_with_extension_of_private_properties() $this->assertEquals('Hello World', $entity->getDescription()); } } - -class ChildHydrateableClass extends BaseHydrateableClass -{ - private $description; - - public function getDescription() - { - return $this->description; - } -} - -class BaseHydrateableClass -{ - private $name; - - public function getName() - { - return $this->name; - } -} diff --git a/tests/Feature/Validation/DoctrinePresenceVerifierTest.php b/tests/Feature/Validation/DoctrinePresenceVerifierTest.php index ed933f2b..36130394 100644 --- a/tests/Feature/Validation/DoctrinePresenceVerifierTest.php +++ b/tests/Feature/Validation/DoctrinePresenceVerifierTest.php @@ -1,10 +1,15 @@ em = m::mock(EntityManagerInterface::class); $this->registry = m::mock(ManagerRegistry::class); $this->builder = m::mock(QueryBuilder::class); - $this->query = m::mock(Doctrine\ORM\Query::class); + $this->query = m::mock(Query::class); $this->verifier = new DoctrinePresenceVerifier( $this->registry @@ -200,7 +205,7 @@ public function test_counting_invalid_entity_throws_exception() ->andReturn(null); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('No Entity Manager could be found for [CountableEntityMock].'); + $this->expectExceptionMessage('No Entity Manager could be found for [LaravelDoctrineTest\ORM\Assets\Mock\CountableEntityMock].'); $this->verifier->getCount(CountableEntityMock::class, 'email', 'test@email.com'); } @@ -254,7 +259,7 @@ protected function defaultGetMultiCountMocks() $this->builder->shouldReceive('where') ->once(); - $this->builder->shouldReceive('expr')->andReturn(new \Doctrine\ORM\Query\Expr()); + $this->builder->shouldReceive('expr')->andReturn(new Expr()); $this->builder->shouldReceive('in')->with("e.email", ['test@email.com']); $this->builder->shouldReceive('getQuery') @@ -268,7 +273,3 @@ protected function tearDown(): void m::close(); } } - -class CountableEntityMock -{ -} diff --git a/tests/Stubs/Faker/Generator.php b/tests/Stubs/Faker/Generator.php deleted file mode 100644 index 436204b7..00000000 --- a/tests/Stubs/Faker/Generator.php +++ /dev/null @@ -1,7 +0,0 @@ -