/
NodeTypeManagerTest.php
82 lines (69 loc) · 3.28 KB
/
NodeTypeManagerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace Jackalope\NodeType;
use Jackalope\TestCase;
class NodeTypeManagerTest extends TestCase
{
protected $ntm;
public function setUp() {
$this->ntm = $this->getNodeTypeManager();
}
/**
* @covers jackalope\NodeType\NodeTypeManager::getNodeType
*/
public function testGetNodeType() {
$nt = $this->ntm->getNodeType('nt:file');
$this->assertType('jackalope\NodeType\NodeType', $nt);
$this->assertSame('nt:file', $nt->getName());
$this->assertFalse($nt->isAbstract());
$this->assertFalse($nt->isMixin());
$this->assertFalse($nt->hasOrderableChildNodes());
$this->assertTrue($nt->isQueryable());
$this->assertSame('jcr:content', $nt->getPrimaryItemName());
}
/**
* @covers jackalope\NodeType\NodeTypeManager::getDeclaredSubtypes
* @covers jackalope\NodeType\NodeTypeManager::getSubtypes
*/
public function testTypeHierarchies() {
$nt = $this->ntm->getNodeType('nt:file');
$this->assertSame(array('nt:hierarchyNode'), $nt->getDeclaredSupertypeNames());
$this->assertSame(array(), $this->ntm->getDeclaredSubtypes('nt:file'));
$this->assertSame(array(), $this->ntm->getSubtypes('nt:file'));
$this->assertSame(array('nt:file', 'nt:folder', 'nt:linkedFile', 'rep:Authorizable', 'rep:AuthorizableFolder'), $this->ntm->getDeclaredSubtypes('nt:hierarchyNode'));
$this->assertSame(array('nt:file', 'nt:folder', 'nt:linkedFile', 'rep:Authorizable', 'rep:Group', 'rep:User', 'rep:AuthorizableFolder'), $this->ntm->getSubtypes('nt:hierarchyNode'));
}
/**
* @covers jackalope\NodeType\NodeTypeManager::hasNodeType
*/
public function testHasNodeType() {
$this->assertTrue($this->ntm->hasNodeType('nt:folder'), 'manager claimed to not know about nt:folder');
$this->assertFalse($this->ntm->hasNodeType('nonode'), 'manager claimed to know about nonode');
}
public function testCountTypeClasses() {
$allNodes = $this->ntm->getAllNodeTypes();
$this->assertType('Iterator', $allNodes);
$this->assertSame(52, count($allNodes));
$this->assertType('jackalope\NodeType\NodeType', $allNodes->current());
$primaryNodes = $this->ntm->getPrimaryNodeTypes();
$this->assertType('Iterator', $primaryNodes);
$this->assertSame(36, count($primaryNodes));
$this->assertType('jackalope\NodeType\NodeType', $primaryNodes->current());
$mixinNodes = $this->ntm->getMixinNodeTypes();
$this->assertType('Iterator', $mixinNodes);
$this->assertSame(16, count($mixinNodes));
$this->assertType('jackalope\NodeType\NodeType', $mixinNodes->current());
}
/**
* @covers jackalope\NodeType\NodeTypeManager::createNodeTypeTemplate
*/
public function testCreateNodeTypeTemplate() {
$ntm = $this->getNodeTypeManager();
$nt = $ntm->getNodeType('nt:file');
$ntt = $ntm->createNodeTypeTemplate($nt);
$this->assertThat($ntt, $this->isInstanceOf('\jackalope\NodeType\NodeTypeDefinition'));
$this->assertType('jackalope\NodeType\NodeTypeTemplate', $ntt);
$this->assertSame('nt:file', $ntt->getName());
$ntt->setName('nt:file-ext');
$this->assertSame('nt:file-ext', $ntt->getName());
}
}