diff --git a/src/Filter/CallbackFilter.php b/src/Filter/CallbackFilter.php index a0af581e5..c327a22e2 100644 --- a/src/Filter/CallbackFilter.php +++ b/src/Filter/CallbackFilter.php @@ -61,8 +61,9 @@ public function getRenderSettings(): array protected function association(ProxyQueryInterface $query, FilterData $data): array { - $alias = $query->entityJoin($this->getParentAssociationMappings()); + $alias = $this->getOption('alias', $query->entityJoin($this->getParentAssociationMappings())); + \assert(\is_string($alias)); - return [$this->getOption('alias', $alias), $this->getFieldName()]; + return [$alias, $this->getFieldName()]; } } diff --git a/tests/DependencyInjection/SonataDoctrineORMAdminExtensionTest.php b/tests/DependencyInjection/SonataDoctrineORMAdminExtensionTest.php index 25b8537eb..0a48ea0d8 100644 --- a/tests/DependencyInjection/SonataDoctrineORMAdminExtensionTest.php +++ b/tests/DependencyInjection/SonataDoctrineORMAdminExtensionTest.php @@ -19,26 +19,16 @@ class SonataDoctrineORMAdminExtensionTest extends TestCase { - /** - * @var ContainerBuilder - */ - protected $configuration; - - protected function tearDown(): void - { - unset($this->configuration); - } - public function testEntityManagerSetFactory(): void { - $this->configuration = new ContainerBuilder(); - $this->configuration->setParameter('kernel.bundles', ['SimpleThingsEntityAuditBundle' => true]); + $configuration = new ContainerBuilder(); + $configuration->setParameter('kernel.bundles', ['SimpleThingsEntityAuditBundle' => true]); $loader = new SonataDoctrineORMAdminExtension(); - $loader->load([], $this->configuration); + $loader->load([], $configuration); - $definition = $this->configuration->getDefinition('sonata.admin.entity_manager'); + $definition = $configuration->getDefinition('sonata.admin.entity_manager'); $this->assertNotNull($definition->getFactory()); - $this->assertNotFalse($this->configuration->getParameter('sonata_doctrine_orm_admin.audit.force')); + $this->assertNotFalse($configuration->getParameter('sonata_doctrine_orm_admin.audit.force')); } } diff --git a/tests/Filter/FilterTestCase.php b/tests/Filter/FilterTestCase.php index 2eaa8745c..2304153a5 100644 --- a/tests/Filter/FilterTestCase.php +++ b/tests/Filter/FilterTestCase.php @@ -108,13 +108,13 @@ private function createExprStub(): Expr $expr = $this->createStub(Expr::class); $expr->method('orX')->willReturnCallback( - static function ($x = null): Orx { + static function (): Orx { return new Orx(\func_get_args()); } ); $expr->method('andX')->willReturnCallback( - static function ($x = null): Andx { + static function (): Andx { return new Andx(\func_get_args()); } ); diff --git a/tests/Fixtures/Entity/ContainerEntity.php b/tests/Fixtures/Entity/ContainerEntity.php index 3fe1f4da0..6cc6ef45a 100644 --- a/tests/Fixtures/Entity/ContainerEntity.php +++ b/tests/Fixtures/Entity/ContainerEntity.php @@ -16,7 +16,7 @@ class ContainerEntity { /** - * @var int + * @var int|null */ protected $plainField; diff --git a/tests/Fixtures/Entity/Embeddable/EmbeddedEntity.php b/tests/Fixtures/Entity/Embeddable/EmbeddedEntity.php index 98d1588c9..d94b5274e 100644 --- a/tests/Fixtures/Entity/Embeddable/EmbeddedEntity.php +++ b/tests/Fixtures/Entity/Embeddable/EmbeddedEntity.php @@ -16,11 +16,32 @@ class EmbeddedEntity { /** - * @var bool + * @var bool|null */ - protected $plainField; + public $plainField; + /** - * @var SubEmbeddedEntity + * @var SubEmbeddedEntity|null */ - protected $subEmbeddedEntity; + private $subEmbeddedEntity; + + public function setPlainField(bool $plainField): void + { + $this->plainField = $plainField; + } + + public function getPlaingField(): ?bool + { + return $this->plainField; + } + + public function setSubEmbeddedEntity(SubEmbeddedEntity $subEmbeddedEntity): void + { + $this->subEmbeddedEntity = $subEmbeddedEntity; + } + + public function getSubEmbeddedEntity(): ?SubEmbeddedEntity + { + return $this->subEmbeddedEntity; + } } diff --git a/tests/Fixtures/Entity/Embeddable/SubEmbeddedEntity.php b/tests/Fixtures/Entity/Embeddable/SubEmbeddedEntity.php index 64662b687..3029c25fc 100644 --- a/tests/Fixtures/Entity/Embeddable/SubEmbeddedEntity.php +++ b/tests/Fixtures/Entity/Embeddable/SubEmbeddedEntity.php @@ -16,7 +16,17 @@ class SubEmbeddedEntity { /** - * @var bool + * @var bool|null */ - protected $plainField; + private $plainField; + + public function setPlainField(bool $plainField): void + { + $this->plainField = $plainField; + } + + public function getPlaingField(): ?bool + { + return $this->plainField; + } } diff --git a/tests/Fixtures/Entity/ORM/Menu.php b/tests/Fixtures/Entity/ORM/Menu.php deleted file mode 100644 index 0c0ad6956..000000000 --- a/tests/Fixtures/Entity/ORM/Menu.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Entity\ORM; - -use Doctrine\ORM\Mapping as ORM; - -/** - * @ORM\Entity - */ -class Menu -{ - /** - * @ORM\Column(type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * - * @var int|null - */ - private $id; - - /** - * @ORM\Column(name="lft", type="integer") - * - * @var int|null - */ - private $lft; - - /** - * @ORM\Column(name="lvl", type="integer") - * - * @var int|null - */ - private $lvl; - - /** - * @ORM\Column(name="rgt", type="integer") - * - * @var int|null - */ - private $rgt; - - /** - * @ORM\ManyToOne(targetEntity="Menu") - * @ORM\JoinColumn(name="tree_root", referencedColumnName="id", onDelete="CASCADE") - * - * @var Menu|null - */ - private $root; - - /** - * @ORM\ManyToOne(targetEntity="Menu", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE") - * - * @var Menu|null - */ - private $parent; - - /** - * @ORM\OneToMany(targetEntity="Menu", mappedBy="parent") - * @ORM\OrderBy({"lft" = "ASC"}) - * - * @var Menu|null - */ - private $children; -} diff --git a/tests/Fixtures/Entity/ORM/Product.php b/tests/Fixtures/Entity/ORM/Product.php deleted file mode 100644 index e5b9d9545..000000000 --- a/tests/Fixtures/Entity/ORM/Product.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Entity\ORM; - -use Doctrine\ORM\Mapping as ORM; - -/** - * @ORM\Entity - */ -class Product -{ - /** - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * - * @var int|null - */ - private $id; - - /** - * @ORM\OneToMany(targetEntity="StoreProduct", mappedBy="product") - * - * @var StoreProduct[] - */ - private $products; -} diff --git a/tests/Fixtures/Entity/ORM/Store.php b/tests/Fixtures/Entity/ORM/Store.php deleted file mode 100644 index 564c5f8f9..000000000 --- a/tests/Fixtures/Entity/ORM/Store.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Entity\ORM; - -use Doctrine\ORM\Mapping as ORM; - -/** - * @ORM\Entity - */ -class Store -{ - /** - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * - * @var int|null - */ - private $id; - - /** - * @ORM\OneToMany(targetEntity="StoreProduct", mappedBy="store") - * - * @var StoreProduct[] - */ - private $stores; -} diff --git a/tests/Fixtures/Entity/ORM/StoreProduct.php b/tests/Fixtures/Entity/ORM/StoreProduct.php deleted file mode 100644 index bf01dda9f..000000000 --- a/tests/Fixtures/Entity/ORM/StoreProduct.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Entity\ORM; - -use Doctrine\ORM\Mapping as ORM; - -/** - * @ORM\Entity - */ -class StoreProduct -{ - /** - * @ORM\ManyToOne(targetEntity="Store", inversedBy="stores") - * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") - * @ORM\Id() - * @ORM\GeneratedValue("NONE") - * - * @var Store|null - */ - protected $store; - - /** - * @ORM\ManyToOne(targetEntity="Product", inversedBy="products") - * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") - * @ORM\Id() - * @ORM\GeneratedValue("NONE") - * - * @var Product|null - */ - protected $product; - - /** - * @ORM\Column(type="string") - * - * @var string|null - */ - protected $name; -} diff --git a/tests/Fixtures/Entity/ORM/User.php b/tests/Fixtures/Entity/ORM/User.php index 22aa7e0cb..305db51fb 100644 --- a/tests/Fixtures/Entity/ORM/User.php +++ b/tests/Fixtures/Entity/ORM/User.php @@ -25,7 +25,17 @@ class User * @ORM\GeneratedValue(strategy="AUTO") * @ORM\Column(name="id", type="integer") * - * @var int + * @var int|null */ private $id; + + public function setId(int $id): void + { + $this->id = $id; + } + + public function getId(): ?int + { + return $this->id; + } } diff --git a/tests/Fixtures/Entity/ORM/UserBrowser.php b/tests/Fixtures/Entity/ORM/UserBrowser.php index 42b98613a..5cd606434 100644 --- a/tests/Fixtures/Entity/ORM/UserBrowser.php +++ b/tests/Fixtures/Entity/ORM/UserBrowser.php @@ -25,7 +25,7 @@ class UserBrowser * @ORM\GeneratedValue(strategy="NONE") * @ORM\Column(type="integer") * - * @var int + * @var int|null */ private $userId; @@ -34,7 +34,27 @@ class UserBrowser * @ORM\GeneratedValue(strategy="NONE") * @ORM\Column(type="integer") * - * @var int + * @var int|null */ private $browserId; + + public function setUserId(int $userId): void + { + $this->userId = $userId; + } + + public function getUserId(): ?int + { + return $this->userId; + } + + public function setBrowserId(int $browserId): void + { + $this->browserId = $browserId; + } + + public function getBrowserId(): ?int + { + return $this->browserId; + } } diff --git a/tests/Model/ModelManagerTest.php b/tests/Model/ModelManagerTest.php index f1305b2ca..a2fce9ec8 100644 --- a/tests/Model/ModelManagerTest.php +++ b/tests/Model/ModelManagerTest.php @@ -16,7 +16,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\MySqlPlatform; -use Doctrine\DBAL\Platforms\PostgreSqlPlatform; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -91,6 +91,8 @@ public function valueObjectDataProvider(): iterable } /** + * @param class-string $vbClassName + * * @dataProvider valueObjectDataProvider */ public function testGetIdentifierValuesWhenIdentifierIsValueObjectWithToStringMethod(string $vbClassName): void @@ -329,7 +331,7 @@ public function testGetIdentifierValuesForIdInObjectTypeBinaryToStringSupport(): ->method('getTypeOfField') ->willReturn(UuidBinaryType::NAME); //'uuid_binary' - $platform = $this->createMock(PostgreSqlPlatform::class); + $platform = $this->createMock(PostgreSQL94Platform::class); $platform->expects($this->any()) ->method('hasDoctrineTypeMappingFor') ->with(UuidBinaryType::NAME) @@ -374,7 +376,7 @@ public function testNonIntegerIdentifierType(): void ->method('getTypeOfField') ->willReturn(UuidType::NAME); - $platform = $this->createMock(PostgreSqlPlatform::class); + $platform = $this->createMock(PostgreSQL94Platform::class); $platform->expects($this->any()) ->method('hasDoctrineTypeMappingFor') ->with(UuidType::NAME) @@ -417,7 +419,7 @@ public function testIntegerIdentifierType(): void ->method('getTypeOfField') ->willReturn(ProductIdType::NAME); - $platform = $this->createMock(PostgreSqlPlatform::class); + $platform = $this->createMock(PostgreSQL94Platform::class); $platform->expects($this->any()) ->method('hasDoctrineTypeMappingFor') ->with(ProductIdType::NAME) @@ -459,7 +461,7 @@ public function testAssociationIdentifierType(): void ->method('getTypeOfField') ->willReturn(null); - $platform = $this->createMock(PostgreSqlPlatform::class); + $platform = $this->createMock(PostgreSQL94Platform::class); $platform->expects($this->never()) ->method('hasDoctrineTypeMappingFor');