diff --git a/tests/data/item_selector.json b/tests/data/item_selector.json index 8985fb3533c12b93e2a76a1b75c5ba99211a617c..bc01b9959391e2502e4e5465528873f8ef8d53e7 100644 --- a/tests/data/item_selector.json +++ b/tests/data/item_selector.json @@ -3,11 +3,27 @@ "data": [ { "id": 1, - "title": "1 item" + "title": "1 item", + "items": [ + { + "id": 1, + "title": "1.1 item" + }, + { + "id": 2, + "title": "1.2 item" + } + ] }, { "id": 2, - "title": "2 item" + "title": "2 item", + "items": [ + { + "id": 3, + "title": "2.1 item" + } + ] } ], "data_empty": [], diff --git a/tests/src/Kernel/Plugin/migrate_plus/data_parser/JsonTest.php b/tests/src/Kernel/Plugin/migrate_plus/data_parser/JsonTest.php index 2be7f156261ee019cbddb9be8e3446c232eb69bd..e3f10d67b04d8974859cd0384527e941ca3f11b3 100644 --- a/tests/src/Kernel/Plugin/migrate_plus/data_parser/JsonTest.php +++ b/tests/src/Kernel/Plugin/migrate_plus/data_parser/JsonTest.php @@ -213,6 +213,38 @@ final class JsonTest extends KernelTestBase { ], ], ], + 'item_selector 2nd level' => [ + 'item_selector' => '/data/0/items', + 'fields' => $fields, + 'expected' => [ + [ + 'id' => '1', + 'title' => '1.1 item', + ], + [ + 'id' => '2', + 'title' => '1.2 item', + ], + ], + ], + 'item_selector 2nd level, depth selector' => [ + 'item_selector' => 3, + 'fields' => $fields, + 'expected' => [ + [ + 'id' => '1', + 'title' => '1.1 item', + ], + [ + 'id' => '2', + 'title' => '1.2 item', + ], + [ + 'id' => '3', + 'title' => '2.1 item', + ], + ], + ], ]; }