]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/JsonLDTest.php
Merge remote-tracking branch 'upstream/2021.12-rc' into user-banner
[friendica.git] / tests / src / Util / JsonLDTest.php
index 2c922d38446398b89e47f3b1fef9656a9291d5fb..6cb051f08c4d103c2159a7c4435969c90ae63736 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -62,6 +62,7 @@ class JsonLDTest extends TestCase
                $data = JsonLD::fetchElementArray($object, 'field', '@id');
                self::assertSame(['value3', 'value4'], $data);
        }
+
        public function testFetchElementArrayFoundArrays()
        {
                $object = ['field' => [['subfield11' => 'value11', 'subfield12' => 'value12'],
@@ -74,6 +75,17 @@ class JsonLDTest extends TestCase
                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 = [];