Add dataset for single pointers

This commit is contained in:
Andrea Marco Sartori 2022-11-17 23:52:34 +10:00
parent 3e9da676ce
commit da7b20e489
2 changed files with 247 additions and 0 deletions

View File

@ -41,4 +41,22 @@ class Dataset
} }
} }
} }
/**
* Retrieve the dataset to test single pointers
*
* @return Generator
*/
public static function forSinglePointers(): Generator
{
$singlePointers = require __DIR__ . '/fixtures/pointers/single_pointer.php';
foreach ($singlePointers as $fixture => $pointers) {
$json = file_get_contents(__DIR__ . "/fixtures/json/{$fixture}.json");
foreach ($pointers as $pointer => $value) {
yield [$json, $pointer, $value];
}
}
}
} }

View File

@ -0,0 +1,229 @@
<?php
return [
'complex_array' => [
'/-/id' => ['id' => ['0001', '0002', '0003']],
'/-/batters' => [
'batters' => [
[
'batter' => [
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
[
"id" => "1003",
"type" => "Blueberry",
],
[
"id" => "1004",
"type" => "Devil's Food",
],
],
],
[
'batter' => [
[
"id" => "1001",
"type" => "Regular",
],
],
],
[
'batter' => [
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
],
],
],
],
'/-/batters/batter' => [
'batter' => [
[
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
[
"id" => "1003",
"type" => "Blueberry",
],
[
"id" => "1004",
"type" => "Devil's Food",
],
],
[
[
"id" => "1001",
"type" => "Regular",
],
],
[
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
],
],
],
'/-/batters/batter/-' => [
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
[
"id" => "1003",
"type" => "Blueberry",
],
[
"id" => "1004",
"type" => "Devil's Food",
],
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
],
'/-/batters/batter/-/id' => ['id' => ["1001", "1002", "1003", "1004", "1001", "1001", "1002"]],
],
'complex_object' => [
'/id' => ['id' => '0001'],
'/batters' => [
'batters' => [
'batter' => [
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
[
"id" => "1003",
"type" => "Blueberry",
],
[
"id" => "1004",
"type" => "Devil's Food",
],
],
],
],
'/batters/batter' => [
'batter' => [
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
[
"id" => "1003",
"type" => "Blueberry",
],
[
"id" => "1004",
"type" => "Devil's Food",
],
],
],
'/batters/batter/-' => [
[
"id" => "1001",
"type" => "Regular",
],
[
"id" => "1002",
"type" => "Chocolate",
],
[
"id" => "1003",
"type" => "Blueberry",
],
[
"id" => "1004",
"type" => "Devil's Food",
],
],
'/batters/batter/-/id' => ['id' => ["1001", "1002", "1003", "1004"]],
],
'empty_array' => [
'/-' => [],
'/-1' => [],
'/0' => [],
'/foo' => [],
],
'empty_object' => [
'/-' => [],
'/-1' => [],
'/0' => [],
'/foo' => [],
],
'simple_array' => [
'/-' => [1, '', 'foo', '"bar"', 'hej då', 3.14, false, null, [], []],
'/-1' => [],
'/0' => [1],
'/1' => [''],
'/2' => ['foo'],
'/3' => ['"bar"'],
'/4' => ['hej då'],
'/5' => [3.14],
'/6' => [false],
'/7' => [null],
'/8' => [[]],
'/9' => [[]],
'/10' => [],
'/foo' => [],
],
'simple_object' => [
'/-' => [],
'/-1' => [],
'/int' => ['int' => 1],
'/empty_string' => ['empty_string' => ''],
'/string' => ['string' => 'foo'],
'/escaped_string' => ['escaped_string' => '"bar"'],
'/\"escaped_key\"' => ['"escaped_key"' => 'baz'],
'/unicode' => ['unicode' => "hej då"],
'/float' => ['float' => 3.14],
'/bool' => ['bool' => false],
'/null' => ['null' => null],
'/empty_array' => ['empty_array' => []],
'/empty_object' => ['empty_object' => []],
'/10' => [],
'/foo' => [],
],
];