diff --git a/web/landing/assets/wasm/data/orders.floe b/web/landing/assets/wasm/data/orders.floe new file mode 100644 index 0000000000..0d00393b5a Binary files /dev/null and b/web/landing/assets/wasm/data/orders.floe differ diff --git a/web/landing/assets/wasm/data/orders.xlsx b/web/landing/assets/wasm/data/orders.xlsx new file mode 100644 index 0000000000..df4cd67598 Binary files /dev/null and b/web/landing/assets/wasm/data/orders.xlsx differ diff --git a/web/landing/content/examples/topics/partitioning/partition_pruning/input/color=blue/sku=A/data.csv b/web/landing/assets/wasm/data/partitioned/color=blue/sku=A/products.csv similarity index 100% rename from web/landing/content/examples/topics/partitioning/partition_pruning/input/color=blue/sku=A/data.csv rename to web/landing/assets/wasm/data/partitioned/color=blue/sku=A/products.csv diff --git a/web/landing/content/examples/topics/partitioning/partition_pruning/input/color=green/sku=A/data.csv b/web/landing/assets/wasm/data/partitioned/color=green/sku=A/products.csv similarity index 100% rename from web/landing/content/examples/topics/partitioning/partition_pruning/input/color=green/sku=A/data.csv rename to web/landing/assets/wasm/data/partitioned/color=green/sku=A/products.csv diff --git a/web/landing/content/examples/topics/partitioning/partition_pruning/input/color=red/sku=A/data.csv b/web/landing/assets/wasm/data/partitioned/color=red/sku=A/products.csv similarity index 100% rename from web/landing/content/examples/topics/partitioning/partition_pruning/input/color=red/sku=A/data.csv rename to web/landing/assets/wasm/data/partitioned/color=red/sku=A/products.csv diff --git a/web/landing/content/examples/topics/partitioning/partition_pruning/input/color=red/sku=B/data.csv b/web/landing/assets/wasm/data/partitioned/color=red/sku=B/products.csv similarity index 100% rename from web/landing/content/examples/topics/partitioning/partition_pruning/input/color=red/sku=B/data.csv rename to web/landing/assets/wasm/data/partitioned/color=red/sku=B/products.csv diff --git a/web/landing/content/examples/topics/data_frame/data_reading/csv/code.php b/web/landing/content/examples/topics/data_frame/data_reading/csv/code.php index 23ebe70e8d..7f11fdf092 100644 --- a/web/landing/content/examples/topics/data_frame/data_reading/csv/code.php +++ b/web/landing/content/examples/topics/data_frame/data_reading/csv/code.php @@ -9,7 +9,7 @@ data_frame() ->read(from_csv( - __DIR__ . '/input/dataset.csv', + __DIR__ . '/data/orders.csv', with_header: true, empty_to_null: true, separator: ',', diff --git a/web/landing/content/examples/topics/data_frame/data_reading/csv/input/dataset.csv b/web/landing/content/examples/topics/data_frame/data_reading/csv/input/dataset.csv deleted file mode 100644 index 237a3f2678..0000000000 --- a/web/landing/content/examples/topics/data_frame/data_reading/csv/input/dataset.csv +++ /dev/null @@ -1,6 +0,0 @@ -id,name,email,active -1,Alice,alice@example.com,true -2,Bob,bob@example.com,false -3,Charlie,charlie@example.com,true -4,Diana,diana@example.com,true -5,Eve,eve@example.com,false diff --git a/web/landing/content/examples/topics/data_frame/data_reading/excel/code.php b/web/landing/content/examples/topics/data_frame/data_reading/excel/code.php index ef5fe9ce0e..9df29773fc 100644 --- a/web/landing/content/examples/topics/data_frame/data_reading/excel/code.php +++ b/web/landing/content/examples/topics/data_frame/data_reading/excel/code.php @@ -9,7 +9,7 @@ data_frame() ->read(from_excel( - __DIR__ . '/input/dataset.xlsx', + __DIR__ . '/data/orders.xlsx', )) ->collect() ->write(to_output(truncate: false)) diff --git a/web/landing/content/examples/topics/data_frame/data_reading/excel/input/dataset.xlsx b/web/landing/content/examples/topics/data_frame/data_reading/excel/input/dataset.xlsx deleted file mode 100644 index ad8dbbb3de..0000000000 Binary files a/web/landing/content/examples/topics/data_frame/data_reading/excel/input/dataset.xlsx and /dev/null differ diff --git a/web/landing/content/examples/topics/data_frame/data_reading/floe/_meta.yaml b/web/landing/content/examples/topics/data_frame/data_reading/floe/_meta.yaml new file mode 100644 index 0000000000..7e24f38dd8 --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_reading/floe/_meta.yaml @@ -0,0 +1,2 @@ +priority: 0 +hidden: false diff --git a/web/landing/content/examples/topics/data_frame/data_reading/floe/code.php b/web/landing/content/examples/topics/data_frame/data_reading/floe/code.php new file mode 100644 index 0000000000..883f032132 --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_reading/floe/code.php @@ -0,0 +1,14 @@ +read(from_floe(__DIR__ . '/data/orders.floe')) + ->collect() + ->write(to_output(truncate: false)) + ->run(); diff --git a/web/landing/content/examples/topics/data_frame/data_reading/floe/description.md b/web/landing/content/examples/topics/data_frame/data_reading/floe/description.md new file mode 100644 index 0000000000..41506fbe83 --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_reading/floe/description.md @@ -0,0 +1 @@ +Extract data from Floe files. Floe is Flow's native self-describing binary format that stores the schema inside the file and evolves it across appended sections. diff --git a/web/landing/content/examples/topics/data_frame/data_reading/floe/documentation.md b/web/landing/content/examples/topics/data_frame/data_reading/floe/documentation.md new file mode 100644 index 0000000000..3bc9471dab --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_reading/floe/documentation.md @@ -0,0 +1 @@ +- [Floe File Format](/documentation/components/core/floe) diff --git a/web/landing/content/examples/topics/data_frame/data_reading/json/input/dataset.json b/web/landing/content/examples/topics/data_frame/data_reading/json/input/dataset.json deleted file mode 100644 index 6c9b6a14d2..0000000000 --- a/web/landing/content/examples/topics/data_frame/data_reading/json/input/dataset.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - {"id": 1, "name": "Alice", "email": "alice@example.com", "active": true}, - {"id": 2, "name": "Bob", "email": "bob@example.com", "active": false}, - {"id": 3, "name": "Charlie", "email": "charlie@example.com", "active": true}, - {"id": 4, "name": "Diana", "email": "diana@example.com", "active": true}, - {"id": 5, "name": "Eve", "email": "eve@example.com", "active": false} -] diff --git a/web/landing/content/examples/topics/data_frame/data_reading/jsonl/input/dataset.jsonl b/web/landing/content/examples/topics/data_frame/data_reading/jsonl/input/dataset.jsonl deleted file mode 100644 index 697c5d18d4..0000000000 --- a/web/landing/content/examples/topics/data_frame/data_reading/jsonl/input/dataset.jsonl +++ /dev/null @@ -1,5 +0,0 @@ -{"id": 1, "name": "Alice", "email": "alice@example.com", "active": true} -{"id": 2, "name": "Bob", "email": "bob@example.com", "active": false} -{"id": 3, "name": "Charlie", "email": "charlie@example.com", "active": true} -{"id": 4, "name": "Diana", "email": "diana@example.com", "active": true} -{"id": 5, "name": "Eve", "email": "eve@example.com", "active": false} diff --git a/web/landing/content/examples/topics/data_frame/data_reading/parquet/code.php b/web/landing/content/examples/topics/data_frame/data_reading/parquet/code.php index 6e95b2e918..3a44958ca5 100644 --- a/web/landing/content/examples/topics/data_frame/data_reading/parquet/code.php +++ b/web/landing/content/examples/topics/data_frame/data_reading/parquet/code.php @@ -9,7 +9,7 @@ data_frame() ->read(from_parquet( - __DIR__ . '/input/dataset.parquet', + __DIR__ . '/data/orders.parquet', )) ->collect() ->write(to_output(truncate: false)) diff --git a/web/landing/content/examples/topics/data_frame/data_reading/parquet/input/dataset.parquet b/web/landing/content/examples/topics/data_frame/data_reading/parquet/input/dataset.parquet deleted file mode 100644 index cbd326fd8e..0000000000 Binary files a/web/landing/content/examples/topics/data_frame/data_reading/parquet/input/dataset.parquet and /dev/null differ diff --git a/web/landing/content/examples/topics/data_frame/data_writing/floe/_meta.yaml b/web/landing/content/examples/topics/data_frame/data_writing/floe/_meta.yaml new file mode 100644 index 0000000000..7e24f38dd8 --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_writing/floe/_meta.yaml @@ -0,0 +1,2 @@ +priority: 0 +hidden: false diff --git a/web/landing/content/examples/topics/data_frame/data_writing/floe/code.php b/web/landing/content/examples/topics/data_frame/data_writing/floe/code.php new file mode 100644 index 0000000000..e4552eab87 --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_writing/floe/code.php @@ -0,0 +1,17 @@ +read(from_csv(__DIR__ . '/data/orders.csv')) + ->limit(10) + ->collect() + ->saveMode(overwrite()) + ->write(to_floe(__DIR__ . '/output.floe')) + ->run(); diff --git a/web/landing/content/examples/topics/data_frame/data_writing/floe/description.md b/web/landing/content/examples/topics/data_frame/data_writing/floe/description.md new file mode 100644 index 0000000000..2332761324 --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_writing/floe/description.md @@ -0,0 +1 @@ +Write data to Floe files. Floe is Flow's native self-describing binary format — the schema travels inside the file, so it reads back through the DataFrame API with no external metadata. diff --git a/web/landing/content/examples/topics/data_frame/data_writing/floe/documentation.md b/web/landing/content/examples/topics/data_frame/data_writing/floe/documentation.md new file mode 100644 index 0000000000..3bc9471dab --- /dev/null +++ b/web/landing/content/examples/topics/data_frame/data_writing/floe/documentation.md @@ -0,0 +1 @@ +- [Floe File Format](/documentation/components/core/floe) diff --git a/web/landing/content/examples/topics/data_frame/data_writing/overwrite/code.php b/web/landing/content/examples/topics/data_frame/data_writing/overwrite/code.php index 65d970cdcc..d0de04256e 100644 --- a/web/landing/content/examples/topics/data_frame/data_writing/overwrite/code.php +++ b/web/landing/content/examples/topics/data_frame/data_writing/overwrite/code.php @@ -8,7 +8,8 @@ require __DIR__ . '/vendor/autoload.php'; data_frame() - ->read(from_csv(__DIR__ . '/input/file.csv')) + ->read(from_csv(__DIR__ . '/data/orders.csv')) + ->limit(20) ->saveMode(overwrite()) ->write(to_csv(__DIR__ . '/output/file.csv')) ->collect() @@ -18,7 +19,7 @@ data_frame() ->read(from_csv(__DIR__ . '/output/file.csv')) ->saveMode(overwrite()) - ->drop('name') + ->drop('notes') ->write(to_csv(__DIR__ . '/output/file.csv')) ->collect() ->write(to_output(truncate: false)) diff --git a/web/landing/content/examples/topics/data_frame/data_writing/overwrite/input/file.csv b/web/landing/content/examples/topics/data_frame/data_writing/overwrite/input/file.csv deleted file mode 100644 index 5389099c0b..0000000000 --- a/web/landing/content/examples/topics/data_frame/data_writing/overwrite/input/file.csv +++ /dev/null @@ -1,4 +0,0 @@ -id,name,price -1,Product A,19.99 -2,Product B,29.99 -3,Product C,39.99 diff --git a/web/landing/content/examples/topics/partitioning/partition_pruning/code.php b/web/landing/content/examples/topics/partitioning/partition_pruning/code.php index 3ef795cf58..b9a6d020fe 100644 --- a/web/landing/content/examples/topics/partitioning/partition_pruning/code.php +++ b/web/landing/content/examples/topics/partitioning/partition_pruning/code.php @@ -8,7 +8,7 @@ require __DIR__ . '/vendor/autoload.php'; data_frame() - ->read(from_csv(__DIR__ . '/input/color=*/sku=*/*.csv')) + ->read(from_csv(__DIR__ . '/data/partitioned/color=*/sku=*/*.csv')) ->filterPartitions(ref('color')->notEquals(lit('green'))) ->collect() ->write(to_output(truncate: false)) diff --git a/web/landing/content/examples/topics/partitioning/path_partitions/code.php b/web/landing/content/examples/topics/partitioning/path_partitions/code.php index dc8654a2a0..de5790e199 100644 --- a/web/landing/content/examples/topics/partitioning/path_partitions/code.php +++ b/web/landing/content/examples/topics/partitioning/path_partitions/code.php @@ -7,7 +7,7 @@ require __DIR__ . '/vendor/autoload.php'; data_frame() - ->read(from_path_partitions(__DIR__ . '/input/color=*/sku=*/*.csv')) + ->read(from_path_partitions(__DIR__ . '/data/partitioned/color=*/sku=*/*.csv')) ->withEntry('path', ref('path')->strReplace(__DIR__, '/__ABSOLUTE_PATH__')) ->collect() ->write(to_output(truncate: false)) diff --git a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=blue/sku=A/data.csv b/web/landing/content/examples/topics/partitioning/path_partitions/input/color=blue/sku=A/data.csv deleted file mode 100644 index cabbeba10e..0000000000 --- a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=blue/sku=A/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -5,Blue Widget A,16.99 -6,Blue Gadget A,26.99 diff --git a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=green/sku=A/data.csv b/web/landing/content/examples/topics/partitioning/path_partitions/input/color=green/sku=A/data.csv deleted file mode 100644 index 03902632f1..0000000000 --- a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=green/sku=A/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -7,Green Widget A,17.99 -8,Green Gadget A,27.99 diff --git a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=red/sku=A/data.csv b/web/landing/content/examples/topics/partitioning/path_partitions/input/color=red/sku=A/data.csv deleted file mode 100644 index c8c353a410..0000000000 --- a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=red/sku=A/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -1,Red Widget A,15.99 -2,Red Gadget A,25.99 diff --git a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=red/sku=B/data.csv b/web/landing/content/examples/topics/partitioning/path_partitions/input/color=red/sku=B/data.csv deleted file mode 100644 index a7d09d424e..0000000000 --- a/web/landing/content/examples/topics/partitioning/path_partitions/input/color=red/sku=B/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -3,Red Widget B,18.99 -4,Red Gadget B,28.99 diff --git a/web/landing/content/examples/topics/partitioning/reading/basic/code.php b/web/landing/content/examples/topics/partitioning/reading/basic/code.php index 8b3c3f5fbb..ac6bb32f81 100644 --- a/web/landing/content/examples/topics/partitioning/reading/basic/code.php +++ b/web/landing/content/examples/topics/partitioning/reading/basic/code.php @@ -8,6 +8,6 @@ require __DIR__ . '/vendor/autoload.php'; data_frame() - ->read(from_csv(__DIR__ . '/input/color=*/sku=*/*.csv')) + ->read(from_csv(__DIR__ . '/data/partitioned/color=*/sku=*/*.csv')) ->write(to_output(truncate: false)) ->run(); diff --git a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=blue/sku=A/data.csv b/web/landing/content/examples/topics/partitioning/reading/basic/input/color=blue/sku=A/data.csv deleted file mode 100644 index cabbeba10e..0000000000 --- a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=blue/sku=A/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -5,Blue Widget A,16.99 -6,Blue Gadget A,26.99 diff --git a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=green/sku=A/data.csv b/web/landing/content/examples/topics/partitioning/reading/basic/input/color=green/sku=A/data.csv deleted file mode 100644 index 03902632f1..0000000000 --- a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=green/sku=A/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -7,Green Widget A,17.99 -8,Green Gadget A,27.99 diff --git a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=red/sku=A/data.csv b/web/landing/content/examples/topics/partitioning/reading/basic/input/color=red/sku=A/data.csv deleted file mode 100644 index c8c353a410..0000000000 --- a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=red/sku=A/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -1,Red Widget A,15.99 -2,Red Gadget A,25.99 diff --git a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=red/sku=B/data.csv b/web/landing/content/examples/topics/partitioning/reading/basic/input/color=red/sku=B/data.csv deleted file mode 100644 index a7d09d424e..0000000000 --- a/web/landing/content/examples/topics/partitioning/reading/basic/input/color=red/sku=B/data.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,price -3,Red Widget B,18.99 -4,Red Gadget B,28.99 diff --git a/web/landing/content/examples/topics/schema/inferring/code.php b/web/landing/content/examples/topics/schema/inferring/code.php index 790695076f..6d0e327dbd 100644 --- a/web/landing/content/examples/topics/schema/inferring/code.php +++ b/web/landing/content/examples/topics/schema/inferring/code.php @@ -14,7 +14,7 @@ if ($fs->status(path(__DIR__ . '/output/schema.json')) === null) { $schema = data_frame() - ->read(from_csv(__DIR__ . '/input/dataset.csv')) + ->read(from_csv(__DIR__ . '/data/orders.csv')) ->limit(100) // Limiting the number of rows to read will speed up the process but might bring less accurate results ->autoCast() ->schema(); @@ -28,7 +28,7 @@ // Reading schemaless data formats with predefined schema can significantly improve performance data_frame() - ->read(from_csv(__DIR__ . '/input/dataset.csv', schema: $schema)) + ->read(from_csv(__DIR__ . '/data/orders.csv', schema: $schema)) ->collect() ->write(to_output(truncate: false, output: Output::rows_and_schema)) ->run(); diff --git a/web/landing/content/examples/topics/schema/inferring/input/dataset.csv b/web/landing/content/examples/topics/schema/inferring/input/dataset.csv deleted file mode 100644 index 9e00562b00..0000000000 --- a/web/landing/content/examples/topics/schema/inferring/input/dataset.csv +++ /dev/null @@ -1,6 +0,0 @@ -id,name,price,quantity,active,created_at -1,Product A,19.99,10,true,2024-01-15 -2,Product B,29.99,5,false,2024-01-16 -3,Product C,39.99,8,true,2024-01-17 -4,Product D,49.99,3,true,2024-01-18 -5,Product E,59.99,12,false,2024-01-19 diff --git a/web/landing/phpunit.xml b/web/landing/phpunit.xml index 5bb0ba2a87..4eee2b675e 100644 --- a/web/landing/phpunit.xml +++ b/web/landing/phpunit.xml @@ -13,7 +13,7 @@ - + diff --git a/web/landing/src/Flow/Website/StaticSourceProvider/ExamplesSourceProvider.php b/web/landing/src/Flow/Website/StaticSourceProvider/ExamplesSourceProvider.php index c170a5b5b3..b15415b0c5 100644 --- a/web/landing/src/Flow/Website/StaticSourceProvider/ExamplesSourceProvider.php +++ b/web/landing/src/Flow/Website/StaticSourceProvider/ExamplesSourceProvider.php @@ -38,10 +38,27 @@ public function all(): array 'example' => $example, 'option' => $option, ]); + + foreach ($this->examples->dataFiles($topic, $example, $option) as $path) { + $sources[] = new Source('example_option_data', [ + 'topic' => $topic, + 'example' => $example, + 'option' => $option, + 'path' => $path, + ]); + } } } else { $sources[] = new Source('example', ['topic' => $topic, 'example' => $example]); $sources[] = new Source('example_playground', ['topic' => $topic, 'example' => $example]); + + foreach ($this->examples->dataFiles($topic, $example) as $path) { + $sources[] = new Source('example_data', [ + 'topic' => $topic, + 'example' => $example, + 'path' => $path, + ]); + } } } } diff --git a/web/landing/templates/playground/_playground.html.twig b/web/landing/templates/playground/_playground.html.twig index 6c8fdb37e2..2e3732bbdd 100644 --- a/web/landing/templates/playground/_playground.html.twig +++ b/web/landing/templates/playground/_playground.html.twig @@ -21,7 +21,13 @@ Parameters: 'data/orders.json': asset('wasm/data/orders.json'), 'data/orders.csv': asset('wasm/data/orders.csv'), 'data/orders.jsonl': asset('wasm/data/orders.jsonl'), - 'data/orders.parquet': asset('wasm/data/orders.parquet') + 'data/orders.parquet': asset('wasm/data/orders.parquet'), + 'data/orders.xlsx': asset('wasm/data/orders.xlsx'), + 'data/orders.floe': asset('wasm/data/orders.floe'), + 'data/partitioned/color=blue/sku=A/products.csv': asset('wasm/data/partitioned/color=blue/sku=A/products.csv'), + 'data/partitioned/color=green/sku=A/products.csv': asset('wasm/data/partitioned/color=green/sku=A/products.csv'), + 'data/partitioned/color=red/sku=A/products.csv': asset('wasm/data/partitioned/color=red/sku=A/products.csv'), + 'data/partitioned/color=red/sku=B/products.csv': asset('wasm/data/partitioned/color=red/sku=B/products.csv') } %} {% for virtualPath, relativePath in data_files|default({}) %} {% if option is defined and option is not null %} diff --git a/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/_meta.yaml b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/_meta.yaml new file mode 100644 index 0000000000..0d96c143f9 --- /dev/null +++ b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/_meta.yaml @@ -0,0 +1,2 @@ +priority: 1 +hidden: false diff --git a/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/_meta.yaml b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/_meta.yaml new file mode 100644 index 0000000000..372963400e --- /dev/null +++ b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/_meta.yaml @@ -0,0 +1,2 @@ +priority: 2 +hidden: false diff --git a/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/option_1/_meta.yaml b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/option_1/_meta.yaml new file mode 100644 index 0000000000..0d96c143f9 --- /dev/null +++ b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/option_1/_meta.yaml @@ -0,0 +1,2 @@ +priority: 1 +hidden: false diff --git a/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/option_1/code.php b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/option_1/code.php new file mode 100644 index 0000000000..3b1611c004 --- /dev/null +++ b/web/landing/tests/Flow/Website/Tests/Fixtures/WithDataFiles/topics/data_topic/option_example/option_1/code.php @@ -0,0 +1,5 @@ +getFilename() !== 'code.php') { + continue; + } + + $references = []; + preg_match_all( + "#__DIR__ \. '/(data/[^']+)'#", + (string) file_get_contents($file->getPathname()), + $references, + ); + + foreach ($references[1] as $reference) { + $matches = glob($wasmDir . '/' . $reference); + + static::assertNotEmpty($matches, sprintf( + '%s references "%s" which the playground does not ship', + $file->getPathname(), + $reference, + )); + + foreach ($matches as $match) { + static::assertContains( + str_replace($wasmDir . '/', '', $match), + $registered[1], + sprintf( + '%s references "%s" which is not registered in the wasm_resources map', + $file->getPathname(), + $reference, + ), + ); + } + + $checked++; + } + } + + static::assertGreaterThan(0, $checked, 'No dataset references were found to check'); + } +} diff --git a/web/landing/tests/Flow/Website/Tests/Integration/ExamplesSourceProviderTest.php b/web/landing/tests/Flow/Website/Tests/Integration/ExamplesSourceProviderTest.php new file mode 100644 index 0000000000..9cfcca14dd --- /dev/null +++ b/web/landing/tests/Flow/Website/Tests/Integration/ExamplesSourceProviderTest.php @@ -0,0 +1,56 @@ +all(); + + static::assertContainsEquals( + new Source('example_option_data', [ + 'topic' => 'data_topic', + 'example' => 'option_example', + 'option' => 'option_1', + 'path' => 'input/nested/data.csv', + ]), + $sources, + ); + } + + public function test_data_sources_are_emitted_for_example_without_options(): void + { + $sources = (new ExamplesSourceProvider(new Examples(__DIR__ . '/../Fixtures/WithDataFiles')))->all(); + + static::assertContainsEquals( + new Source('example_data', [ + 'topic' => 'data_topic', + 'example' => 'plain_example', + 'path' => 'input/dataset.csv', + ]), + $sources, + ); + } + + public function test_no_data_sources_are_emitted_when_example_ships_no_input(): void + { + $sources = (new ExamplesSourceProvider(new Examples(__DIR__ . '/../Fixtures/Valid')))->all(); + + static::assertSame( + ['example', 'example_playground'], + array_values(array_unique(array_map(static fn(Source $source): string => $source->routerName(), $sources))), + ); + } +}