Skip to content

Commit

Permalink
Prepare for PHPUnit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed May 25, 2024
1 parent 03c0b7a commit 88eaac8
Show file tree
Hide file tree
Showing 28 changed files with 68 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Flow\ETL\Adapter\GoogleSheet\Columns;
use Flow\ETL\Exception\InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class ColumnsTest extends TestCase
Expand Down Expand Up @@ -46,9 +47,7 @@ public static function invalid_cases() : \Generator
];
}

/**
* @dataProvider invalid_cases
*/
#[DataProvider('invalid_cases')]
public function test_assertions(string $sheetName, string $startColumn, string $endColumn, string $expectedExceptionMessage) : void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Flow\ETL\Adapter\GoogleSheet\{Columns, SheetRange};
use Flow\ETL\Exception\InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class SheetRangeTest extends TestCase
Expand Down Expand Up @@ -46,9 +47,7 @@ public static function invalid_cases() : \Generator
];
}

/**
* @dataProvider invalid_cases
*/
#[DataProvider('invalid_cases')]
public function test_assertions(int $startRow, int $endRow, string $expectedExceptionMessage) : void
{
$this->expectExceptionMessage($expectedExceptionMessage);
Expand All @@ -64,9 +63,7 @@ public function test_next_rows_range() : void
self::assertSame('Sheet2!A21:B40', $range->nextRows(10)->nextRows(20)->toString());
}

/**
* @dataProvider example_string_ranges
*/
#[DataProvider('example_string_ranges')]
public function test_range_to_string(SheetRange $range, string $expectedStringRange) : void
{
self::assertSame($expectedStringRange, $range->toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Flow\ETL\Adapter\Http\RequestEntriesFactory;
use Flow\ETL\Row\Entry\{JsonEntry, StringEntry};
use Nyholm\Psr7\Factory\Psr17Factory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;

Expand Down Expand Up @@ -44,9 +45,7 @@ public static function requests() : \Generator
];
}

/**
* @dataProvider requests
*/
#[DataProvider('requests')]
public function test_uses_expected_entry_for_request_body(string $expectedRequestBodyEntryClass, RequestInterface $request) : void
{
$entryFactory = new RequestEntriesFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ArrayComparison\Tests\Unit;

use Flow\ArrayComparison\ArrayComparison;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class ArrayComparisonTest extends TestCase
Expand Down Expand Up @@ -143,17 +144,13 @@ public function test_compare_arrays() : void
);
}

/**
* @dataProvider equal_arrays
*/
#[DataProvider('equal_arrays')]
public function test_equals(array $a, array $b) : void
{
self::assertTrue((new ArrayComparison())->equals($a, $b));
}

/**
* @dataProvider not_equal_arrays
*/
#[DataProvider('not_equal_arrays')]
public function test_not_equals(array $a, array $b) : void
{
self::assertFalse((new ArrayComparison())->equals($a, $b));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ArrayComparison\Tests\Unit;

use Flow\ArrayComparison\ArraySortByKey;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class ArraySortByKeyTest extends TestCase
Expand Down Expand Up @@ -109,9 +110,7 @@ public function arrays() : \Generator
];
}

/**
* @dataProvider arrays
*/
#[DataProvider('arrays')]
public function test_sorts_array_by_key(array $origin, array $sorted) : void
{
// serialize to JSON to be sure that array is sorted exactly as expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Integration\Filesystem;

use Flow\ETL\Filesystem\Path;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class RealpathTest extends TestCase
Expand All @@ -17,9 +18,7 @@ public static function double_dots_paths() : \Generator
yield ['/path/more/nested/..//../file.txt', '/path/file.txt'];
}

/**
* @dataProvider double_dots_paths
*/
#[DataProvider('double_dots_paths')]
public function test_double_dots_in_path(string $relative, string $absolute) : void
{
self::assertEquals(new Path($absolute), Path::realpath($relative));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use function Flow\ETL\DSL\{from_array, ref, to_memory};
use Flow\ETL\Flow;
use Flow\ETL\Memory\ArrayMemory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class HashTest extends TestCase
Expand All @@ -18,9 +19,7 @@ public static function provideValues() : \Generator
yield 'string' => ['value', 'd7ab8cce59abd5050d59506fb013961a'];
}

/**
* @dataProvider provideValues
*/
#[DataProvider('provideValues')]
public function test_hash_on_given_value(mixed $value, string $expected) : void
{
(new Flow())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use function Flow\ETL\DSL\datetime_entry;
use Flow\ETL\Formatter\ASCII\ASCIIValue;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class ASCIIValueTest extends TestCase
Expand All @@ -29,9 +30,7 @@ public static function values_without_truncating() : \Generator
yield [['a' => 1, 'b' => 2, 'c' => ['test']], '{"a":1,"b":2,"c":["test"]}'];
}

