<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* JsonLD utility test class
*/
class JsonLDTest extends TestCase
-{
+{
public function testFetchElementArrayNotFound()
{
$object = [];
$data = JsonLD::fetchElementArray($object, 'field', '@id');
self::assertSame(['value3', 'value4'], $data);
}
+
public function testFetchElementArrayFoundArrays()
{
$object = ['field' => [['subfield11' => 'value11', 'subfield12' => 'value12'],
self::assertSame($expect, $data);
}
+ public function testFetchElementArrayTypeValue()
+ {
+ $object = ['field' => [['subfield11' => 'value11', 'subfield12' => 'value12'],
+ ['subfield21' => 'value21', 'subfield22' => 'value22']]];
+
+ $expect = [['subfield11' => 'value11', 'subfield12' => 'value12']];
+
+ $data = JsonLD::fetchElementArray($object, 'field', null, 'subfield11', 'value11');
+ self::assertSame($expect, $data);
+ }
+
public function testFetchElementNotFound()
{
$object = [];