Total Complexity | 48 |
Total Lines | 1063 |
Duplicated Lines | 0 % |
Changes | 6 | ||
Bugs | 0 | Features | 0 |
Complex classes like DBNestedSetTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DBNestedSetTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
6 | class DBNestedSetTest extends \PHPUnit\Framework\TestCase |
||
7 | { |
||
8 | private static $dbm; |
||
9 | private $config; |
||
10 | |||
11 | |||
12 | public static function setUpBeforeClass() : void |
||
13 | { |
||
14 | self::$dbm = \TestHelper::getDBManager(); |
||
15 | $schema = new \Doctrine\DBAL\Schema\Schema(); |
||
16 | |||
17 | $table = $schema->createTable( 'mw_tree_test' ); |
||
18 | $table->addColumn( 'id', 'integer', array( 'autoincrement' => true ) ); |
||
19 | $table->addColumn( 'parentid', 'integer', array( 'notnull' => false ) ); |
||
20 | $table->addColumn( 'label', 'string', array( 'length' => 16 ) ); |
||
21 | $table->addColumn( 'code', 'string', array( 'length' => 32 ) ); |
||
22 | $table->addColumn( 'level', 'integer', [] ); |
||
23 | $table->addColumn( 'nleft', 'integer', [] ); |
||
24 | $table->addColumn( 'nright', 'integer', [] ); |
||
25 | $table->addColumn( 'status', 'smallint', [] ); |
||
26 | $table->setPrimaryKey( array( 'id' ) ); |
||
27 | |||
28 | $conn = self::$dbm->get(); |
||
29 | |||
30 | foreach( $schema->toSQL( $conn->getRawObject()->getDatabasePlatform() ) as $sql ) { |
||
31 | $conn->create( $sql )->execute()->finish(); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | |||
36 | public static function tearDownAfterClass() : void |
||
37 | { |
||
38 | $conn = self::$dbm->get(); |
||
39 | $conn->create( 'DROP TABLE "mw_tree_test"' )->execute()->finish(); |
||
40 | } |
||
41 | |||
42 | |||
43 | protected function setUp() : void |
||
144 | } |
||
145 | |||
146 | |||
147 | protected function tearDown() : void |
||
151 | } |
||
152 | |||
153 | |||
154 | public function testConstructorNoConfig() |
||
155 | { |
||
156 | $this->expectException( \Aimeos\MW\Tree\Exception::class ); |
||
157 | new \Aimeos\MW\Tree\Manager\DBNestedSet( [], self::$dbm->get() ); |
||
158 | } |
||
159 | |||
160 | |||
161 | public function testConstructorNoSqlConfig() |
||
162 | { |
||
163 | unset( $this->config['sql'] ); |
||
164 | |||
165 | $this->expectException( \Aimeos\MW\Tree\Exception::class ); |
||
166 | new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
167 | } |
||
168 | |||
169 | |||
170 | public function testConstructorMissingSqlConfig() |
||
176 | } |
||
177 | |||
178 | |||
179 | public function testConstructorMissingSearchConfig() |
||
180 | { |
||
181 | unset( $this->config['search']['id'] ); |
||
182 | |||
183 | $this->expectException( \Aimeos\MW\Tree\Exception::class ); |
||
184 | new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
185 | } |
||
186 | |||
187 | |||
188 | public function testGetSearchAttributes() |
||
189 | { |
||
190 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
191 | |||
192 | foreach( $manager->getSearchAttributes() as $attribute ) { |
||
193 | $this->assertInstanceOf( \Aimeos\Base\Criteria\Attribute\Iface::class, $attribute ); |
||
194 | } |
||
195 | } |
||
196 | |||
197 | |||
198 | public function testIsReadOnly() |
||
199 | { |
||
200 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
201 | |||
202 | $this->assertFalse( $manager->isReadOnly() ); |
||
203 | } |
||
204 | |||
205 | |||
206 | public function testCreateSearch() |
||
207 | { |
||
208 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
209 | |||
210 | $this->assertInstanceOf( \Aimeos\Base\Criteria\Iface::class, $manager->createSearch() ); |
||
211 | } |
||
212 | |||
213 | |||
214 | public function testSearchNodes() |
||
215 | { |
||
216 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
217 | $search = $manager->createSearch(); |
||
218 | |||
219 | |||
220 | $search->setConditions( $search->compare( '==', 'tree.level', 1 ) ); |
||
221 | $nodes = $manager->searchNodes( $search ); |
||
222 | |||
223 | $this->assertEquals( 3, count( $nodes ) ); |
||
224 | |||
225 | foreach( $nodes as $node ) { |
||
226 | $this->assertInstanceOf( \Aimeos\MW\Tree\Node\Iface::class, $node ); |
||
227 | } |
||
228 | |||
229 | |||
230 | if( ( $node = reset( $nodes ) ) === false ) { |
||
231 | throw new \RuntimeException( 'No node found' ); |
||
232 | } |
||
233 | |||
234 | $search->setConditions( $search->compare( '==', 'tree.level', 3 ) ); |
||
235 | $nodes = $manager->searchNodes( $search, $node->getId() ); |
||
236 | |||
237 | $this->assertEquals( 1, count( $nodes ) ); |
||
238 | |||
239 | foreach( $nodes as $node ) { |
||
240 | $this->assertInstanceOf( \Aimeos\MW\Tree\Node\Iface::class, $node ); |
||
241 | } |
||
242 | } |
||
243 | |||
244 | |||
245 | public function testSearchException() |
||
257 | } |
||
258 | |||
259 | |||
260 | public function testDeleteNode() |
||
261 | { |
||
262 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
263 | |||
264 | $search = $manager->createSearch(); |
||
265 | $search->setConditions( $search->compare( '==', 'tree.label', 'l2n2' ) ); |
||
266 | $nodes = $manager->searchNodes( $search ); |
||
267 | $this->assertEquals( 1, count( $nodes ) ); |
||
268 | |||
269 | $this->assertInstanceOf( \Aimeos\MW\Tree\Manager\Iface::class, $manager->deleteNode( reset( $nodes )->getId() ) ); |
||
270 | |||
271 | $search = $manager->createSearch(); |
||
272 | $nodes = $manager->searchNodes( $search ); |
||
273 | $this->assertEquals( 7, count( $nodes ) ); |
||
274 | } |
||
275 | |||
276 | |||
277 | public function testDeleteNodeException() |
||
278 | { |
||
279 | $this->config['sql']['search'] = ' |
||
280 | DELETE FROM "mw_tree_test" WHERE domain = ? AND nleft12 >= ? AND nright <= ? |
||
281 | '; |
||
282 | |||
283 | $this->expectException( \Aimeos\Base\DB\Exception::class ); |
||
284 | |||
285 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
286 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
287 | $manager->deleteNode( $root->getId() ); |
||
288 | } |
||
289 | |||
290 | |||
291 | public function testGetNode() |
||
292 | { |
||
293 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
294 | $search = $manager->createSearch(); |
||
295 | |||
296 | $node = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search ); |
||
297 | |||
298 | $this->assertEquals( 0, $node->level ); |
||
299 | $this->assertEquals( 0, count( $node->getChildren() ) ); |
||
300 | } |
||
301 | |||
302 | |||
303 | public function testGetNodeList() |
||
304 | { |
||
305 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
306 | |||
307 | $node = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
308 | $node = $manager->getNode( $node->getId(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); |
||
309 | |||
310 | $this->assertEquals( 3, count( $node->getChildren() ) ); |
||
311 | $this->assertEquals( 0, count( $node->getChild( 0 )->getChildren() ) ); |
||
312 | $this->assertEquals( 0, count( $node->getChild( 1 )->getChildren() ) ); |
||
313 | } |
||
314 | |||
315 | |||
316 | public function testGetNodeTree() |
||
317 | { |
||
318 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
319 | |||
320 | $node = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
321 | $node = $manager->getNode( $node->getId(), \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
322 | |||
323 | $this->assertEquals( 3, count( $node->getChildren() ) ); |
||
324 | $this->assertEquals( 1, count( $node->getChild( 0 )->getChildren() ) ); |
||
325 | $this->assertEquals( 1, count( $node->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
326 | $this->assertEquals( 1, count( $node->getChild( 1 )->getChildren() ) ); |
||
327 | $this->assertEquals( 2, count( $node->getChild( 1 )->getChild( 0 )->getChildren() ) ); |
||
328 | $this->assertEquals( 0, count( $node->getChild( 2 )->getChildren() ) ); |
||
329 | } |
||
330 | |||
331 | |||
332 | public function testGetNodeTreeCondition() |
||
333 | { |
||
334 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
335 | $filter = $manager->createSearch()->add( 'tree.status', '==', 1 ); |
||
336 | |||
337 | $node = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, $filter ); |
||
338 | |||
339 | $this->assertEquals( 3, count( $node->getChildren() ) ); |
||
340 | $this->assertEquals( 0, count( $node->getChild( 0 )->getChildren() ) ); |
||
341 | $this->assertEquals( 1, count( $node->getChild( 1 )->getChildren() ) ); |
||
342 | $this->assertEquals( 2, count( $node->getChild( 1 )->getChild( 0 )->getChildren() ) ); |
||
343 | $this->assertEquals( 0, count( $node->getChild( 2 )->getChildren() ) ); |
||
344 | } |
||
345 | |||
346 | |||
347 | public function testGetPath() |
||
348 | { |
||
349 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
350 | |||
351 | $nodes = []; |
||
352 | $nodes[0] = $manager->getNode(); |
||
353 | $nodes[1] = $nodes[0]->getChild( 1 ); |
||
354 | $nodes[2] = $nodes[1]->getChild( 0 ); |
||
355 | $nodes[3] = $nodes[2]->getChild( 1 ); |
||
356 | |||
357 | $path = $manager->getPath( (string) $nodes[3]->getId() ); |
||
358 | |||
359 | foreach( $nodes as $node ) |
||
360 | { |
||
361 | if( ( $actual = array_shift( $path ) ) === null ) { |
||
362 | throw new \RuntimeException( 'Not enough nodes in path' ); |
||
363 | } |
||
364 | |||
365 | $this->assertEquals( $node->getId(), $actual->getId() ); |
||
366 | } |
||
367 | } |
||
368 | |||
369 | |||
370 | public function testGetLevelFromConstantException() |
||
371 | { |
||
372 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
373 | |||
374 | $this->expectException( \Aimeos\MW\Tree\Exception::class ); |
||
375 | $manager->getNode( null, 0 ); |
||
376 | } |
||
377 | |||
378 | |||
379 | public function testInsertNode() |
||
380 | { |
||
381 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
382 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
383 | |||
384 | $newNode = $manager->createNode(); |
||
385 | $newNode->setLabel( 'l1n4' ); |
||
386 | $manager->insertNode( $newNode, $root->getId() ); |
||
387 | |||
388 | $root = $manager->getNode( $root->getId(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); |
||
389 | $this->assertEquals( 4, count( $root->getChildren() ) ); |
||
390 | $this->assertEquals( 'l1n4', $root->getChild( 3 )->getLabel() ); |
||
391 | $this->assertEquals( $newNode->getId(), $root->getChild( 3 )->getId() ); |
||
392 | |||
393 | $search = $manager->createSearch(); |
||
394 | $search->setConditions( $search->compare( '==', 'tree.label', 'l1n3' ) ); |
||
395 | $nodes = $manager->searchNodes( $search ); |
||
396 | $this->assertEquals( 1, count( $nodes ) ); |
||
397 | |||
398 | $newNode->setLabel( 'new l1n3' ); |
||
399 | $newNode = $manager->insertNode( $newNode, $root->getId(), reset( $nodes )->getId() ); |
||
|
|||
400 | |||
401 | $root = $manager->getNode( $root->getId(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); |
||
402 | $this->assertInstanceOf( \Aimeos\MW\Tree\Node\Iface::class, $newNode ); |
||
403 | $this->assertEquals( 5, count( $root->getChildren() ) ); |
||
404 | $this->assertEquals( 'l1n2', $root->getChild( 1 )->getLabel() ); |
||
405 | $this->assertEquals( 'new l1n3', $root->getChild( 2 )->getLabel() ); |
||
406 | $this->assertEquals( 'l1n3', $root->getChild( 3 )->getLabel() ); |
||
407 | $this->assertEquals( 'l1n4', $root->getChild( 4 )->getLabel() ); |
||
408 | } |
||
409 | |||
410 | |||
411 | public function testInsertNodeException() |
||
412 | { |
||
413 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
414 | $newNode = $manager->createNode(); |
||
415 | |||
416 | $this->expectException( \Aimeos\MW\Tree\Exception::class ); |
||
417 | $manager->insertNode( $newNode, -1 ); |
||
418 | } |
||
419 | |||
420 | |||
421 | public function testInsertNodeRoot() |
||
422 | { |
||
423 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
424 | |||
425 | $newNode = $manager->createNode(); |
||
426 | $newNode->setCode( 'root3' ); |
||
427 | $newNode->setLabel( 'Root 3' ); |
||
428 | |||
429 | $this->assertInstanceOf( \Aimeos\MW\Tree\Node\Iface::class, $manager->insertNode( $newNode ) ); |
||
430 | |||
431 | $root = $manager->getNode( $newNode->getId() ); |
||
432 | $this->assertEquals( 'Root 3', $root->getLabel() ); |
||
433 | $this->assertEquals( 21, $root->left ); |
||
434 | $this->assertEquals( 22, $root->right ); |
||
435 | } |
||
436 | |||
437 | |||
438 | public function testMoveNodeNoParent() |
||
439 | { |
||
440 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
441 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
442 | |||
443 | $nodeid = $root->getChild( 0 )->getChild( 0 )->getChild( 0 )->getId(); |
||
444 | $oldparentid = $root->getChild( 0 )->getChild( 0 )->getId(); |
||
445 | |||
446 | $result = $manager->moveNode( (string) $nodeid, $oldparentid, null ); |
||
447 | $this->assertInstanceOf( \Aimeos\MW\Tree\Manager\Iface::class, $result ); |
||
448 | |||
449 | $testroot = $manager->getNode( $nodeid, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
450 | |||
451 | $this->assertEquals( 0, $testroot->level ); |
||
452 | $this->assertEquals( 19, $testroot->left ); |
||
453 | $this->assertEquals( 20, $testroot->right ); |
||
454 | $this->assertEquals( 0, count( $testroot->getChildren() ) ); |
||
455 | } |
||
456 | |||
457 | |||
458 | public function testMoveNodeSameParent() |
||
459 | { |
||
460 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
461 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
462 | |||
463 | $nodeid = $root->getChild( 0 )->getId(); |
||
464 | $oldparentid = $root->getId(); |
||
465 | |||
466 | $manager->moveNode( (string) $nodeid, $oldparentid, $oldparentid ); |
||
467 | $manager->moveNode( (string) $nodeid, $oldparentid, $oldparentid ); |
||
468 | |||
469 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
470 | |||
471 | $this->assertEquals( 'l1n1', $testroot->getChild( 2 )->label ); |
||
472 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
473 | $this->assertEquals( 12, $testroot->getChild( 2 )->left ); |
||
474 | $this->assertEquals( 17, $testroot->getChild( 2 )->right ); |
||
475 | $this->assertEquals( 1, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
476 | } |
||
477 | |||
478 | |||
479 | public function testMoveNode1() |
||
480 | { |
||
481 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
482 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
483 | |||
484 | $nodeid = $root->getChild( 0 )->getChild( 0 )->getChild( 0 )->getId(); |
||
485 | $oldparentid = $root->getChild( 0 )->getChild( 0 )->getId(); |
||
486 | $newparentid = $root->getChild( 0 )->getId(); |
||
487 | $refnodeid = null; |
||
488 | |||
489 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
490 | |||
491 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
492 | |||
493 | $this->assertEquals( 0, $testroot->level ); |
||
494 | $this->assertEquals( 1, $testroot->left ); |
||
495 | $this->assertEquals( 18, $testroot->right ); |
||
496 | $this->assertEquals( 3, count( $testroot->getChildren() ) ); |
||
497 | |||
498 | $this->assertEquals( 1, $testroot->getChild( 0 )->level ); |
||
499 | $this->assertEquals( 2, $testroot->getChild( 0 )->left ); |
||
500 | $this->assertEquals( 7, $testroot->getChild( 0 )->right ); |
||
501 | $this->assertEquals( 2, count( $testroot->getChild( 0 )->getChildren() ) ); |
||
502 | |||
503 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 0 )->level ); |
||
504 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->left ); |
||
505 | $this->assertEquals( 4, $testroot->getChild( 0 )->getChild( 0 )->right ); |
||
506 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
507 | |||
508 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 1 )->level ); |
||
509 | $this->assertEquals( 5, $testroot->getChild( 0 )->getChild( 1 )->left ); |
||
510 | $this->assertEquals( 6, $testroot->getChild( 0 )->getChild( 1 )->right ); |
||
511 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 1 )->getChildren() ) ); |
||
512 | |||
513 | $this->assertEquals( 1, $testroot->getChild( 1 )->level ); |
||
514 | $this->assertEquals( 8, $testroot->getChild( 1 )->left ); |
||
515 | $this->assertEquals( 15, $testroot->getChild( 1 )->right ); |
||
516 | $this->assertEquals( 1, count( $testroot->getChild( 1 )->getChildren() ) ); |
||
517 | |||
518 | $this->assertEquals( 2, $testroot->getChild( 1 )->getChild( 0 )->level ); |
||
519 | $this->assertEquals( 9, $testroot->getChild( 1 )->getChild( 0 )->left ); |
||
520 | $this->assertEquals( 14, $testroot->getChild( 1 )->getChild( 0 )->right ); |
||
521 | $this->assertEquals( 2, count( $testroot->getChild( 1 )->getChild( 0 )->getChildren() ) ); |
||
522 | |||
523 | $this->assertEquals( 3, $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->level ); |
||
524 | $this->assertEquals( 10, $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->left ); |
||
525 | $this->assertEquals( 11, $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->right ); |
||
526 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
527 | |||
528 | $this->assertEquals( 3, $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->level ); |
||
529 | $this->assertEquals( 12, $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->left ); |
||
530 | $this->assertEquals( 13, $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->right ); |
||
531 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->getChildren() ) ); |
||
532 | |||
533 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
534 | $this->assertEquals( 16, $testroot->getChild( 2 )->left ); |
||
535 | $this->assertEquals( 17, $testroot->getChild( 2 )->right ); |
||
536 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
537 | } |
||
538 | |||
539 | |||
540 | public function testMoveNode2() |
||
541 | { |
||
542 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
543 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
544 | |||
545 | $nodeid = $root->getChild( 1 )->getChild( 0 )->getId(); |
||
546 | $oldparentid = $root->getChild( 1 )->getId(); |
||
547 | $newparentid = $root->getId(); |
||
548 | $refnodeid = $root->getChild( 1 )->getId(); |
||
549 | |||
550 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
551 | |||
552 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
553 | |||
554 | $this->assertEquals( 0, $testroot->level ); |
||
555 | $this->assertEquals( 1, $testroot->left ); |
||
556 | $this->assertEquals( 18, $testroot->right ); |
||
557 | $this->assertEquals( 4, count( $testroot->getChildren() ) ); |
||
558 | |||
559 | $this->assertEquals( 1, $testroot->getChild( 0 )->level ); |
||
560 | $this->assertEquals( 2, $testroot->getChild( 0 )->left ); |
||
561 | $this->assertEquals( 7, $testroot->getChild( 0 )->right ); |
||
562 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChildren() ) ); |
||
563 | |||
564 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 0 )->level ); |
||
565 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->left ); |
||
566 | $this->assertEquals( 6, $testroot->getChild( 0 )->getChild( 0 )->right ); |
||
567 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
568 | |||
569 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->level ); |
||
570 | $this->assertEquals( 4, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->left ); |
||
571 | $this->assertEquals( 5, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->right ); |
||
572 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
573 | |||
574 | $this->assertEquals( 1, $testroot->getChild( 1 )->level ); |
||
575 | $this->assertEquals( 8, $testroot->getChild( 1 )->left ); |
||
576 | $this->assertEquals( 13, $testroot->getChild( 1 )->right ); |
||
577 | $this->assertEquals( 2, count( $testroot->getChild( 1 )->getChildren() ) ); |
||
578 | |||
579 | $this->assertEquals( 2, $testroot->getChild( 1 )->getChild( 0 )->level ); |
||
580 | $this->assertEquals( 9, $testroot->getChild( 1 )->getChild( 0 )->left ); |
||
581 | $this->assertEquals( 10, $testroot->getChild( 1 )->getChild( 0 )->right ); |
||
582 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChild( 0 )->getChildren() ) ); |
||
583 | |||
584 | $this->assertEquals( 2, $testroot->getChild( 1 )->getChild( 1 )->level ); |
||
585 | $this->assertEquals( 11, $testroot->getChild( 1 )->getChild( 1 )->left ); |
||
586 | $this->assertEquals( 12, $testroot->getChild( 1 )->getChild( 1 )->right ); |
||
587 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChild( 1 )->getChildren() ) ); |
||
588 | |||
589 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
590 | $this->assertEquals( 14, $testroot->getChild( 2 )->left ); |
||
591 | $this->assertEquals( 15, $testroot->getChild( 2 )->right ); |
||
592 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
593 | |||
594 | $this->assertEquals( 1, $testroot->getChild( 3 )->level ); |
||
595 | $this->assertEquals( 16, $testroot->getChild( 3 )->left ); |
||
596 | $this->assertEquals( 17, $testroot->getChild( 3 )->right ); |
||
597 | $this->assertEquals( 0, count( $testroot->getChild( 3 )->getChildren() ) ); |
||
598 | } |
||
599 | |||
600 | |||
601 | public function testMoveNode3() |
||
602 | { |
||
603 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
604 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
605 | |||
606 | $nodeid = $root->getChild( 1 )->getChild( 0 )->getId(); |
||
607 | $oldparentid = $root->getChild( 1 )->getId(); |
||
608 | $newparentid = $root->getId(); |
||
609 | $refnodeid = $root->getChild( 2 )->getId(); |
||
610 | |||
611 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
612 | |||
613 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
614 | |||
615 | $this->assertEquals( 0, $testroot->level ); |
||
616 | $this->assertEquals( 1, $testroot->left ); |
||
617 | $this->assertEquals( 18, $testroot->right ); |
||
618 | $this->assertEquals( 4, count( $testroot->getChildren() ) ); |
||
619 | |||
620 | $this->assertEquals( 1, $testroot->getChild( 0 )->level ); |
||
621 | $this->assertEquals( 2, $testroot->getChild( 0 )->left ); |
||
622 | $this->assertEquals( 7, $testroot->getChild( 0 )->right ); |
||
623 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChildren() ) ); |
||
624 | |||
625 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 0 )->level ); |
||
626 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->left ); |
||
627 | $this->assertEquals( 6, $testroot->getChild( 0 )->getChild( 0 )->right ); |
||
628 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
629 | |||
630 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->level ); |
||
631 | $this->assertEquals( 4, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->left ); |
||
632 | $this->assertEquals( 5, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->right ); |
||
633 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
634 | |||
635 | $this->assertEquals( 1, $testroot->getChild( 1 )->level ); |
||
636 | $this->assertEquals( 8, $testroot->getChild( 1 )->left ); |
||
637 | $this->assertEquals( 9, $testroot->getChild( 1 )->right ); |
||
638 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChildren() ) ); |
||
639 | |||
640 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
641 | $this->assertEquals( 10, $testroot->getChild( 2 )->left ); |
||
642 | $this->assertEquals( 15, $testroot->getChild( 2 )->right ); |
||
643 | $this->assertEquals( 2, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
644 | |||
645 | $this->assertEquals( 2, $testroot->getChild( 2 )->getChild( 0 )->level ); |
||
646 | $this->assertEquals( 11, $testroot->getChild( 2 )->getChild( 0 )->left ); |
||
647 | $this->assertEquals( 12, $testroot->getChild( 2 )->getChild( 0 )->right ); |
||
648 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChild( 0 )->getChildren() ) ); |
||
649 | |||
650 | $this->assertEquals( 2, $testroot->getChild( 2 )->getChild( 1 )->level ); |
||
651 | $this->assertEquals( 13, $testroot->getChild( 2 )->getChild( 1 )->left ); |
||
652 | $this->assertEquals( 14, $testroot->getChild( 2 )->getChild( 1 )->right ); |
||
653 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChild( 1 )->getChildren() ) ); |
||
654 | |||
655 | $this->assertEquals( 1, $testroot->getChild( 3 )->level ); |
||
656 | $this->assertEquals( 16, $testroot->getChild( 3 )->left ); |
||
657 | $this->assertEquals( 17, $testroot->getChild( 3 )->right ); |
||
658 | $this->assertEquals( 0, count( $testroot->getChild( 3 )->getChildren() ) ); |
||
659 | } |
||
660 | |||
661 | |||
662 | public function testMoveNode4() |
||
663 | { |
||
664 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
665 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
666 | |||
667 | $nodeid = $root->getChild( 1 )->getChild( 0 )->getId(); |
||
668 | $oldparentid = $root->getChild( 1 )->getId(); |
||
669 | $newparentid = $root->getId(); |
||
670 | $refnodeid = null; |
||
671 | |||
672 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
673 | |||
674 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
675 | |||
676 | $this->assertEquals( 0, $testroot->level ); |
||
677 | $this->assertEquals( 1, $testroot->left ); |
||
678 | $this->assertEquals( 18, $testroot->right ); |
||
679 | $this->assertEquals( 4, count( $testroot->getChildren() ) ); |
||
680 | |||
681 | $this->assertEquals( 1, $testroot->getChild( 0 )->level ); |
||
682 | $this->assertEquals( 2, $testroot->getChild( 0 )->left ); |
||
683 | $this->assertEquals( 7, $testroot->getChild( 0 )->right ); |
||
684 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChildren() ) ); |
||
685 | |||
686 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 0 )->level ); |
||
687 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->left ); |
||
688 | $this->assertEquals( 6, $testroot->getChild( 0 )->getChild( 0 )->right ); |
||
689 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
690 | |||
691 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->level ); |
||
692 | $this->assertEquals( 4, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->left ); |
||
693 | $this->assertEquals( 5, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->right ); |
||
694 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
695 | |||
696 | $this->assertEquals( 1, $testroot->getChild( 1 )->level ); |
||
697 | $this->assertEquals( 8, $testroot->getChild( 1 )->left ); |
||
698 | $this->assertEquals( 9, $testroot->getChild( 1 )->right ); |
||
699 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChildren() ) ); |
||
700 | |||
701 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
702 | $this->assertEquals( 10, $testroot->getChild( 2 )->left ); |
||
703 | $this->assertEquals( 11, $testroot->getChild( 2 )->right ); |
||
704 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
705 | |||
706 | $this->assertEquals( 1, $testroot->getChild( 3 )->level ); |
||
707 | $this->assertEquals( 12, $testroot->getChild( 3 )->left ); |
||
708 | $this->assertEquals( 17, $testroot->getChild( 3 )->right ); |
||
709 | $this->assertEquals( 2, count( $testroot->getChild( 3 )->getChildren() ) ); |
||
710 | |||
711 | $this->assertEquals( 2, $testroot->getChild( 3 )->getChild( 0 )->level ); |
||
712 | $this->assertEquals( 13, $testroot->getChild( 3 )->getChild( 0 )->left ); |
||
713 | $this->assertEquals( 14, $testroot->getChild( 3 )->getChild( 0 )->right ); |
||
714 | $this->assertEquals( 0, count( $testroot->getChild( 3 )->getChild( 0 )->getChildren() ) ); |
||
715 | |||
716 | $this->assertEquals( 2, $testroot->getChild( 3 )->getChild( 1 )->level ); |
||
717 | $this->assertEquals( 15, $testroot->getChild( 3 )->getChild( 1 )->left ); |
||
718 | $this->assertEquals( 16, $testroot->getChild( 3 )->getChild( 1 )->right ); |
||
719 | $this->assertEquals( 0, count( $testroot->getChild( 3 )->getChild( 1 )->getChildren() ) ); |
||
720 | } |
||
721 | |||
722 | |||
723 | public function testMoveNode5() |
||
724 | { |
||
725 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
726 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
727 | |||
728 | $nodeid = $root->getChild( 1 )->getChild( 0 )->getId(); |
||
729 | $oldparentid = $root->getChild( 1 )->getId(); |
||
730 | $newparentid = $root->getChild( 2 )->getId(); |
||
731 | $refnodeid = null; |
||
732 | |||
733 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
734 | |||
735 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
736 | |||
737 | $this->assertEquals( 0, $testroot->level ); |
||
738 | $this->assertEquals( 1, $testroot->left ); |
||
739 | $this->assertEquals( 18, $testroot->right ); |
||
740 | $this->assertEquals( 3, count( $testroot->getChildren() ) ); |
||
741 | |||
742 | $this->assertEquals( 1, $testroot->getChild( 0 )->level ); |
||
743 | $this->assertEquals( 2, $testroot->getChild( 0 )->left ); |
||
744 | $this->assertEquals( 7, $testroot->getChild( 0 )->right ); |
||
745 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChildren() ) ); |
||
746 | |||
747 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 0 )->level ); |
||
748 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->left ); |
||
749 | $this->assertEquals( 6, $testroot->getChild( 0 )->getChild( 0 )->right ); |
||
750 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
751 | |||
752 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->level ); |
||
753 | $this->assertEquals( 4, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->left ); |
||
754 | $this->assertEquals( 5, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->right ); |
||
755 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
756 | |||
757 | $this->assertEquals( 1, $testroot->getChild( 1 )->level ); |
||
758 | $this->assertEquals( 8, $testroot->getChild( 1 )->left ); |
||
759 | $this->assertEquals( 9, $testroot->getChild( 1 )->right ); |
||
760 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChildren() ) ); |
||
761 | |||
762 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
763 | $this->assertEquals( 10, $testroot->getChild( 2 )->left ); |
||
764 | $this->assertEquals( 17, $testroot->getChild( 2 )->right ); |
||
765 | $this->assertEquals( 1, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
766 | |||
767 | $this->assertEquals( 2, $testroot->getChild( 2 )->getChild( 0 )->level ); |
||
768 | $this->assertEquals( 11, $testroot->getChild( 2 )->getChild( 0 )->left ); |
||
769 | $this->assertEquals( 16, $testroot->getChild( 2 )->getChild( 0 )->right ); |
||
770 | $this->assertEquals( 2, count( $testroot->getChild( 2 )->getChild( 0 )->getChildren() ) ); |
||
771 | |||
772 | $this->assertEquals( 3, $testroot->getChild( 2 )->getChild( 0 )->getChild( 0 )->level ); |
||
773 | $this->assertEquals( 12, $testroot->getChild( 2 )->getChild( 0 )->getChild( 0 )->left ); |
||
774 | $this->assertEquals( 13, $testroot->getChild( 2 )->getChild( 0 )->getChild( 0 )->right ); |
||
775 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
776 | |||
777 | $this->assertEquals( 3, $testroot->getChild( 2 )->getChild( 0 )->getChild( 1 )->level ); |
||
778 | $this->assertEquals( 14, $testroot->getChild( 2 )->getChild( 0 )->getChild( 1 )->left ); |
||
779 | $this->assertEquals( 15, $testroot->getChild( 2 )->getChild( 0 )->getChild( 1 )->right ); |
||
780 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChild( 0 )->getChild( 1 )->getChildren() ) ); |
||
781 | } |
||
782 | |||
783 | |||
784 | public function testMoveNode6() |
||
853 | } |
||
854 | |||
855 | |||
856 | public function testMoveNode7() |
||
857 | { |
||
858 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
859 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
860 | |||
861 | $nodeid = $root->getChild( 1 )->getChild( 0 )->getId(); |
||
862 | $oldparentid = $root->getChild( 1 )->getId(); |
||
863 | $newparentid = $root->getId(); |
||
864 | $refnodeid = $root->getChild( 1 )->getId(); |
||
865 | |||
866 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
867 | |||
868 | |||
869 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
870 | |||
871 | $nodeid = $root->getChild( 1 )->getId(); |
||
872 | $oldparentid = $root->getId(); |
||
873 | $newparentid = $root->getChild( 2 )->getId(); |
||
874 | $refnodeid = null; |
||
875 | |||
876 | $manager->moveNode( $nodeid, $oldparentid, $newparentid, $refnodeid ); |
||
877 | |||
878 | |||
879 | $testroot = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
880 | |||
881 | $this->assertEquals( 0, $testroot->level ); |
||
882 | $this->assertEquals( 1, $testroot->left ); |
||
883 | $this->assertEquals( 18, $testroot->right ); |
||
884 | $this->assertEquals( 3, count( $testroot->getChildren() ) ); |
||
885 | |||
886 | $this->assertEquals( 1, $testroot->getChild( 0 )->level ); |
||
887 | $this->assertEquals( 2, $testroot->getChild( 0 )->left ); |
||
888 | $this->assertEquals( 7, $testroot->getChild( 0 )->right ); |
||
889 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChildren() ) ); |
||
890 | |||
891 | $this->assertEquals( 2, $testroot->getChild( 0 )->getChild( 0 )->level ); |
||
892 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->left ); |
||
893 | $this->assertEquals( 6, $testroot->getChild( 0 )->getChild( 0 )->right ); |
||
894 | $this->assertEquals( 1, count( $testroot->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
895 | |||
896 | $this->assertEquals( 3, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->level ); |
||
897 | $this->assertEquals( 4, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->left ); |
||
898 | $this->assertEquals( 5, $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->right ); |
||
899 | $this->assertEquals( 0, count( $testroot->getChild( 0 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
900 | |||
901 | $this->assertEquals( 1, $testroot->getChild( 1 )->level ); |
||
902 | $this->assertEquals( 8, $testroot->getChild( 1 )->left ); |
||
903 | $this->assertEquals( 15, $testroot->getChild( 1 )->right ); |
||
904 | $this->assertEquals( 1, count( $testroot->getChild( 1 )->getChildren() ) ); |
||
905 | |||
906 | $this->assertEquals( 2, $testroot->getChild( 1 )->getChild( 0 )->level ); |
||
907 | $this->assertEquals( 9, $testroot->getChild( 1 )->getChild( 0 )->left ); |
||
908 | $this->assertEquals( 14, $testroot->getChild( 1 )->getChild( 0 )->right ); |
||
909 | $this->assertEquals( 2, count( $testroot->getChild( 1 )->getChild( 0 )->getChildren() ) ); |
||
910 | |||
911 | $this->assertEquals( 3, $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->level ); |
||
912 | $this->assertEquals( 10, $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->left ); |
||
913 | $this->assertEquals( 11, $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->right ); |
||
914 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChild( 0 )->getChild( 0 )->getChildren() ) ); |
||
915 | |||
916 | $this->assertEquals( 3, $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->level ); |
||
917 | $this->assertEquals( 12, $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->left ); |
||
918 | $this->assertEquals( 13, $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->right ); |
||
919 | $this->assertEquals( 0, count( $testroot->getChild( 1 )->getChild( 0 )->getChild( 1 )->getChildren() ) ); |
||
920 | |||
921 | $this->assertEquals( 1, $testroot->getChild( 2 )->level ); |
||
922 | $this->assertEquals( 16, $testroot->getChild( 2 )->left ); |
||
923 | $this->assertEquals( 17, $testroot->getChild( 2 )->right ); |
||
924 | $this->assertEquals( 0, count( $testroot->getChild( 2 )->getChildren() ) ); |
||
925 | } |
||
926 | |||
927 | |||
928 | public function testMoveNode8() |
||
987 | } |
||
988 | |||
989 | |||
990 | public function testMoveNodeException() |
||
991 | { |
||
992 | $this->config['sql']['move-left'] = ' |
||
993 | UPDATE "mw_tree_test" |
||
994 | SET nleft123 = nleft + ?, level = level + ? |
||
995 | WHERE nleft >= ? AND nleft <= ? |
||
996 | '; |
||
997 | |||
998 | $this->config['sql']['move-right'] = ' |
||
999 | UPDATE "mw_tree_test" |
||
1000 | SET nright123 = nright + ? |
||
1001 | WHERE nright >= ? AND nright <= ? |
||
1002 | '; |
||
1003 | |||
1004 | |||
1005 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
1006 | |||
1007 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
||
1008 | |||
1009 | $nodeid = $root->getChild( 1 )->getId(); |
||
1010 | $oldparentid = $root->getId(); |
||
1011 | $newparentid = $root->getChild( 0 )->getId(); |
||
1012 | |||
1013 | $this->expectException( \Aimeos\Base\DB\Exception::class ); |
||
1014 | $manager->moveNode( (string) $nodeid, $oldparentid, $newparentid ); |
||
1015 | } |
||
1016 | |||
1017 | |||
1018 | public function testSaveNode() |
||
1029 | } |
||
1030 | |||
1031 | |||
1032 | public function testSaveNodeException() |
||
1033 | { |
||
1034 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
1035 | $node = $manager->createNode(); |
||
1036 | |||
1037 | $this->expectException( \Aimeos\MW\Tree\Exception::class ); |
||
1038 | $manager->saveNode( $node ); |
||
1039 | } |
||
1040 | |||
1041 | |||
1042 | public function testSaveNodeException2() |
||
1043 | { |
||
1044 | $this->config['sql']['update'] = ' |
||
1045 | UPDATE "mw_tree_test" SET label123 = ?, status = ? WHERE id = ? |
||
1046 | '; |
||
1047 | |||
1048 | $manager = new \Aimeos\MW\Tree\Manager\DBNestedSet( $this->config, self::$dbm->get() ); |
||
1049 | $root = $manager->getNode( null, \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
1050 | |||
1051 | $root->setLabel( 'rooot' ); |
||
1052 | |||
1053 | $this->expectException( \Aimeos\Base\DB\Exception::class ); |
||
1054 | $manager->saveNode( $root ); |
||
1055 | } |
||
1056 | |||
1057 | |||
1058 | public function testSetReadOnly() |
||
1069 | } |
||
1070 | |||
1071 | } |
||
1072 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.