Skip to content

add tests trying to overwrite a built-in node type #126

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 8, 2014
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
13 changes: 13 additions & 0 deletions tests/19_NodeTypeManagement/CndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
";
}
17 changes: 16 additions & 1 deletion tests/19_NodeTypeManagement/NodeTypeBaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ protected function setUp()
$this->renewSession(); // reset session
parent::setUp();

$this->session = $this->session;
$this->workspace = $this->session->getWorkspace();
}

Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
17 changes: 17 additions & 0 deletions tests/19_NodeTypeManagement/NodeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}