From 5058deb9c2d60978a08cba555bd51e24fea1bc49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wr=C3=B3blewski?= Date: Sat, 10 Feb 2024 23:21:34 +0100 Subject: [PATCH] feat: improve class names of the data table test fixtures --- .../FooDataTableTypeBazExtension.php | 16 --------- ...hp => SimpleDataTableTypeBarExtension.php} | 6 ++-- ...hp => SimpleDataTableTypeBazExtension.php} | 6 ++-- ...aTableType.php => SimpleDataTableType.php} | 2 +- ...bleType.php => SimpleSubDataTableType.php} | 4 +-- tests/Unit/DataTableFactoryTest.php | 10 +++--- tests/Unit/DataTableRegistryTest.php | 36 +++++++++---------- 7 files changed, 32 insertions(+), 48 deletions(-) delete mode 100644 tests/Fixtures/DataTable/Extension/FooDataTableTypeBazExtension.php rename tests/Fixtures/DataTable/Extension/{FooDataTableTypeBarExtension.php => SimpleDataTableTypeBarExtension.php} (55%) rename tests/Fixtures/DataTable/Extension/{DataTableTypeFooExtension.php => SimpleDataTableTypeBazExtension.php} (55%) rename tests/Fixtures/DataTable/Type/{FooDataTableType.php => SimpleDataTableType.php} (75%) rename tests/Fixtures/DataTable/Type/{BarDataTableType.php => SimpleSubDataTableType.php} (68%) diff --git a/tests/Fixtures/DataTable/Extension/FooDataTableTypeBazExtension.php b/tests/Fixtures/DataTable/Extension/FooDataTableTypeBazExtension.php deleted file mode 100644 index 57ca23f4..00000000 --- a/tests/Fixtures/DataTable/Extension/FooDataTableTypeBazExtension.php +++ /dev/null @@ -1,16 +0,0 @@ -createFactory()->createBuilder(FooDataTableType::class); + $builder = $this->createFactory()->createBuilder(SimpleDataTableType::class); - $this->assertSame('foo', $builder->getName()); + $this->assertSame('simple', $builder->getName()); } public function testCreate() @@ -94,7 +94,7 @@ private function createFactory(array $proxyQueryFactories = []): DataTableFactor $registry = new DataTableRegistry( types: [ new DataTableType(), - new FooDataTableType(), + new SimpleDataTableType(), new ConfigurableDataTableType(), ], typeExtensions: [], @@ -104,4 +104,4 @@ private function createFactory(array $proxyQueryFactories = []): DataTableFactor return new DataTableFactory($registry); } -} \ No newline at end of file +} diff --git a/tests/Unit/DataTableRegistryTest.php b/tests/Unit/DataTableRegistryTest.php index b071eaf8..486e0c03 100644 --- a/tests/Unit/DataTableRegistryTest.php +++ b/tests/Unit/DataTableRegistryTest.php @@ -8,13 +8,13 @@ use Kreyu\Bundle\DataTableBundle\Exception\InvalidArgumentException; use Kreyu\Bundle\DataTableBundle\Exception\LogicException; use Kreyu\Bundle\DataTableBundle\Exception\UnexpectedTypeException; -use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Extension\FooDataTableTypeBarExtension; -use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Extension\FooDataTableTypeBazExtension; +use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Extension\SimpleDataTableTypeBarExtension; +use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Extension\SimpleDataTableTypeBazExtension; use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Query\BarProxyQueryFactory; use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Query\FooProxyQueryFactory; -use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\BarDataTableType; +use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\SimpleSubDataTableType; use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\DataTableTypeWithSameParentType; -use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\FooDataTableType; +use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\SimpleDataTableType; use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\RecursiveDataTableTypeBar; use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\RecursiveDataTableTypeBaz; use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\RecursiveDataTableTypeFoo; @@ -26,9 +26,9 @@ class DataTableRegistryTest extends TestCase { public function testGetType() { - $resolvedType = $this->createRegistry()->getType(FooDataTableType::class); + $resolvedType = $this->createRegistry()->getType(SimpleDataTableType::class); - $this->assertInstanceOf(FooDataTableType::class, $resolvedType->getInnerType()); + $this->assertInstanceOf(SimpleDataTableType::class, $resolvedType->getInnerType()); } public function testGetTypeWithNonExistentType() @@ -42,31 +42,31 @@ public function testGetTypeWithNonExistentType() public function testGetTypeWithTypeExtensions() { $typeExtensions = [ - new FooDataTableTypeBarExtension(), - new FooDataTableTypeBazExtension(), + new SimpleDataTableTypeBarExtension(), + new SimpleDataTableTypeBazExtension(), ]; - $resolvedType = $this->createRegistry(typeExtensions: $typeExtensions)->getType(FooDataTableType::class); + $resolvedType = $this->createRegistry(typeExtensions: $typeExtensions)->getType(SimpleDataTableType::class); $this->assertSame($typeExtensions, $resolvedType->getTypeExtensions()); } public function testGetTypeWithParent() { - $resolvedType = $this->createRegistry()->getType(BarDataTableType::class); + $resolvedType = $this->createRegistry()->getType(SimpleSubDataTableType::class); - $this->assertInstanceOf(BarDataTableType::class, $resolvedType->getInnerType()); - $this->assertInstanceOf(FooDataTableType::class, $resolvedType->getParent()->getInnerType()); + $this->assertInstanceOf(SimpleSubDataTableType::class, $resolvedType->getInnerType()); + $this->assertInstanceOf(SimpleDataTableType::class, $resolvedType->getParent()->getInnerType()); } public function testGetTypeWithParentTypeExtensions() { $typeExtensions = [ - new FooDataTableTypeBarExtension(), - new FooDataTableTypeBazExtension(), + new SimpleDataTableTypeBarExtension(), + new SimpleDataTableTypeBazExtension(), ]; - $resolvedType = $this->createRegistry(typeExtensions: $typeExtensions)->getType(BarDataTableType::class); + $resolvedType = $this->createRegistry(typeExtensions: $typeExtensions)->getType(SimpleSubDataTableType::class); $this->assertEmpty($resolvedType->getTypeExtensions()); $this->assertSame($typeExtensions, $resolvedType->getParent()->getTypeExtensions()); @@ -97,7 +97,7 @@ public function testRecursiveTypeReferences() public function testHasType() { - $this->assertTrue($this->createRegistry()->hasType(FooDataTableType::class)); + $this->assertTrue($this->createRegistry()->hasType(SimpleDataTableType::class)); } public function testHasTypeWithNonExistentType() @@ -141,8 +141,8 @@ private function createRegistry(array $types = [], array $typeExtensions = [], a return new DataTableRegistry( types: $types ?: [ new DataTableType(), - new FooDataTableType(), - new BarDataTableType(), + new SimpleDataTableType(), + new SimpleSubDataTableType(), ], typeExtensions: $typeExtensions, proxyQueryFactories: $proxyQueryFactories,