From 21d48bca33eedb463e13e35c782b68e3ba63e342 Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Sun, 28 Jan 2024 15:32:37 +0100 Subject: [PATCH] Remove dependency from CSV adapter in AnalyzeTest --- .../Integration/DataFrame/AnalyzeTest.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) 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 8b7a67fda..241ced742 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 @@ -4,11 +4,11 @@ namespace Flow\ETL\Tests\Integration\DataFrame; -use function Flow\ETL\Adapter\CSV\from_csv; use function Flow\ETL\Adapter\Text\from_text; use function Flow\ETL\DSL\datetime_schema; use function Flow\ETL\DSL\df; use function Flow\ETL\DSL\float_schema; +use function Flow\ETL\DSL\from_array; use function Flow\ETL\DSL\int_schema; use function Flow\ETL\DSL\schema; use function Flow\ETL\DSL\str_schema; @@ -19,11 +19,17 @@ final class AnalyzeTest extends IntegrationTestCase public function test_analyzing_csv_file_with_auto_cast() : void { $report = df() - ->read(from_csv(__DIR__ . '/Fixtures/Analyze/goldstock.csv')) + ->read(from_array([ + ['Index' => 1, 'Date' => '2024-01-19', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => 2, 'Date' => '2024-01-20', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => 3, 'Date' => '2024-01-21', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => 4, 'Date' => '2024-01-22', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => 5, 'Date' => '2024-01-23', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ])) ->autoCast() ->run(analyze: true); - $this->assertSame(2511, $report->statistics()->totalRows()); + $this->assertSame(5, $report->statistics()->totalRows()); $this->assertEquals( schema( int_schema('Index'), @@ -42,11 +48,17 @@ public function test_analyzing_csv_file_with_auto_cast() : void public function test_analyzing_csv_file_with_limit() : void { $report = df() - ->read(from_csv(__DIR__ . '/Fixtures/Analyze/goldstock.csv')) - ->limit(100) + ->read(from_array([ + ['Index' => '1', 'Date' => '2024-01-19', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => '2', 'Date' => '2024-01-20', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => '3', 'Date' => '2024-01-21', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => '4', 'Date' => '2024-01-22', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ['Index' => '5', 'Date' => '2024-01-23', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'], + ])) + ->limit(2) ->run(analyze: true); - $this->assertSame(100, $report->statistics()->totalRows()); + $this->assertSame(2, $report->statistics()->totalRows()); $this->assertEquals( schema( str_schema('Index'),