Skip to content

10.4.2.5 Multi-value Properties and Null #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/05_Reading/BinaryReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function testReadBinaryValueAsString()
public function testGetLength()
{
$size = $this->binaryProperty->getLength();
$this->assertInternalType('integer', $size);
$this->assertEquals(strlen($this->decodedstring), $size);
}

Expand Down Expand Up @@ -113,6 +114,7 @@ public function testGetLengthMultivalue()
$sizes = $binaryMulti->getLength();
$this->assertInternalType('array', $sizes);
foreach ($sizes as $size) {
$this->assertInternalType('integer', $size);
$this->assertEquals(strlen($this->decodedstring), $size);
}
}
Expand Down
46 changes: 43 additions & 3 deletions tests/10_Writing/SetPropertyMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testSetPropertyMultivalue()
$prop = $node->getProperty('multivalue');
$this->assertEquals(\PHPCR\PropertyType::LONG, $prop->getType());
$this->assertTrue($prop->isMultiple());
$this->assertEquals(array(1,2,3), $prop->getValue('multivalue'));
$this->assertEquals(array(1,2,3), $prop->getValue());
}

public function testSetPropertyMultivalueOne()
Expand All @@ -171,7 +171,47 @@ public function testSetPropertyMultivalueOne()
$prop = $node->getProperty('multivalue2');
$this->assertEquals(\PHPCR\PropertyType::LONG, $prop->getType());
$this->assertTrue($prop->isMultiple());
$this->assertEquals(array(1), $prop->getValue('multivalue2'));
$this->assertEquals(array(1), $prop->getValue());
}

/**
* 10.4.2.5 Multi-value Properties and Null
*
* Null values must be removed from the list of values.
*/
public function testSetPropertyMultivalueNull()
{
$prop = $this->node->setProperty('multivalue_null', array(1, null, 3));
$this->assertEquals(array(1, 3), $this->node->getPropertyValue('multivalue_null'));
$this->assertEquals(\PHPCR\PropertyType::LONG, $prop->getType());
$this->assertTrue($prop->isMultiple());

$this->saveAndRenewSession();
$node = $this->session->getNode($this->nodePath);
$prop = $node->getProperty('multivalue_null');
$this->assertEquals(\PHPCR\PropertyType::LONG, $prop->getType());
$this->assertTrue($prop->isMultiple());
$this->assertEquals(array(1, 3), $prop->getValue());
}

/**
* 10.4.2.5 Multi-value Properties and Null
*
* Null values must be removed from the list of values.
*/
public function testSetPropertyMultivalueAllNull()
{
$prop = $this->node->setProperty('multivalue_allnull', array(null, null, null));
$this->assertEquals(array(), $this->node->getPropertyValue('multivalue_allnull'));
$this->assertEquals(\PHPCR\PropertyType::STRING, $prop->getType());
$this->assertTrue($prop->isMultiple());

$this->saveAndRenewSession();
$node = $this->session->getNode($this->nodePath);
$prop = $node->getProperty('multivalue_allnull');
$this->assertEquals(\PHPCR\PropertyType::STRING, $prop->getType());
$this->assertTrue($prop->isMultiple());
$this->assertEquals(array(), $prop->getValue());
}

public function testSetPropertyMultivalueRef()
Expand All @@ -187,7 +227,7 @@ public function testSetPropertyMultivalueRef()
$prop = $node->getProperty('multiref');
$this->assertEquals(\PHPCR\PropertyType::WEAKREFERENCE, $prop->getType());
$this->assertTrue($prop->isMultiple());
$this->assertEquals($ids, $prop->getString('multiref'));
$this->assertEquals($ids, $prop->getString());
$nodes = $prop->getValue();
$this->assertInternalType('array', $nodes);
$this->assertCount(3, $nodes);
Expand Down