Skip to content

test behaviour with jcr:uuid property #149

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
Jan 15, 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
14 changes: 13 additions & 1 deletion tests/05_Reading/NodeReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,21 @@ public function testGetIdentifier()
$this->assertEquals('842e61c0-09ab-42a9-87c0-308ccc90e6f4', $id);
}

/**
* The JCR specification is not saying what the properties of this id
* should be. But it must be a string.
*/
public function testGetIdentifierNonReferenceable()
{
$id = $this->node->getNode('index.txt')->getIdentifier();
$this->assertInternalType('string', $id);
}

/**
* getIndex has to work even when same-name siblings are not allowed.
*/
public function testGetIndex()
{
//TODO: Improve this test to test actual multiple nodes
$index = $this->node->getIndex();
$this->assertTrue(is_numeric($index));
$this->assertEquals(1, $index);
Expand Down
42 changes: 42 additions & 0 deletions tests/10_Writing/MixinReferenceableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,46 @@ public function testUpdateReference()
$referenced2 = $session->getNode('/tests_general_base/idExample');
$this->assertSame($referenced2, $session->getProperty('/tests_general_base/index.txt/jcr:content/reference')->getValue());
}

public function testSetUuidNewReferenceable()
{
$uuid = 'aaaa61c0-09ab-42a9-87c0-308ccc93aaaa';
$node = $this->session->getNode('/tests_general_base/index.txt/jcr:content')->addNode('newId', 'nt:unstructured');
$node->addMixin('mix:referenceable');
$node->setProperty('jcr:uuid', $uuid);
$this->session->save();
$this->assertSame($uuid, $node->getIdentifier());

$session = $this->renewSession();

$node = $session->getNode('/tests_general_base/index.txt/jcr:content/newId');
$this->assertSame($uuid, $node->getIdentifier());
}

/**
* @expectedException \PHPCR\NodeType\ConstraintViolationException
*/
public function testSetUuidNewButNonreferenceable()
{
$node = $this->session->getNode('/tests_general_base/index.txt/jcr:content')->addNode('newNonref', 'nt:unstructured');
$node->setProperty('jcr:uuid', 'bbbb61c0-09ab-42a9-87c0-308ccc93aaaa');
}

/**
* @expectedException \PHPCR\NodeType\ConstraintViolationException
*/
public function testSetUuidReferenceableButExisting()
{
$node = $this->session->getNode('/tests_general_base/idExample');
$node->setProperty('jcr:uuid', 'cccc61c0-09ab-42a9-87c0-308ccc93aaaa');
}

/**
* @expectedException \PHPCR\NodeType\ConstraintViolationException
*/
public function testSetUuidButNotReferenceableExisting()
{
$node = $this->session->getNode('/tests_general_base/index.txt/jcr:content');
$node->setProperty('jcr:uuid', 'dddd61c0-09ab-42a9-87c0-308ccc93aaaa');
}
}