Just some more tests added
This commit is contained in:
parent
699429ab08
commit
0799b721c9
|
@ -37,6 +37,14 @@ class JsonLDTest extends TestCase
|
||||||
$this->assertNull($data);
|
$this->assertNull($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFetchElementArrayFoundEmptyArray()
|
||||||
|
{
|
||||||
|
$object = ['field' => []];
|
||||||
|
|
||||||
|
$data = JsonLD::fetchElementArray($object, 'field');
|
||||||
|
$this->assertSame([], $data);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFetchElementArrayFoundID()
|
public function testFetchElementArrayFoundID()
|
||||||
{
|
{
|
||||||
$object = ['field' => ['value1', ['@id' => 'value2'], ['@id' => 'value3']]];
|
$object = ['field' => ['value1', ['@id' => 'value2'], ['@id' => 'value3']]];
|
||||||
|
@ -45,6 +53,17 @@ class JsonLDTest extends TestCase
|
||||||
$this->assertSame(['value1', 'value2', 'value3'], $data);
|
$this->assertSame(['value1', 'value2', 'value3'], $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFetchElementArrayFoundArrays()
|
||||||
|
{
|
||||||
|
$object = ['field' => [['subfield11' => 'value11', 'subfield12' => 'value12'],
|
||||||
|
['subfield21' => 'value21', 'subfield22' => 'value22']]];
|
||||||
|
|
||||||
|
$expect = [['subfield11' => 'value11', 'subfield12' => 'value12'],
|
||||||
|
['subfield21' => 'value21', 'subfield22' => 'value22']];
|
||||||
|
|
||||||
|
$data = JsonLD::fetchElementArray($object, 'field');
|
||||||
|
$this->assertSame($expect, $data);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFetchElementNotFound()
|
public function testFetchElementNotFound()
|
||||||
{
|
{
|
||||||
|
@ -62,6 +81,14 @@ class JsonLDTest extends TestCase
|
||||||
$this->assertSame('value', $data);
|
$this->assertSame('value', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFetchElementFoundEmptyString()
|
||||||
|
{
|
||||||
|
$object = ['field' => ''];
|
||||||
|
|
||||||
|
$data = JsonLD::fetchElement($object, 'field');
|
||||||
|
$this->assertSame('', $data);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFetchElementFoundID()
|
public function testFetchElementFoundID()
|
||||||
{
|
{
|
||||||
$object = ['field' => ['field2' => 'value2', '@id' => 'value', 'field3' => 'value3']];
|
$object = ['field' => ['field2' => 'value2', '@id' => 'value', 'field3' => 'value3']];
|
||||||
|
|
Loading…
Reference in a new issue