Skip to content

Commit

Permalink
Add implementation for Jackalope\Node::isNodeType()
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed May 7, 2011
1 parent 2b059f9 commit a4c9451
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Jackalope/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,10 @@ public function getMixinNodeTypes()
*/
public function isNodeType($nodeTypeName)
{
throw new NotImplementedException();
return (
$this->primaryType == $nodeTypeName ||
(isset($this->properties["jcr:mixinTypes"]) && in_array($nodeTypeName, $this->properties["jcr:mixinTypes"]->getNativeValue()))
);
}

/**
Expand Down
20 changes: 16 additions & 4 deletions tests/Jackalope/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,33 @@ class NodeTest extends TestCase
{
protected $JSON = '{":jcr:primaryType":"Name","jcr:primaryType":"rep:root","jcr:system":{},"tests_level1_access_base":{}}';

public function testConstructor()
protected function createNode()
{
$factory = new \Jackalope\Factory;
$session = $this->getMock('Jackalope\Session', array(), array($factory), '', false);
$objectManager = $this->getMock('Jackalope\ObjectManager', array(), array($factory), '', false);
$node = new Node($factory, json_decode($this->JSON), '/jcr:node', $session, $objectManager);
$this->assertSame($session, $node->getSession());
return $node;
}

public function testConstructor()
{
$node = $this->createNode();
$this->assertType('Jackalope\Session', $node->getSession());
$this->assertType('jackalope\Node', $node);
//TODO: Activate this…
// $this->assertTrue($node->getPrimaryNodeType()->isNodeType('rep:root'));
$children = $node->getNodes();
$this->assertType('Iterator', $children);
$this->assertSame(2, count($children));
}

public function testNodeType()
{
$node = $this->createNode();
$this->assertTrue($node->isNodeType('rep:root'), "Should return true on is 'rep:root' node type.");
//TODO: Activate this…
// $this->assertTrue($node->getPrimaryNodeType()->isNodeType('rep:root'));
}

public function testFilterNames()
{
$filter = 'test';
Expand Down

0 comments on commit a4c9451

Please sign in to comment.