1 | <?php |
||
10 | abstract class AbstractScopeTest extends IntegrationTestCase |
||
11 | { |
||
12 | /** |
||
13 | * @var TreeAdapter |
||
14 | */ |
||
15 | protected $treeAdapter; |
||
16 | |||
17 | protected function setUp() |
||
18 | { |
||
19 | $this->treeAdapter = $this->getTreeAdapter(); |
||
20 | |||
21 | parent::setUp(); |
||
22 | } |
||
23 | |||
24 | protected function tearDown() |
||
25 | { |
||
26 | $this->treeAdapter = null; |
||
27 | parent::tearDown(); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return TreeAdapter |
||
32 | */ |
||
33 | abstract protected function getTreeAdapter(); |
||
34 | |||
35 | protected function getDataSet() |
||
36 | { |
||
37 | switch ($this->getName()) { |
||
38 | case 'testValidateTreeRaiseExceptionIfIdParentIdIsBroken': |
||
39 | return $this->createMySQLXMLDataSet(__DIR__.'/_files/NestedSet/with_scope/initDataSetBrokenParents.xml'); |
||
40 | case 'testInvalidTree': |
||
41 | case 'testRebuildTree': |
||
42 | return $this->createMySQLXMLDataSet(__DIR__.'/_files/NestedSet/with_scope/initDataSetBrokenTreeIndexes.xml'); |
||
43 | default: |
||
44 | return $this->createMySQLXMLDataSet(__DIR__.'/_files/NestedSet/with_scope/initDataSet.xml'); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | public function testCreateRoot() |
||
49 | { |
||
50 | $this->treeAdapter |
||
51 | ->createRootNode(array(), 10); |
||
52 | |||
53 | $this->assertCompareDataSet(array('tree_traversal_with_scope'), __DIR__.'/_files/NestedSet/with_scope/testCreateRoot.xml'); |
||
54 | } |
||
55 | |||
56 | public function testCreateRootRootWithSomeScopeAlreadyExist() |
||
57 | { |
||
58 | $this->expectException(\StefanoTree\Exception\ValidationException::class); |
||
59 | $this->expectExceptionMessage('Root node for given scope already exist'); |
||
60 | |||
61 | $this->treeAdapter |
||
62 | ->createRootNode(array(), 123); |
||
63 | $this->treeAdapter |
||
64 | ->createRootNode(array(), 123); |
||
65 | } |
||
66 | |||
67 | public function testGetRoots() |
||
95 | |||
96 | public function testAddNodePlacementChildTopDefaultPlacement() |
||
97 | { |
||
98 | $lastGeneratedValue = $this->treeAdapter |
||
99 | ->addNode(1); |
||
100 | |||
101 | $this->assertCompareDataSet(array('tree_traversal_with_scope'), __DIR__.'/_files/NestedSet/with_scope/testAddNodePlacementChildTop.xml'); |
||
104 | |||
105 | public function testMoveNodePlacementBottom() |
||
112 | |||
113 | public function testCannotMoveNodeBetweenScopes() |
||
121 | |||
122 | public function testDeleteBranch() |
||
129 | |||
130 | public function testGetDescendants() |
||
177 | |||
178 | public function testGetPath() |
||
214 | |||
215 | public function testUpdateCannotCorruptTreeStructure() |
||
241 | |||
242 | public function testIsTreeValid() |
||
246 | |||
247 | public function testInvalidTree() |
||
251 | |||
252 | public function testValidateTreeGivenNodeIdIsNotRoot() |
||
259 | |||
260 | public function testRebuildTree() |
||
267 | |||
268 | public function testRebuildTreeGivenNodeIdIsNotRoot() |
||
275 | |||
276 | public function testIsValidTreeGivenNodeIdIsNotRoot() |
||
283 | |||
284 | public function testRebuildTreeGivenNodeIdDoesNotExists() |
||
291 | |||
292 | public function testIsValidTreeGivenNodeIdDoesNotExists() |
||
299 | } |
||
300 |