11
11
12
12
namespace PHPCR \Tests \NodeTypeDiscovery ;
13
13
14
+ use PHPCR \NodeType \NodeDefinitionInterface ;
15
+ use PHPCR \NodeType \NodeTypeInterface ;
16
+ use PHPCR \NodeType \NodeTypeManagerInterface ;
17
+
14
18
/**
15
- * Test the NoteDefinition §8.
19
+ * Test NodeDefinition behaviour and reading NodeDefinition from NodeTypeDefinition §8.
16
20
*
17
21
* Requires that NodeTypeManager->getNodeType and NodeTypeDefinition->getChildNodeDefinitions() works correctly
18
22
*/
19
23
class NodeDefinitionTest extends \PHPCR \Test \BaseCase
20
24
{
21
25
private static $ base ;
26
+
27
+ /**
28
+ * @var NodeTypeInterface
29
+ */
22
30
private static $ file ;
31
+
32
+ /**
33
+ * @var NodeTypeInterface
34
+ */
23
35
private static $ folder ;
36
+
37
+ /**
38
+ * @var NodeTypeInterface
39
+ */
24
40
private static $ hierarchyNodeType ;
25
- /** jcr:content of nt:file */
41
+
42
+ /**
43
+ * Node definition of the jcr:content in an nt:file type.
44
+ *
45
+ * @var NodeDefinitionInterface
46
+ */
26
47
private $ content ;
48
+
49
+ /**
50
+ * Node definition of a hierarchy node.
51
+ *
52
+ * @var NodeDefinitionInterface
53
+ */
27
54
private $ hierarchyNodeDef ;
28
55
29
56
public static function setupBeforeClass ($ fixtures = false )
30
57
{
31
58
parent ::setupBeforeClass ($ fixtures );
59
+ /** @var NodeTypeManagerInterface $ntm */
32
60
$ ntm = self ::$ staticSharedFixture ['session ' ]->getWorkspace ()->getNodeTypeManager ();
33
61
self ::$ file = $ ntm ->getNodeType ('nt:file ' );
34
62
self ::$ folder = $ ntm ->getNodeType ('nt:folder ' );
@@ -37,6 +65,7 @@ public static function setupBeforeClass($fixtures = false)
37
65
38
66
public function setUp ()
39
67
{
68
+ parent ::setUp ();
40
69
try {
41
70
$ defs = self ::$ file ->getChildNodeDefinitions ();
42
71
$ this ->assertInternalType ('array ' , $ defs );
@@ -55,6 +84,7 @@ public function setUp()
55
84
$ this ->markTestSkipped ('getChildNodeDefinitions not working as it should, skipping tests about NodeDefinitionInterface: ' .$ e ->getMessage ());
56
85
}
57
86
}
87
+
58
88
public function testAllowsSameNameSiblings ()
59
89
{
60
90
$ this ->assertFalse ($ this ->content ->allowsSameNameSiblings ());
@@ -64,10 +94,12 @@ public function testDefaultPrimaryType()
64
94
{
65
95
$ this ->assertNull ($ this ->content ->getDefaultPrimaryType ());
66
96
}
97
+
67
98
public function testDefaultPrimaryTypeName ()
68
99
{
69
100
$ this ->assertNull ($ this ->content ->getDefaultPrimaryTypeName ());
70
101
}
102
+
71
103
public function getRequiredPrimaryTypeNames ()
72
104
{
73
105
$ names = $ this ->content ->getRequiredPrimaryTypeNames ();
@@ -102,26 +134,31 @@ public function testGetDeclaringNodeType()
102
134
$ nt = $ this ->hierarchyNodeDef ->getDeclaringNodeType ();
103
135
$ this ->assertSame (self ::$ folder , $ nt );
104
136
}
137
+
105
138
public function testName ()
106
139
{
107
140
$ this ->assertEquals ('jcr:content ' , $ this ->content ->getName ());
108
141
$ this ->assertEquals ('* ' , $ this ->hierarchyNodeDef ->getName ());
109
142
}
143
+
110
144
public function testGetOnParentVersion ()
111
145
{
112
146
$ this ->assertEquals (\PHPCR \Version \OnParentVersionAction::COPY , $ this ->content ->getOnParentVersion ());
113
147
$ this ->assertEquals (\PHPCR \Version \OnParentVersionAction::VERSION , $ this ->hierarchyNodeDef ->getOnParentVersion ());
114
148
}
149
+
115
150
public function testIsAutoCreated ()
116
151
{
117
152
$ this ->assertFalse ($ this ->content ->isAutoCreated ());
118
153
$ this ->assertFalse ($ this ->hierarchyNodeDef ->isAutoCreated ());
119
154
}
155
+
120
156
public function testIsMandatory ()
121
157
{
122
158
$ this ->assertTrue ($ this ->content ->isMandatory ());
123
159
$ this ->assertFalse ($ this ->hierarchyNodeDef ->isMandatory ());
124
160
}
161
+
125
162
public function testIsProtected ()
126
163
{
127
164
$ this ->assertFalse ($ this ->content ->isProtected ());
0 commit comments