/**
* @dataProvider values_without_truncating
*/
#[DataProvider('values_without_truncating')]
public function test_converting_value_to_ascii_value(mixed $value, string $asciiValue) : void
{
self::assertSame(
Expand All @@ -40,9 +39,7 @@ public function test_converting_value_to_ascii_value(mixed $value, string $ascii
);
}

/**
* @dataProvider values_with_truncating
*/
#[DataProvider('values_with_truncating')]
public function test_converting_value_to_ascii_value_with_truncating(mixed $value, string $asciiValue) : void
{
self::assertSame(
Expand Down
5 changes: 2 additions & 3 deletions src/core/etl/tests/Flow/ETL/Tests/Unit/Function/CastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Flow\ETL\PHP\Value\Uuid;
use Flow\ETL\Row;
use Flow\ETL\Row\Factory\NativeEntryFactory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class CastTest extends TestCase
Expand Down Expand Up @@ -48,9 +49,7 @@ public static function cast_provider() : array
];
}

/**
* @dataProvider cast_provider
*/
#[DataProvider('cast_provider')]
public function test_cast(mixed $from, string $to, mixed $expected) : void
{
$resultRefCast = ref('value')->cast($to)->eval(Row::create((new NativeEntryFactory())->create('value', $from)));
Expand Down
9 changes: 3 additions & 6 deletions src/core/etl/tests/Flow/ETL/Tests/Unit/PartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Flow\ETL\Exception\InvalidArgumentException;
use Flow\ETL\Partition;
use Flow\ETL\Row\Entry\XMLEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class PartitionTest extends TestCase
Expand Down Expand Up @@ -84,19 +85,15 @@ public function test_creating_partitions_from_uri_without_partitions() : void
self::assertCount(0, $partitions);
}

/**
* @dataProvider provider_forbidden_characters_values
*/
#[DataProvider('provider_forbidden_characters_values')]
public function test_forbidden_names(string $value) : void
{
$this->expectException(InvalidArgumentException::class);

new Partition($value, 'value');
}

/**
* @dataProvider provider_forbidden_characters_values
*/
#[DataProvider('provider_forbidden_characters_values')]
public function test_forbidden_values(string $value) : void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Unit\Row\Entry;

use Flow\ETL\Row\Entry\{ArrayEntry, IntegerEntry};
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class ArrayEntryTest extends TestCase
Expand Down Expand Up @@ -83,9 +84,7 @@ public function test_entry_name_can_be_zero() : void
self::assertSame('0', (new ArrayEntry('0', ['id' => 1]))->name());
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, ArrayEntry $entry, ArrayEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Unit\Row\Entry;

use Flow\ETL\Row\Entry\BooleanEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class BooleanEntryTest extends TestCase
Expand All @@ -22,9 +23,7 @@ public function test_entry_name_can_be_zero() : void
self::assertSame('0', (new BooleanEntry('0', true))->name());
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, BooleanEntry $entry, BooleanEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Flow\ETL\Exception\InvalidArgumentException;
use Flow\ETL\Row\Entry\DateTimeEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class DateTimeEntryTest extends TestCase
Expand Down Expand Up @@ -35,9 +36,7 @@ public function test_invalid_date() : void
new DateTimeEntry('a', 'random string');
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, DateTimeEntry $entry, DateTimeEntry $nextEntry) : void
{
self::assertEquals($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Unit\Row\Entry;

use Flow\ETL\Row\Entry\FloatEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class FloatEntryTest extends TestCase
Expand All @@ -24,9 +25,7 @@ public function test_entry_name_can_be_zero() : void
self::assertSame('0', (new FloatEntry('0', 0))->name());
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, FloatEntry $entry, FloatEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Unit\Row\Entry;

use Flow\ETL\Row\Entry\IntegerEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class IntegerEntryTest extends TestCase
Expand All @@ -22,9 +23,7 @@ public function test_entry_name_can_be_zero() : void
self::assertSame('0', (new IntegerEntry('0', 0))->name());
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, IntegerEntry $entry, IntegerEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Flow\ETL\Exception\InvalidArgumentException;
use Flow\ETL\Row\Entry\{IntegerEntry, JsonEntry};
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class JsonEntryTest extends TestCase
Expand Down Expand Up @@ -101,9 +102,7 @@ public function test_invalid_json() : void
new JsonEntry('a', 'random string');
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, JsonEntry $entry, JsonEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Unit\Row\Entry;

use Flow\ETL\Row\Entry\{IntegerEntry, JsonEntry};
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class JsonObjectEntryTest extends TestCase
Expand Down Expand Up @@ -53,9 +54,7 @@ public static function is_equal_data_provider() : \Generator
];
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, JsonEntry $entry, JsonEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Flow\ETL\Tests\Unit\Row\Entry;

use Flow\ETL\Row\Entry\ObjectEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class ObjectEntryTest extends TestCase
Expand All @@ -22,9 +23,7 @@ public function test_entry_name_can_be_zero() : void
self::assertSame('0', (new ObjectEntry('0', new \stdClass()))->name());
}

/**
* @dataProvider is_equal_data_provider
*/
#[DataProvider('is_equal_data_provider')]
public function test_is_equal(bool $equals, ObjectEntry $entry, ObjectEntry $nextEntry) : void
{
self::assertSame($equals, $entry->isEqual($nextEntry));
Expand Down
Loading

0 comments on commit 88eaac8

Please sign in to comment.