From 12357ba4b120ecb1b1118f6f9054c3c6ddc530ab Mon Sep 17 00:00:00 2001 From: Aggelos Bellos Date: Sun, 29 Dec 2024 05:19:13 +0200 Subject: [PATCH] Extractor test helper (#1291) * Unify how we generate an array from Extractors * Use the new test case * Clean-up files * Add methods for modifying and asserting rows * Use the new methods * Add method for multi-row counting * Use the methods in the rest of the files * Import function * Leave this class pure to test the implementation * Import of build-in function is forbidden * Convert helper function to an assertion * Remove unused method * Convert helper method to an assertion * Fix code style * Follow the naming conventions of PHPUnit * Use a more descriptive name * Split logic into 2 methods * Rename test case and fix code style issues * Revert "Rename test case and fix code style issues" This reverts commit 43a88c87d6f9b550205f14ff793e9815ba99ff9a. * Rename test case * Fix code style * Improve assertion naming * Assert by flatten first the rows * Use the same implementation * Allow to override default flow context * Allow to override default error message * Make methods static and final as PHPUnit does * Move class into the ETL root * Integration should extend the base FlowTestCase * Use DSL functions instead of objects * Use self instead of directly accessing the FlowTestCase --------- Co-authored-by: Norbert Orzechowicz <1921950+norberttech@users.noreply.github.com> --- .../Integration/Loader/XMLLoaderTest.php | 4 +- .../Integration/XMLParserExtractorTest.php | 4 +- .../Integration/XMLReaderExtractorTest.php | 4 +- .../Adapter/XML/Tests/Integration/XMLTest.php | 4 +- .../Tests/Integration/AsyncAWSS3TestCase.php | 4 +- .../etl/tests/Flow/ETL/Tests/FlowTestCase.php | 94 +++++++++++++++++++ .../Integration/Cache/CacheBaseTestSuite.php | 4 +- .../Integration/DataFrame/AnalyzeTest.php | 4 +- .../Integration/DataFrame/BranchingTest.php | 4 +- .../Tests/Integration/DataFrame/CacheTest.php | 4 +- .../DataFrame/ConfigBuilderTest.php | 4 +- .../DataFrame/DataFrameJsonTest.php | 4 +- .../Integration/DataFrame/DisplayTest.php | 4 +- .../Integration/DataFrame/FilterTest.php | 4 +- .../Integration/DataFrame/GroupByTest.php | 4 +- .../Tests/Integration/DataFrame/JoinTest.php | 4 +- .../Tests/Integration/DataFrame/LimitTest.php | 4 +- .../Tests/Integration/DataFrame/MapTest.php | 4 +- .../DataFrame/PartitioningTest.php | 4 +- .../Integration/DataFrame/RenameTest.php | 4 +- .../Integration/DataFrame/SchemaTest.php | 4 +- .../Tests/Integration/DataFrame/SortTest.php | 4 +- .../Extractor/CacheExtractorTest.php | 4 +- .../Extractor/PathPartitionsExtractorTest.php | 4 +- .../FilesystemStreamsTestCase.php | 4 +- ...stCase.php => FlowIntegrationTestCase.php} | 5 +- .../Monitoring/Memory/ConfigurationTest.php | 4 +- .../Pipeline/SynchronousPipelineTest.php | 4 +- .../Sort/ExternalSort/ExternalSortTest.php | 4 +- .../Unit/Extractor/ChainExtractorTest.php | 21 ++--- .../Unit/Extractor/ChunkExtractorTest.php | 13 ++- .../Unit/Extractor/DataFrameExtractorTest.php | 35 +++---- .../Unit/Extractor/FilesExtractorTest.php | 34 ++----- .../Unit/Extractor/MemoryExtractorTest.php | 15 +-- .../Unit/Extractor/PipelineExtractorTest.php | 10 +- .../Unit/Extractor/RowsExtractorTest.php | 15 +-- .../Unit/Extractor/SequenceExtractorTest.php | 81 ++++++++-------- 37 files changed, 240 insertions(+), 191 deletions(-) create mode 100644 src/core/etl/tests/Flow/ETL/Tests/FlowTestCase.php rename src/core/etl/tests/Flow/ETL/Tests/Integration/{IntegrationTestCase.php => FlowIntegrationTestCase.php} (96%) diff --git a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/Loader/XMLLoaderTest.php b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/Loader/XMLLoaderTest.php index 85cfb016a..8019f86ae 100644 --- a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/Loader/XMLLoaderTest.php +++ b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/Loader/XMLLoaderTest.php @@ -7,9 +7,9 @@ use function Flow\ETL\Adapter\XML\{from_xml, to_xml}; use function Flow\ETL\DSL\{df, from_array, overwrite, ref}; use Flow\ETL\Tests\Double\FakeExtractor; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class XMLLoaderTest extends IntegrationTestCase +final class XMLLoaderTest extends FlowIntegrationTestCase { public function test_partitioning_xml_file() : void { diff --git a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLParserExtractorTest.php b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLParserExtractorTest.php index d7d54abe6..b46b2b8eb 100644 --- a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLParserExtractorTest.php +++ b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLParserExtractorTest.php @@ -12,10 +12,10 @@ Flow, FlowContext, PHP\Type\Caster, - Tests\Integration\IntegrationTestCase}; + Tests\Integration\FlowIntegrationTestCase}; use Flow\Filesystem\Path; -final class XMLParserExtractorTest extends IntegrationTestCase +final class XMLParserExtractorTest extends FlowIntegrationTestCase { public function test_limit() : void { diff --git a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLReaderExtractorTest.php b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLReaderExtractorTest.php index 1650c0e65..c887dba23 100644 --- a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLReaderExtractorTest.php +++ b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLReaderExtractorTest.php @@ -7,10 +7,10 @@ use function Flow\ETL\DSL\type_string; use Flow\ETL\Adapter\XML\XMLReaderExtractor; use Flow\ETL\Extractor\Signal; -use Flow\ETL\{Config, Flow, FlowContext, PHP\Type\Caster, Tests\Integration\IntegrationTestCase}; +use Flow\ETL\{Config, Flow, FlowContext, PHP\Type\Caster, Tests\Integration\FlowIntegrationTestCase}; use Flow\Filesystem\Path; -final class XMLReaderExtractorTest extends IntegrationTestCase +final class XMLReaderExtractorTest extends FlowIntegrationTestCase { public function test_limit() : void { diff --git a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLTest.php b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLTest.php index 614134ba0..365c78a0d 100644 --- a/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLTest.php +++ b/src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Integration/XMLTest.php @@ -7,9 +7,9 @@ use function Flow\ETL\Adapter\XML\from_xml; use function Flow\ETL\DSL\{datetime_schema, df, int_schema, ref, schema, type_int}; use function Flow\Filesystem\DSL\path; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class XMLTest extends IntegrationTestCase +final class XMLTest extends FlowIntegrationTestCase { public function test_transforming_xml_into_a_tabular_dataset() : void { diff --git a/src/bridge/filesystem/async-aws/tests/Flow/Filesystem/Bridge/AsyncAWS/Tests/Integration/AsyncAWSS3TestCase.php b/src/bridge/filesystem/async-aws/tests/Flow/Filesystem/Bridge/AsyncAWS/Tests/Integration/AsyncAWSS3TestCase.php index 49ec53a05..4687c8b37 100644 --- a/src/bridge/filesystem/async-aws/tests/Flow/Filesystem/Bridge/AsyncAWS/Tests/Integration/AsyncAWSS3TestCase.php +++ b/src/bridge/filesystem/async-aws/tests/Flow/Filesystem/Bridge/AsyncAWS/Tests/Integration/AsyncAWSS3TestCase.php @@ -6,10 +6,10 @@ use function Flow\Filesystem\Bridge\AsyncAWS\DSL\aws_s3_client; use AsyncAws\S3\S3Client; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\Filesystem\Path; -abstract class AsyncAWSS3TestCase extends IntegrationTestCase +abstract class AsyncAWSS3TestCase extends FlowIntegrationTestCase { protected function setUp() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/FlowTestCase.php b/src/core/etl/tests/Flow/ETL/Tests/FlowTestCase.php new file mode 100644 index 000000000..b3be36be2 --- /dev/null +++ b/src/core/etl/tests/Flow/ETL/Tests/FlowTestCase.php @@ -0,0 +1,94 @@ +extract($flowContext)), + $message + ); + } + + final public static function assertExtractedBatchesSize( + int $expectedCount, + Extractor $extractor, + ?FlowContext $flowContext = null, + string $message = '', + ) : void { + $flowContext = $flowContext ?? flow_context(); + $extractorContainsBatches = false; + + foreach ($extractor->extract($flowContext) as $rows) { + static::assertCount($expectedCount, $rows, $message); + $extractorContainsBatches = true; + } + + if (!$extractorContainsBatches) { + static::fail('Extractor does not contain any batches'); + } + } + + final public static function assertExtractedRowsAsArrayEquals( + array $expectedArray, + Extractor $extractor, + ?FlowContext $flowContext = null, + string $message = '', + ) : void { + $flowContext = $flowContext ?? flow_context(); + $extractedRows = rows(); + + foreach ($extractor->extract($flowContext) as $nextRows) { + $extractedRows = $extractedRows->merge($nextRows); + } + + static::assertEquals($expectedArray, $extractedRows->toArray(), $message); + } + + final public static function assertExtractedRowsCount( + int $expectedCount, + Extractor $extractor, + ?FlowContext $flowContext = null, + string $message = '', + ) : void { + $flowContext = $flowContext ?? flow_context(); + $totalRows = 0; + + foreach ($extractor->extract($flowContext) as $rows) { + $totalRows += $rows->count(); + } + + static::assertSame($expectedCount, $totalRows, $message); + } + + final public static function assertExtractedRowsEquals( + Rows $expectedRows, + Extractor $extractor, + ?FlowContext $flowContext = null, + string $message = '', + ) : void { + $flowContext = $flowContext ?? flow_context(); + $extractedRows = rows(); + + foreach ($extractor->extract($flowContext) as $nextRows) { + $extractedRows = $extractedRows->merge($nextRows); + } + + static::assertEquals($expectedRows, $extractedRows, $message); + } +} diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Cache/CacheBaseTestSuite.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Cache/CacheBaseTestSuite.php index 919989c6a..876b27814 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Cache/CacheBaseTestSuite.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Cache/CacheBaseTestSuite.php @@ -7,9 +7,9 @@ use function Flow\ETL\DSL\{row, rows, str_entry}; use Flow\ETL\Cache\{CacheIndex}; use Flow\ETL\Exception\KeyNotInCacheException; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -abstract class CacheBaseTestSuite extends IntegrationTestCase +abstract class CacheBaseTestSuite extends FlowIntegrationTestCase { protected function setUp() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/AnalyzeTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/AnalyzeTest.php index 72d7b7848..7ef6c72d0 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/AnalyzeTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/AnalyzeTest.php @@ -6,9 +6,9 @@ use function Flow\ETL\Adapter\Text\from_text; use function Flow\ETL\DSL\{datetime_schema, df, float_schema, from_array, int_schema, schema, str_schema}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class AnalyzeTest extends IntegrationTestCase +final class AnalyzeTest extends FlowIntegrationTestCase { public function test_analyzing_csv_file_with_auto_cast() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/BranchingTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/BranchingTest.php index 85779a2e4..02138df94 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/BranchingTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/BranchingTest.php @@ -6,9 +6,9 @@ use function Flow\ETL\DSL\{df, from_array, lit, ref, to_branch, to_memory}; use Flow\ETL\Memory\ArrayMemory; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class BranchingTest extends IntegrationTestCase +final class BranchingTest extends FlowIntegrationTestCase { public function test_branching() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/CacheTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/CacheTest.php index 8e433f260..ea5069704 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/CacheTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/CacheTest.php @@ -8,10 +8,10 @@ use Flow\ETL\Cache\CacheIndex; use Flow\ETL\Cache\Implementation\InMemoryCache; use Flow\ETL\Tests\Double\FakeExtractor; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\{Extractor, FlowContext, Rows}; -final class CacheTest extends IntegrationTestCase +final class CacheTest extends FlowIntegrationTestCase { public function test_cache() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/ConfigBuilderTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/ConfigBuilderTest.php index b0c6c26a9..002fe67a5 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/ConfigBuilderTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/ConfigBuilderTest.php @@ -7,9 +7,9 @@ use function Flow\ETL\DSL\config_builder; use Flow\ETL\Config\Cache\CacheConfig; use Flow\ETL\Sort\SortAlgorithms; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class ConfigBuilderTest extends IntegrationTestCase +final class ConfigBuilderTest extends FlowIntegrationTestCase { public function test_creating_custom_cache_dir() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DataFrameJsonTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DataFrameJsonTest.php index 9c7d232d6..db937f9ab 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DataFrameJsonTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DataFrameJsonTest.php @@ -6,9 +6,9 @@ use Flow\ETL\DataFrame; use Flow\ETL\Exception\InvalidArgumentException; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class DataFrameJsonTest extends IntegrationTestCase +final class DataFrameJsonTest extends FlowIntegrationTestCase { public function test_building_data_frame_from_json() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DisplayTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DisplayTest.php index 1167d7f46..36d1df762 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DisplayTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/DisplayTest.php @@ -30,10 +30,10 @@ enum_entry, type_string, xml_entry}; use Flow\ETL\Tests\Fixtures\Enum\BackedStringEnum; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\{Extractor, FlowContext, Rows}; -final class DisplayTest extends IntegrationTestCase +final class DisplayTest extends FlowIntegrationTestCase { public function test_display() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/FilterTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/FilterTest.php index 42c9d996f..74146548b 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/FilterTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/FilterTest.php @@ -5,9 +5,9 @@ namespace Flow\ETL\Tests\Integration\DataFrame; use function Flow\ETL\DSL\{df, from_array, ref}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class FilterTest extends IntegrationTestCase +final class FilterTest extends FlowIntegrationTestCase { public function test_multiple_filters() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/GroupByTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/GroupByTest.php index d6524af70..57736ac8d 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/GroupByTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/GroupByTest.php @@ -35,10 +35,10 @@ uuid_schema, window}; use Flow\ETL\Memory\ArrayMemory; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\{Loader, Rows}; -final class GroupByTest extends IntegrationTestCase +final class GroupByTest extends FlowIntegrationTestCase { public function test_group_by_array() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/JoinTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/JoinTest.php index e8c615663..983c9dfe5 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/JoinTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/JoinTest.php @@ -6,10 +6,10 @@ use function Flow\ETL\DSL\{datetime_entry, df, from_rows, int_entry, row, rows, str_entry}; use Flow\ETL\Join\Expression; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\{Flow, Join\Join, Loader}; -final class JoinTest extends IntegrationTestCase +final class JoinTest extends FlowIntegrationTestCase { public function test_join_inner() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/LimitTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/LimitTest.php index a4a5e1d5b..79d0b644e 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/LimitTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/LimitTest.php @@ -16,10 +16,10 @@ type_structure}; use Flow\ETL\Exception\InvalidArgumentException; use Flow\ETL\Row\Entry\{IntegerEntry}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\{Extractor, FlowContext, Row, Rows}; -final class LimitTest extends IntegrationTestCase +final class LimitTest extends FlowIntegrationTestCase { public function test_exceeding_the_limit_in_one_rows_set() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/MapTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/MapTest.php index ea6209fa9..070ce1aae 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/MapTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/MapTest.php @@ -12,9 +12,9 @@ type_list, type_string}; use Flow\ETL\Row; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class MapTest extends IntegrationTestCase +final class MapTest extends FlowIntegrationTestCase { public function test_using_map_to_replace_nullable_lists() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/PartitioningTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/PartitioningTest.php index d30ca5246..1e6fa1161 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/PartitioningTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/PartitioningTest.php @@ -20,11 +20,11 @@ rows_partitioned, str_entry}; use function Flow\Filesystem\DSL\partition; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\{Rows}; use Flow\Filesystem\Partition; -final class PartitioningTest extends IntegrationTestCase +final class PartitioningTest extends FlowIntegrationTestCase { public function test_dropping_partitions() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/RenameTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/RenameTest.php index be1b61470..429372071 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/RenameTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/RenameTest.php @@ -5,11 +5,11 @@ namespace Flow\ETL\Tests\Integration\DataFrame; use function Flow\ETL\DSL\{bool_entry, df, from_rows, int_entry, json_entry, ref, str_entry}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\ETL\Transformer\StyleConverter\StringStyles; use Flow\ETL\{Row, Rows}; -final class RenameTest extends IntegrationTestCase +final class RenameTest extends FlowIntegrationTestCase { public function test_rename() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SchemaTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SchemaTest.php index c4c276874..125d0e4de 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SchemaTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SchemaTest.php @@ -23,9 +23,9 @@ string_entry}; use Flow\ETL\Pipeline\SynchronousPipeline; use Flow\ETL\Row\Schema; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class SchemaTest extends IntegrationTestCase +final class SchemaTest extends FlowIntegrationTestCase { public function test_extraction_according_to_schema() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SortTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SortTest.php index 0a579e60a..700ebc7ef 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SortTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/SortTest.php @@ -8,9 +8,9 @@ use Flow\ETL\Config; use Flow\ETL\Monitoring\Memory\Unit; use Flow\ETL\Tests\Double\{FakeExtractor}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class SortTest extends IntegrationTestCase +final class SortTest extends FlowIntegrationTestCase { public function test_etl_sort_by_external_sort() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/CacheExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/CacheExtractorTest.php index 7ca0a13ff..3666b64cd 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/CacheExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/CacheExtractorTest.php @@ -8,9 +8,9 @@ use Flow\ETL\Cache\CacheIndex; use Flow\ETL\Cache\Implementation\InMemoryCache; use Flow\ETL\Extractor\CacheExtractor; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class CacheExtractorTest extends IntegrationTestCase +final class CacheExtractorTest extends FlowIntegrationTestCase { public function test_extracting_rows_from_cache() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/PathPartitionsExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/PathPartitionsExtractorTest.php index 3e9815678..d7a64fcbf 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/PathPartitionsExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Extractor/PathPartitionsExtractorTest.php @@ -5,10 +5,10 @@ namespace Flow\ETL\Tests\Integration\Extractor; use function Flow\ETL\DSL\{flow_context, from_path_partitions, rows}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\Filesystem\Path; -final class PathPartitionsExtractorTest extends IntegrationTestCase +final class PathPartitionsExtractorTest extends FlowIntegrationTestCase { public function test_extracting_data_from_path_partitions() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Filesystem/FilesystemStreams/FilesystemStreamsTestCase.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Filesystem/FilesystemStreams/FilesystemStreamsTestCase.php index 474fc50d3..1ad874c75 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Filesystem/FilesystemStreams/FilesystemStreamsTestCase.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Filesystem/FilesystemStreams/FilesystemStreamsTestCase.php @@ -5,9 +5,9 @@ namespace Flow\ETL\Tests\Integration\Filesystem\FilesystemStreams; use Flow\ETL\Filesystem\FilesystemStreams; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -abstract class FilesystemStreamsTestCase extends IntegrationTestCase +abstract class FilesystemStreamsTestCase extends FlowIntegrationTestCase { protected function filesDirectory() : string { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/IntegrationTestCase.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/FlowIntegrationTestCase.php similarity index 96% rename from src/core/etl/tests/Flow/ETL/Tests/Integration/IntegrationTestCase.php rename to src/core/etl/tests/Flow/ETL/Tests/Integration/FlowIntegrationTestCase.php index 47a01e47f..d880385e3 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/IntegrationTestCase.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/FlowIntegrationTestCase.php @@ -4,13 +4,12 @@ namespace Flow\ETL\Tests\Integration; -use Flow\ETL\{Config\Cache\CacheConfig}; +use Flow\ETL\{Config\Cache\CacheConfig, Tests\FlowTestCase}; use Flow\Filesystem\{Filesystem, Path}; use Flow\Filesystem\{FilesystemTable, Local\NativeLocalFilesystem, Local\StdOutFilesystem}; use Flow\Serializer\{Base64Serializer, NativePHPSerializer, Serializer}; -use PHPUnit\Framework\TestCase; -abstract class IntegrationTestCase extends TestCase +abstract class FlowIntegrationTestCase extends FlowTestCase { protected Path $cacheDir; diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Monitoring/Memory/ConfigurationTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Monitoring/Memory/ConfigurationTest.php index fc8c839d9..b12c5820c 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Monitoring/Memory/ConfigurationTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Monitoring/Memory/ConfigurationTest.php @@ -5,9 +5,9 @@ namespace Flow\ETL\Tests\Integration\Monitoring\Memory; use Flow\ETL\Monitoring\Memory\{Configuration, Unit}; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class ConfigurationTest extends IntegrationTestCase +final class ConfigurationTest extends FlowIntegrationTestCase { public function test_less_than_for_infinite_memory() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Pipeline/SynchronousPipelineTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Pipeline/SynchronousPipelineTest.php index b84ed18cc..8aebfdfdc 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Pipeline/SynchronousPipelineTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Pipeline/SynchronousPipelineTest.php @@ -7,9 +7,9 @@ use function Flow\ETL\Adapter\CSV\{from_csv, to_csv}; use function Flow\ETL\DSL\{df, from_array, lit}; use Flow\ETL\Loader; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; -final class SynchronousPipelineTest extends IntegrationTestCase +final class SynchronousPipelineTest extends FlowIntegrationTestCase { protected function setUp() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Sort/ExternalSort/ExternalSortTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Sort/ExternalSort/ExternalSortTest.php index 501c08526..15fd5b337 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Sort/ExternalSort/ExternalSortTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Sort/ExternalSort/ExternalSortTest.php @@ -8,10 +8,10 @@ use Flow\ETL\Pipeline\{SynchronousPipeline}; use Flow\ETL\Sort\ExternalSort; use Flow\ETL\Sort\ExternalSort\BucketsCache\FilesystemBucketsCache; -use Flow\ETL\Tests\Integration\IntegrationTestCase; +use Flow\ETL\Tests\Integration\FlowIntegrationTestCase; use Flow\Filesystem\Path; -final class ExternalSortTest extends IntegrationTestCase +final class ExternalSortTest extends FlowIntegrationTestCase { public function test_memory_implementation_of_external_sort_algorithm() : void { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChainExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChainExtractorTest.php index a66a34372..4cda94fa1 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChainExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChainExtractorTest.php @@ -5,10 +5,9 @@ namespace Flow\ETL\Tests\Unit\Extractor; use function Flow\ETL\DSL\{from_all, int_entry}; -use Flow\ETL\{Config, Extractor, FlowContext, Row, Rows}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\{Extractor, FlowContext, Row, Rows, Tests\FlowTestCase}; -final class ChainExtractorTest extends TestCase +final class ChainExtractorTest extends FlowTestCase { public function test_chain_extractor() : void { @@ -29,14 +28,14 @@ public function extract(FlowContext $context) : \Generator }, ); - self::assertEquals( - [ - new Rows(Row::create(int_entry('id', 1))), - new Rows(Row::create(int_entry('id', 2))), - new Rows(Row::create(int_entry('id', 3))), - new Rows(Row::create(int_entry('id', 4))), - ], - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) + self::assertExtractedRowsEquals( + new Rows( + Row::create(int_entry('id', 1)), + Row::create(int_entry('id', 2)), + Row::create(int_entry('id', 3)), + Row::create(int_entry('id', 4)), + ), + $extractor ); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChunkExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChunkExtractorTest.php index b3149b6fe..b12a271f9 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChunkExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/ChunkExtractorTest.php @@ -6,18 +6,17 @@ use Flow\ETL\Extractor\ChunkExtractor; use Flow\ETL\Tests\Double\FakeExtractor; -use Flow\ETL\{Config, FlowContext}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\Tests\FlowTestCase; -final class ChunkExtractorTest extends TestCase +final class ChunkExtractorTest extends FlowTestCase { public function test_chunk_extractor() : void { $extractor = new ChunkExtractor(new FakeExtractor($batches = 100), $chunkSize = 10); - self::assertCount( + self::assertExtractedBatchesCount( $batches / $chunkSize, - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) + $extractor ); } @@ -25,9 +24,9 @@ public function test_chunk_extractor_with_chunk_size_greater_than_() : void { $extractor = new ChunkExtractor(new FakeExtractor(total: 20), chunkSize: 25); - self::assertCount( + self::assertExtractedBatchesCount( 1, - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) + $extractor ); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/DataFrameExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/DataFrameExtractorTest.php index 1692aedcc..18bb2829f 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/DataFrameExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/DataFrameExtractorTest.php @@ -5,15 +5,14 @@ namespace Flow\ETL\Tests\Unit\Extractor; use function Flow\ETL\DSL\{df, from_data_frame, from_rows, row, rows, str_entry}; -use Flow\ETL\{Config, FlowContext}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\Tests\FlowTestCase; -final class DataFrameExtractorTest extends TestCase +final class DataFrameExtractorTest extends FlowTestCase { public function test_extracting_from_another_data_frame() : void { - self::assertEquals( - [ + $extractor = from_data_frame( + df()->read(from_rows( rows( row(str_entry('value', 'test')), row(str_entry('value', 'test')), @@ -21,22 +20,18 @@ public function test_extracting_from_another_data_frame() : void rows( row(str_entry('value', 'test')), row(str_entry('value', 'test')), - ), - ], - \iterator_to_array( - from_data_frame( - df()->read(from_rows( - rows( - row(str_entry('value', 'test')), - row(str_entry('value', 'test')), - ), - rows( - row(str_entry('value', 'test')), - row(str_entry('value', 'test')), - ) - )), - )->extract(new FlowContext(Config::default())) + ) + )) + ); + + self::assertExtractedRowsEquals( + rows( + row(str_entry('value', 'test')), + row(str_entry('value', 'test')), + row(str_entry('value', 'test')), + row(str_entry('value', 'test')), ), + $extractor ); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/FilesExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/FilesExtractorTest.php index 1bd1b651b..00397c93f 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/FilesExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/FilesExtractorTest.php @@ -6,22 +6,16 @@ use function Flow\ETL\DSL\{files, flow_context}; use Flow\ETL\Extractor\Signal; -use PHPUnit\Framework\TestCase; +use Flow\ETL\Tests\FlowTestCase; -final class FilesExtractorTest extends TestCase +final class FilesExtractorTest extends FlowTestCase { public function test_extracting_files_from_directory() : void { $extractor = files(__DIR__ . '/Fixtures/FileListExtractor/*'); - $totalRows = 0; - - foreach ($extractor->extract(flow_context()) as $rows) { - self::assertCount(1, $rows); - $totalRows += $rows->count(); - } - - self::assertEquals(3, $totalRows); + self::assertExtractedRowsCount(3, $extractor); + self::assertExtractedBatchesSize(1, $extractor); } public function test_extracting_files_from_directory_after_getting_stop_signal() : void @@ -43,14 +37,8 @@ public function test_extracting_files_from_directory_recursive() : void { $extractor = files(__DIR__ . '/Fixtures/FileListExtractor/**/*'); - $totalRows = 0; - - foreach ($extractor->extract(flow_context()) as $rows) { - self::assertCount(1, $rows); - $totalRows += $rows->count(); - } - - self::assertEquals(6, $totalRows); + self::assertExtractedRowsCount(6, $extractor); + self::assertExtractedBatchesSize(1, $extractor); } public function test_extracting_files_from_directory_with_limit() : void @@ -58,13 +46,7 @@ public function test_extracting_files_from_directory_with_limit() : void $extractor = files(__DIR__ . '/Fixtures/FileListExtractor/**/*'); $extractor->changeLimit(2); - $totalRows = 0; - - foreach ($extractor->extract(flow_context()) as $rows) { - self::assertCount(1, $rows); - $totalRows += $rows->count(); - } - - self::assertEquals(2, $totalRows); + self::assertExtractedRowsCount(2, $extractor); + self::assertExtractedBatchesSize(1, $extractor); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/MemoryExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/MemoryExtractorTest.php index 131caeecf..fa311b6b0 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/MemoryExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/MemoryExtractorTest.php @@ -6,10 +6,9 @@ use function Flow\ETL\DSL\{from_memory, int_entry, str_entry, to_memory}; use Flow\ETL\Memory\ArrayMemory; -use Flow\ETL\{Config, FlowContext, Row, Rows}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\{Config, FlowContext, Row, Rows, Tests\FlowTestCase}; -final class MemoryExtractorTest extends TestCase +final class MemoryExtractorTest extends FlowTestCase { public function test_memory_extractor() : void { @@ -27,13 +26,7 @@ public function test_memory_extractor() : void $extractor = from_memory($memory); - $data = []; - - foreach ($extractor->extract(new FlowContext(Config::default())) as $rowsData) { - $data = [...$data, ...$rowsData->toArray()]; - } - - self::assertSame( + self::assertExtractedRowsAsArrayEquals( [ ['number' => 1, 'name' => 'one'], ['number' => 2, 'name' => 'two'], @@ -41,7 +34,7 @@ public function test_memory_extractor() : void ['number' => 4, 'name' => 'four'], ['number' => 5, 'name' => 'five'], ], - $data + $extractor ); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/PipelineExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/PipelineExtractorTest.php index ec3e59f44..1df8a31c5 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/PipelineExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/PipelineExtractorTest.php @@ -7,10 +7,9 @@ use function Flow\ETL\DSL\int_entry; use Flow\ETL\Extractor\{PipelineExtractor, RowsExtractor}; use Flow\ETL\Pipeline\SynchronousPipeline; -use Flow\ETL\{Config, FlowContext, Row, Rows}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\{Row, Rows, Tests\FlowTestCase}; -final class PipelineExtractorTest extends TestCase +final class PipelineExtractorTest extends FlowTestCase { public function test_pipeline_extractor() : void { @@ -22,9 +21,6 @@ public function test_pipeline_extractor() : void $extractor = new PipelineExtractor($pipeline); - self::assertCount( - 3, - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) - ); + self::assertExtractedBatchesCount(3, $extractor); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/RowsExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/RowsExtractorTest.php index 4f27bd006..245162db8 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/RowsExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/RowsExtractorTest.php @@ -5,10 +5,9 @@ namespace Flow\ETL\Tests\Unit\Extractor; use function Flow\ETL\DSL\{from_rows, int_entry, str_entry}; -use Flow\ETL\{Config, FlowContext, Row, Rows}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\{Row, Rows, Tests\FlowTestCase}; -final class RowsExtractorTest extends TestCase +final class RowsExtractorTest extends FlowTestCase { public function test_process_extractor() : void { @@ -22,13 +21,7 @@ public function test_process_extractor() : void $extractor = from_rows($rows); - $data = []; - - foreach ($extractor->extract(new FlowContext(Config::default())) as $rowsData) { - $data = [...$data, ...$rowsData->toArray()]; - } - - self::assertSame( + self::assertExtractedRowsAsArrayEquals( [ ['number' => 1, 'name' => 'one'], ['number' => 2, 'name' => 'two'], @@ -36,7 +29,7 @@ public function test_process_extractor() : void ['number' => 4, 'name' => 'four'], ['number' => 5, 'name' => 'five'], ], - $rows->toArray() + $extractor ); } } diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/SequenceExtractorTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/SequenceExtractorTest.php index faac92e7e..262ee74ff 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/SequenceExtractorTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Extractor/SequenceExtractorTest.php @@ -9,28 +9,27 @@ from_sequence_date_period, from_sequence_date_period_recurrences, from_sequence_number}; -use Flow\ETL\{Config, FlowContext, Row, Rows}; -use PHPUnit\Framework\TestCase; +use Flow\ETL\{Row, Rows, Tests\FlowTestCase}; -final class SequenceExtractorTest extends TestCase +final class SequenceExtractorTest extends FlowTestCase { public function test_extracting_from_date_period() : void { $extractor = from_sequence_date_period('day', new \DateTimeImmutable('2023-01-01'), new \DateInterval('P1D'), new \DateTimeImmutable('2023-01-11'), \DatePeriod::EXCLUDE_START_DATE); - self::assertEquals( - [ - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-02')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-03')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-04')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-05')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-06')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-07')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-08')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-09')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-10')))), - ], - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) + self::assertExtractedRowsEquals( + new Rows( + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-02'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-03'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-04'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-05'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-06'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-07'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-08'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-09'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-10'))), + ), + $extractor ); } @@ -38,20 +37,20 @@ public function test_extracting_from_date_period_recurrences() : void { $extractor = from_sequence_date_period_recurrences('day', new \DateTimeImmutable('2023-01-01'), new \DateInterval('P1D'), 10, \DatePeriod::EXCLUDE_START_DATE); - self::assertEquals( - [ - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-02')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-03')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-04')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-05')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-06')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-07')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-08')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-09')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-10')))), - new Rows(Row::create(date_entry('day', new \DateTimeImmutable('2023-01-11')))), - ], - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) + self::assertExtractedRowsEquals( + new Rows( + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-02'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-03'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-04'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-05'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-06'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-07'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-08'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-09'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-10'))), + Row::create(date_entry('day', new \DateTimeImmutable('2023-01-11'))), + ), + $extractor ); } @@ -59,17 +58,17 @@ public function test_extracting_from_numbers_range() : void { $extractor = from_sequence_number('num', 0, 10, 1.5); - self::assertEquals( - [ - new Rows(Row::create(float_entry('num', 0))), - new Rows(Row::create(float_entry('num', 1.5))), - new Rows(Row::create(float_entry('num', 3))), - new Rows(Row::create(float_entry('num', 4.5))), - new Rows(Row::create(float_entry('num', 6))), - new Rows(Row::create(float_entry('num', 7.5))), - new Rows(Row::create(float_entry('num', 9))), - ], - \iterator_to_array($extractor->extract(new FlowContext(Config::default()))) + self::assertExtractedRowsEquals( + new Rows( + Row::create(float_entry('num', 0)), + Row::create(float_entry('num', 1.5)), + Row::create(float_entry('num', 3)), + Row::create(float_entry('num', 4.5)), + Row::create(float_entry('num', 6)), + Row::create(float_entry('num', 7.5)), + Row::create(float_entry('num', 9)), + ), + $extractor ); } }