diff --git a/tests/19_NodeTypeManagement/CndTest.php b/tests/19_NodeTypeManagement/CndTest.php index 2f4d989e..af1568cb 100644 --- a/tests/19_NodeTypeManagement/CndTest.php +++ b/tests/19_NodeTypeManagement/CndTest.php @@ -23,6 +23,13 @@ protected function registerNodeTypePrimaryItem() return $ntm->registerNodeTypesCnd($this->primary_item_cnd, true); } + protected function registerBuiltinNodeType() + { + $ntm = $this->workspace->getNodeTypeManager(); + + return $ntm->registerNodeTypesCnd($this->system_cnd, true); + } + private $cnd = " <'phpcr'='http://www.doctrine-project.org/projects/phpcr_odm'> [phpcr:apitest] @@ -39,4 +46,10 @@ protected function registerNodeTypePrimaryItem() - phpcr:content (string) primary "; + + private $system_cnd = " + <'nt'='http://www.jcp.org/jcr/nt/1.0'> + [nt:file] + - x (string) + "; } diff --git a/tests/19_NodeTypeManagement/NodeTypeBaseCase.php b/tests/19_NodeTypeManagement/NodeTypeBaseCase.php index e1e0afb8..e5bc90a5 100644 --- a/tests/19_NodeTypeManagement/NodeTypeBaseCase.php +++ b/tests/19_NodeTypeManagement/NodeTypeBaseCase.php @@ -29,7 +29,6 @@ protected function setUp() $this->renewSession(); // reset session parent::setUp(); - $this->session = $this->session; $this->workspace = $this->session->getWorkspace(); } @@ -53,6 +52,14 @@ abstract protected function registerNodeTypes($allowUpdate); */ abstract protected function registerNodeTypePrimaryItem(); + /** + * Try to register a node type with an object or cnd that would overwrite + * a build-in node type, e.g. nt:file + * + * Have allowUpdate true, should still fail. + */ + abstract protected function registerBuiltinNodeType(); + public function testRegisterNodeTypes() { $types = $this->registerNodeTypes(true); @@ -159,4 +166,12 @@ public function testPrimaryItem() $this->assertInstanceOf('PHPCR\ItemInterface', $node); $this->assertEquals('phpcr:content', $primary->getName()); } + + /** + * @expectedException \PHPCR\RepositoryException + */ + public function testOverwriteBuiltinNodeType() + { + $this->registerBuiltinNodeType(); + } } diff --git a/tests/19_NodeTypeManagement/NodeTypeTest.php b/tests/19_NodeTypeManagement/NodeTypeTest.php index dc809245..7c2a4b32 100644 --- a/tests/19_NodeTypeManagement/NodeTypeTest.php +++ b/tests/19_NodeTypeManagement/NodeTypeTest.php @@ -60,4 +60,21 @@ protected function registerNodeTypePrimaryItem() return $ntm->registerNodeTypes($nodeTypes, true); } + + protected function registerBuiltinNodeType() + { + $ntm = $this->workspace->getNodeTypeManager(); + + $test = $ntm->createNodeTypeTemplate(); + $test->setName('nt:file'); + + $prop = $ntm->createPropertyDefinitionTemplate(); + $prop->setName('x'); + $prop->setRequiredType(PropertyType::STRING); + $test->getPropertyDefinitionTemplates()->append($prop); + + $nodeTypes[] = $test; + + return $ntm->registerNodeTypes($nodeTypes, true); + } }