Skip to content

Commit

Permalink
Move fixtures to trait (#193)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Predvoditelev <[email protected]>
  • Loading branch information
arogachev and vjik authored Sep 25, 2024
1 parent 01c7bc5 commit 41f2c3a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

declare(strict_types=1);

namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;
namespace Yiisoft\Data\Tests\Common;

use Yiisoft\Data\Reader\DataReaderInterface;
use Yiisoft\Data\Tests\TestCase;

abstract class BaseReaderWithFilterTestCase extends TestCase
trait FixtureTrait
{
protected static $fixtures = [
['number' => 1, 'email' => 'foo@bar', 'balance' => 10.25, 'born_at' => null],
Expand All @@ -17,8 +14,6 @@ abstract class BaseReaderWithFilterTestCase extends TestCase
['number' => 5, 'email' => 'test@test', 'balance' => 42.0, 'born_at' => '1990-01-01'],
];

abstract protected function getReader(): DataReaderInterface;

protected function assertFixtures(array $expectedFixtureIndexes, array $actualFixtures): void
{
$expectedFixtures = [];
Expand Down
16 changes: 16 additions & 0 deletions tests/Common/Reader/BaseReaderTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Data\Tests\Common\Reader;

use Yiisoft\Data\Reader\DataReaderInterface;
use Yiisoft\Data\Tests\Common\FixtureTrait;
use Yiisoft\Data\Tests\TestCase;

abstract class BaseReaderTestCase extends TestCase
{
use FixtureTrait;

abstract protected function getReader(): DataReaderInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

use Yiisoft\Data\Reader\Filter\All;
use Yiisoft\Data\Reader\Filter\Equals;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithAllTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithAllTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
use Yiisoft\Data\Reader\Filter\GreaterThan;
use Yiisoft\Data\Reader\Filter\LessThan;
use Yiisoft\Data\Reader\Filter\Like;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithAnyTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithAnyTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\Between;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithBetweenTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithBetweenTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\EqualsNull;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithEqualsNullTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithEqualsNullTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\Equals;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithEqualsTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithEqualsTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\GreaterThanOrEqual;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithGreaterThanOrEqualTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithGreaterThanOrEqualTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\GreaterThan;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithGreaterThanTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithGreaterThanTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\In;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithInTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithInTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\LessThanOrEqual;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithLessThanOrEqualTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithLessThanOrEqualTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter;

use Yiisoft\Data\Reader\Filter\LessThan;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithLessThanTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithLessThanTestCase extends BaseReaderTestCase
{
public function testWithReader(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

use PHPUnit\Framework\Attributes\DataProvider;
use Yiisoft\Data\Reader\Filter\Like;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithLikeTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithLikeTestCase extends BaseReaderTestCase
{
public static function dataWithReader(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
use Yiisoft\Data\Reader\Filter\LessThanOrEqual;
use Yiisoft\Data\Reader\Filter\Like;
use Yiisoft\Data\Reader\Filter\Not;
use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase;

abstract class BaseReaderWithNotTestCase extends BaseReaderWithFilterTestCase
abstract class BaseReaderWithNotTestCase extends BaseReaderTestCase
{
public static function dataWithReader(): array
{
Expand Down

0 comments on commit 41f2c3a

Please sign in to comment.