diff --git a/tests/NodeTypeDiscovery/NodeDefinitionTest.php b/tests/NodeTypeDiscovery/NodeDefinitionTest.php index c4c8522c..547ccabf 100644 --- a/tests/NodeTypeDiscovery/NodeDefinitionTest.php +++ b/tests/NodeTypeDiscovery/NodeDefinitionTest.php @@ -11,24 +11,52 @@ namespace PHPCR\Tests\NodeTypeDiscovery; +use PHPCR\NodeType\NodeDefinitionInterface; +use PHPCR\NodeType\NodeTypeInterface; +use PHPCR\NodeType\NodeTypeManagerInterface; + /** - * Test the NoteDefinition §8. + * Test NodeDefinition behaviour and reading NodeDefinition from NodeTypeDefinition §8. * * Requires that NodeTypeManager->getNodeType and NodeTypeDefinition->getChildNodeDefinitions() works correctly */ class NodeDefinitionTest extends \PHPCR\Test\BaseCase { private static $base; + + /** + * @var NodeTypeInterface + */ private static $file; + + /** + * @var NodeTypeInterface + */ private static $folder; + + /** + * @var NodeTypeInterface + */ private static $hierarchyNodeType; - /** jcr:content of nt:file */ + + /** + * Node definition of the jcr:content in an nt:file type. + * + * @var NodeDefinitionInterface + */ private $content; + + /** + * Node definition of a hierarchy node. + * + * @var NodeDefinitionInterface + */ private $hierarchyNodeDef; public static function setupBeforeClass($fixtures = false) { parent::setupBeforeClass($fixtures); + /** @var NodeTypeManagerInterface $ntm */ $ntm = self::$staticSharedFixture['session']->getWorkspace()->getNodeTypeManager(); self::$file = $ntm->getNodeType('nt:file'); self::$folder = $ntm->getNodeType('nt:folder'); @@ -37,6 +65,7 @@ public static function setupBeforeClass($fixtures = false) public function setUp() { + parent::setUp(); try { $defs = self::$file->getChildNodeDefinitions(); $this->assertInternalType('array', $defs); @@ -55,6 +84,7 @@ public function setUp() $this->markTestSkipped('getChildNodeDefinitions not working as it should, skipping tests about NodeDefinitionInterface: '.$e->getMessage()); } } + public function testAllowsSameNameSiblings() { $this->assertFalse($this->content->allowsSameNameSiblings()); @@ -64,10 +94,12 @@ public function testDefaultPrimaryType() { $this->assertNull($this->content->getDefaultPrimaryType()); } + public function testDefaultPrimaryTypeName() { $this->assertNull($this->content->getDefaultPrimaryTypeName()); } + public function getRequiredPrimaryTypeNames() { $names = $this->content->getRequiredPrimaryTypeNames(); @@ -102,26 +134,31 @@ public function testGetDeclaringNodeType() $nt = $this->hierarchyNodeDef->getDeclaringNodeType(); $this->assertSame(self::$folder, $nt); } + public function testName() { $this->assertEquals('jcr:content', $this->content->getName()); $this->assertEquals('*', $this->hierarchyNodeDef->getName()); } + public function testGetOnParentVersion() { $this->assertEquals(\PHPCR\Version\OnParentVersionAction::COPY, $this->content->getOnParentVersion()); $this->assertEquals(\PHPCR\Version\OnParentVersionAction::VERSION, $this->hierarchyNodeDef->getOnParentVersion()); } + public function testIsAutoCreated() { $this->assertFalse($this->content->isAutoCreated()); $this->assertFalse($this->hierarchyNodeDef->isAutoCreated()); } + public function testIsMandatory() { $this->assertTrue($this->content->isMandatory()); $this->assertFalse($this->hierarchyNodeDef->isMandatory()); } + public function testIsProtected() { $this->assertFalse($this->content->isProtected()); diff --git a/tests/NodeTypeDiscovery/NodeNodeDefinitionTest.php b/tests/NodeTypeDiscovery/NodeNodeDefinitionTest.php new file mode 100644 index 00000000..c4c19865 --- /dev/null +++ b/tests/NodeTypeDiscovery/NodeNodeDefinitionTest.php @@ -0,0 +1,44 @@ +rootNode->getNode('tests_general_base/numberPropertyNode/jcr:content'); + $nodeDef = $node->getDefinition(); + $this->assertInstanceOf('PHPCR\\NodeType\\NodeDefinitionInterface', $nodeDef); + $this->assertEquals('jcr:content', $nodeDef->getName()); + $this->assertTrue($nodeDef->isMandatory()); + } + + public function testGetNodeDefinitionWildcard() + { + // defines a child of nt:folder + $node = $this->rootNode->getNode('tests_general_base/index.txt'); + $nodeDef = $node->getDefinition(); + $this->assertInstanceOf('PHPCR\\NodeType\\NodeDefinitionInterface', $nodeDef); + $this->assertEquals('*', $nodeDef->getName()); + } +} diff --git a/tests/NodeTypeDiscovery/PropertyDefinitionTest.php b/tests/NodeTypeDiscovery/PropertyDefinitionTest.php index b32fe809..850df677 100644 --- a/tests/NodeTypeDiscovery/PropertyDefinitionTest.php +++ b/tests/NodeTypeDiscovery/PropertyDefinitionTest.php @@ -11,6 +11,9 @@ namespace PHPCR\Tests\NodeTypeDiscovery; +use PHPCR\NodeType\NodeTypeInterface; +use PHPCR\NodeType\NodeTypeManagerInterface; +use PHPCR\NodeType\PropertyDefinitionInterface; use PHPCR\Query\QOM\QueryObjectModelConstantsInterface; /** @@ -20,26 +23,77 @@ */ class PropertyDefinitionTest extends \PHPCR\Test\BaseCase { + /** + * @var NodeTypeInterface + */ private static $base; + + /** + * @var NodeTypeInterface + */ private static $address; + + /** + * @var NodeTypeInterface + */ private static $mix_created; + + /** + * @var NodeTypeInterface + */ private static $resource; - /** nt:base property */ - private $primaryType; // (NAME) mandatory autocreated protected COMPUTE - private $mixinTypes; // (NAME) protected multiple COMPUTE + // properties of nt:base + /** + * (NAME) mandatory autocreated protected COMPUTE + * @var PropertyDefinitionInterface + */ + private $primaryType; + + /** + * (NAME) protected multiple COMPUTE + * @var PropertyDefinitionInterface + */ + private $mixinTypes; + /** properties of nt:address */ - private $workspace; // (STRING) - private $pathprop; // (PATH) - private $id; // (WEAKREFERENCE) - /** property of mix:created */ - private $created; // (DATE) autocreated protected - /** property of nt:resource */ - private $data; // (BINARY) mandatory + + /** + * (STRING) + * @var PropertyDefinitionInterface + */ + private $workspace; + + /** + * (PATH) + * @var PropertyDefinitionInterface + */ + private $pathprop; + + /** + * (WEAKREFERENCE) + * @var PropertyDefinitionInterface + */ + private $id; + + /** + * (DATE) autocreated protected + * property of mix:created + * @var PropertyDefinitionInterface + */ + private $created; // + + /** + * (BINARY) mandatory + * property of nt:resource + * @var PropertyDefinitionInterface + */ + private $data; // public static function setupBeforeClass($fixtures = false) { parent::setupBeforeClass(); // load default fixtures + /** @var NodeTypeManagerInterface $ntm */ $ntm = self::$staticSharedFixture['session']->getWorkspace()->getNodeTypeManager(); self::$base = $ntm->getNodeType('nt:base'); self::$address = $ntm->getNodeType('nt:address'); @@ -238,7 +292,7 @@ public function testGetPropertyDefinitionExact() $this->assertEquals('jcr:created', $propDef->getName()); } - public function estGetPropertyDefinitionWildcard() + public function testGetPropertyDefinitionWildcard() { $node = $this->rootNode->getNode('tests_general_base/numberPropertyNode/jcr:content'); $valProperty = $node->getProperty('foo');