1111
1212namespace PHPCR \Tests \NodeTypeDiscovery ;
1313
14+ use PHPCR \NodeType \NodeDefinitionInterface ;
15+ use PHPCR \NodeType \NodeTypeInterface ;
16+ use PHPCR \NodeType \NodeTypeManagerInterface ;
17+
1418/**
15- * Test the NoteDefinition §8.
19+ * Test NodeDefinition behaviour and reading NodeDefinition from NodeTypeDefinition §8.
1620 *
1721 * Requires that NodeTypeManager->getNodeType and NodeTypeDefinition->getChildNodeDefinitions() works correctly
1822 */
1923class NodeDefinitionTest extends \PHPCR \Test \BaseCase
2024{
2125 private static $ base ;
26+
27+ /**
28+ * @var NodeTypeInterface
29+ */
2230 private static $ file ;
31+
32+ /**
33+ * @var NodeTypeInterface
34+ */
2335 private static $ folder ;
36+
37+ /**
38+ * @var NodeTypeInterface
39+ */
2440 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+ */
2647 private $ content ;
48+
49+ /**
50+ * Node definition of a hierarchy node.
51+ *
52+ * @var NodeDefinitionInterface
53+ */
2754 private $ hierarchyNodeDef ;
2855
2956 public static function setupBeforeClass ($ fixtures = false )
3057 {
3158 parent ::setupBeforeClass ($ fixtures );
59+ /** @var NodeTypeManagerInterface $ntm */
3260 $ ntm = self ::$ staticSharedFixture ['session ' ]->getWorkspace ()->getNodeTypeManager ();
3361 self ::$ file = $ ntm ->getNodeType ('nt:file ' );
3462 self ::$ folder = $ ntm ->getNodeType ('nt:folder ' );
@@ -37,6 +65,7 @@ public static function setupBeforeClass($fixtures = false)
3765
3866 public function setUp ()
3967 {
68+ parent ::setUp ();
4069 try {
4170 $ defs = self ::$ file ->getChildNodeDefinitions ();
4271 $ this ->assertInternalType ('array ' , $ defs );
@@ -55,6 +84,7 @@ public function setUp()
5584 $ this ->markTestSkipped ('getChildNodeDefinitions not working as it should, skipping tests about NodeDefinitionInterface: ' .$ e ->getMessage ());
5685 }
5786 }
87+
5888 public function testAllowsSameNameSiblings ()
5989 {
6090 $ this ->assertFalse ($ this ->content ->allowsSameNameSiblings ());
@@ -64,10 +94,12 @@ public function testDefaultPrimaryType()
6494 {
6595 $ this ->assertNull ($ this ->content ->getDefaultPrimaryType ());
6696 }
97+
6798 public function testDefaultPrimaryTypeName ()
6899 {
69100 $ this ->assertNull ($ this ->content ->getDefaultPrimaryTypeName ());
70101 }
102+
71103 public function getRequiredPrimaryTypeNames ()
72104 {
73105 $ names = $ this ->content ->getRequiredPrimaryTypeNames ();
@@ -102,26 +134,31 @@ public function testGetDeclaringNodeType()
102134 $ nt = $ this ->hierarchyNodeDef ->getDeclaringNodeType ();
103135 $ this ->assertSame (self ::$ folder , $ nt );
104136 }
137+
105138 public function testName ()
106139 {
107140 $ this ->assertEquals ('jcr:content ' , $ this ->content ->getName ());
108141 $ this ->assertEquals ('* ' , $ this ->hierarchyNodeDef ->getName ());
109142 }
143+
110144 public function testGetOnParentVersion ()
111145 {
112146 $ this ->assertEquals (\PHPCR \Version \OnParentVersionAction::COPY , $ this ->content ->getOnParentVersion ());
113147 $ this ->assertEquals (\PHPCR \Version \OnParentVersionAction::VERSION , $ this ->hierarchyNodeDef ->getOnParentVersion ());
114148 }
149+
115150 public function testIsAutoCreated ()
116151 {
117152 $ this ->assertFalse ($ this ->content ->isAutoCreated ());
118153 $ this ->assertFalse ($ this ->hierarchyNodeDef ->isAutoCreated ());
119154 }
155+
120156 public function testIsMandatory ()
121157 {
122158 $ this ->assertTrue ($ this ->content ->isMandatory ());
123159 $ this ->assertFalse ($ this ->hierarchyNodeDef ->isMandatory ());
124160 }
161+
125162 public function testIsProtected ()
126163 {
127164 $ this ->assertFalse ($ this ->content ->isProtected ());
0 commit comments