File tree 3 files changed +46
-1
lines changed
tests/19_NodeTypeManagement
3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ protected function registerNodeTypePrimaryItem()
23
23
return $ ntm ->registerNodeTypesCnd ($ this ->primary_item_cnd , true );
24
24
}
25
25
26
+ protected function registerBuiltinNodeType ()
27
+ {
28
+ $ ntm = $ this ->workspace ->getNodeTypeManager ();
29
+
30
+ return $ ntm ->registerNodeTypesCnd ($ this ->system_cnd , true );
31
+ }
32
+
26
33
private $ cnd = "
27
34
<'phpcr'='http://www.doctrine-project.org/projects/phpcr_odm'>
28
35
[phpcr:apitest]
@@ -39,4 +46,10 @@ protected function registerNodeTypePrimaryItem()
39
46
- phpcr:content (string)
40
47
primary
41
48
" ;
49
+
50
+ private $ system_cnd = "
51
+ <'nt'='http://www.jcp.org/jcr/nt/1.0'>
52
+ [nt:file]
53
+ - x (string)
54
+ " ;
42
55
}
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ protected function setUp()
29
29
$ this ->renewSession (); // reset session
30
30
parent ::setUp ();
31
31
32
- $ this ->session = $ this ->session ;
33
32
$ this ->workspace = $ this ->session ->getWorkspace ();
34
33
}
35
34
@@ -53,6 +52,14 @@ abstract protected function registerNodeTypes($allowUpdate);
53
52
*/
54
53
abstract protected function registerNodeTypePrimaryItem ();
55
54
55
+ /**
56
+ * Try to register a node type with an object or cnd that would overwrite
57
+ * a build-in node type, e.g. nt:file
58
+ *
59
+ * Have allowUpdate true, should still fail.
60
+ */
61
+ abstract protected function registerBuiltinNodeType ();
62
+
56
63
public function testRegisterNodeTypes ()
57
64
{
58
65
$ types = $ this ->registerNodeTypes (true );
@@ -159,4 +166,12 @@ public function testPrimaryItem()
159
166
$ this ->assertInstanceOf ('PHPCR\ItemInterface ' , $ node );
160
167
$ this ->assertEquals ('phpcr:content ' , $ primary ->getName ());
161
168
}
169
+
170
+ /**
171
+ * @expectedException \PHPCR\RepositoryException
172
+ */
173
+ public function testOverwriteBuiltinNodeType ()
174
+ {
175
+ $ this ->registerBuiltinNodeType ();
176
+ }
162
177
}
Original file line number Diff line number Diff line change @@ -60,4 +60,21 @@ protected function registerNodeTypePrimaryItem()
60
60
61
61
return $ ntm ->registerNodeTypes ($ nodeTypes , true );
62
62
}
63
+
64
+ protected function registerBuiltinNodeType ()
65
+ {
66
+ $ ntm = $ this ->workspace ->getNodeTypeManager ();
67
+
68
+ $ test = $ ntm ->createNodeTypeTemplate ();
69
+ $ test ->setName ('nt:file ' );
70
+
71
+ $ prop = $ ntm ->createPropertyDefinitionTemplate ();
72
+ $ prop ->setName ('x ' );
73
+ $ prop ->setRequiredType (PropertyType::STRING );
74
+ $ test ->getPropertyDefinitionTemplates ()->append ($ prop );
75
+
76
+ $ nodeTypes [] = $ test ;
77
+
78
+ return $ ntm ->registerNodeTypes ($ nodeTypes , true );
79
+ }
63
80
}
You can’t perform that action at this time.
0 commit comments