@@ -97,4 +97,46 @@ public function testUpdateReference()
9797 $ referenced2 = $ session ->getNode ('/tests_general_base/idExample ' );
9898 $ this ->assertSame ($ referenced2 , $ session ->getProperty ('/tests_general_base/index.txt/jcr:content/reference ' )->getValue ());
9999 }
100+
101+ public function testSetUuidNewReferenceable ()
102+ {
103+ $ uuid = 'aaaa61c0-09ab-42a9-87c0-308ccc93aaaa ' ;
104+ $ node = $ this ->session ->getNode ('/tests_general_base/index.txt/jcr:content ' )->addNode ('newId ' , 'nt:unstructured ' );
105+ $ node ->addMixin ('mix:referenceable ' );
106+ $ node ->setProperty ('jcr:uuid ' , $ uuid );
107+ $ this ->session ->save ();
108+ $ this ->assertSame ($ uuid , $ node ->getIdentifier ());
109+
110+ $ session = $ this ->renewSession ();
111+
112+ $ node = $ session ->getNode ('/tests_general_base/index.txt/jcr:content/newId ' );
113+ $ this ->assertSame ($ uuid , $ node ->getIdentifier ());
114+ }
115+
116+ /**
117+ * @expectedException \PHPCR\NodeType\ConstraintViolationException
118+ */
119+ public function testSetUuidNewButNonreferenceable ()
120+ {
121+ $ node = $ this ->session ->getNode ('/tests_general_base/index.txt/jcr:content ' )->addNode ('newNonref ' , 'nt:unstructured ' );
122+ $ node ->setProperty ('jcr:uuid ' , 'bbbb61c0-09ab-42a9-87c0-308ccc93aaaa ' );
123+ }
124+
125+ /**
126+ * @expectedException \PHPCR\NodeType\ConstraintViolationException
127+ */
128+ public function testSetUuidReferenceableButExisting ()
129+ {
130+ $ node = $ this ->session ->getNode ('/tests_general_base/idExample ' );
131+ $ node ->setProperty ('jcr:uuid ' , 'cccc61c0-09ab-42a9-87c0-308ccc93aaaa ' );
132+ }
133+
134+ /**
135+ * @expectedException \PHPCR\NodeType\ConstraintViolationException
136+ */
137+ public function testSetUuidButNotReferenceableExisting ()
138+ {
139+ $ node = $ this ->session ->getNode ('/tests_general_base/index.txt/jcr:content ' );
140+ $ node ->setProperty ('jcr:uuid ' , 'dddd61c0-09ab-42a9-87c0-308ccc93aaaa ' );
141+ }
100142}
0 commit comments