Skip to content

Commit

Permalink
feat: improve class names of the data table test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreyu committed Feb 10, 2024
1 parent ca155c0 commit 5058deb
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 48 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Extension;

use Kreyu\Bundle\DataTableBundle\Extension\AbstractDataTableTypeExtension;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\FooDataTableType;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\SimpleDataTableType;

class FooDataTableTypeBarExtension extends AbstractDataTableTypeExtension
class SimpleDataTableTypeBarExtension extends AbstractDataTableTypeExtension
{
public static function getExtendedTypes(): iterable
{
yield FooDataTableType::class;
yield SimpleDataTableType::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Extension;

use Kreyu\Bundle\DataTableBundle\Extension\AbstractDataTableTypeExtension;
use Kreyu\Bundle\DataTableBundle\Type\DataTableType;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\SimpleDataTableType;

class DataTableTypeFooExtension extends AbstractDataTableTypeExtension
class SimpleDataTableTypeBazExtension extends AbstractDataTableTypeExtension
{
public static function getExtendedTypes(): iterable
{
yield DataTableType::class;
yield SimpleDataTableType::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

use Kreyu\Bundle\DataTableBundle\Type\AbstractDataTableType;

class FooDataTableType extends AbstractDataTableType
class SimpleDataTableType extends AbstractDataTableType
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use Kreyu\Bundle\DataTableBundle\Type\AbstractDataTableType;

class BarDataTableType extends AbstractDataTableType
class SimpleSubDataTableType extends AbstractDataTableType
{
public function getParent(): string
{
return FooDataTableType::class;
return SimpleDataTableType::class;
}
}
10 changes: 5 additions & 5 deletions tests/Unit/DataTableFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Query\CustomProxyQuery;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Query\CustomProxyQueryFactory;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\ConfigurableDataTableType;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\FooDataTableType;
use Kreyu\Bundle\DataTableBundle\Tests\Fixtures\DataTable\Type\SimpleDataTableType;
use Kreyu\Bundle\DataTableBundle\Type\DataTableType;
use Kreyu\Bundle\DataTableBundle\Type\ResolvedDataTableTypeFactory;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -49,9 +49,9 @@ public function testCreateNamedBuilderWithProxyQueryData()

public function testCreateBuilderUsesDataTableName()
{
$builder = $this->createFactory()->createBuilder(FooDataTableType::class);
$builder = $this->createFactory()->createBuilder(SimpleDataTableType::class);

$this->assertSame('foo', $builder->getName());
$this->assertSame('simple', $builder->getName());
}

public function testCreate()
Expand Down Expand Up @@ -94,7 +94,7 @@ private function createFactory(array $proxyQueryFactories = []): DataTableFactor
$registry = new DataTableRegistry(
types: [
new DataTableType(),
new FooDataTableType(),
new SimpleDataTableType(),
new ConfigurableDataTableType(),
],
typeExtensions: [],
Expand All @@ -104,4 +104,4 @@ private function createFactory(array $proxyQueryFactories = []): DataTableFactor

return new DataTableFactory($registry);
}
}
}
36 changes: 18 additions & 18 deletions tests/Unit/DataTableRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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());
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5058deb

Please sign in to comment.