@@ 305-340 (lines=36) @@ | ||
302 | } |
|
303 | } |
|
304 | ||
305 | public function testPrependTo() |
|
306 | { |
|
307 | // single root |
|
308 | $array=NestedSet::model()->findAll(); |
|
309 | $target=NestedSet::model()->findByPk(5); |
|
310 | $this->assertTrue($target instanceof NestedSet); |
|
311 | $nestedSet1=new NestedSet; |
|
312 | $this->assertFalse($nestedSet1->prependTo($target)); |
|
313 | $nestedSet1->name='test'; |
|
314 | $this->assertTrue($nestedSet1->prependTo($target)); |
|
315 | $this->assertTrue($this->checkTree()); |
|
316 | $array[]=$nestedSet1; |
|
317 | $nestedSet2=new NestedSet; |
|
318 | $nestedSet2->name='test'; |
|
319 | $this->assertTrue($nestedSet2->prependTo($target)); |
|
320 | $this->assertTrue($this->checkTree()); |
|
321 | $array[]=$nestedSet2; |
|
322 | $this->assertTrue($this->checkArray($array)); |
|
323 | ||
324 | // many roots |
|
325 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
326 | $target=NestedSetWithManyRoots::model()->findByPk(5); |
|
327 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
328 | $nestedSet1=new NestedSetWithManyRoots; |
|
329 | $this->assertFalse($nestedSet1->prependTo($target)); |
|
330 | $nestedSet1->name='test'; |
|
331 | $this->assertTrue($nestedSet1->prependTo($target)); |
|
332 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
333 | $array[]=$nestedSet1; |
|
334 | $nestedSet2=new NestedSetWithManyRoots; |
|
335 | $nestedSet2->name='test'; |
|
336 | $this->assertTrue($nestedSet2->prependTo($target)); |
|
337 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
338 | $array[]=$nestedSet2; |
|
339 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
340 | } |
|
341 | ||
342 | public function testAppendTo() |
|
343 | { |
|
@@ 342-377 (lines=36) @@ | ||
339 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
340 | } |
|
341 | ||
342 | public function testAppendTo() |
|
343 | { |
|
344 | // single root |
|
345 | $array=NestedSet::model()->findAll(); |
|
346 | $target=NestedSet::model()->findByPk(2); |
|
347 | $this->assertTrue($target instanceof NestedSet); |
|
348 | $nestedSet1=new NestedSet; |
|
349 | $this->assertFalse($nestedSet1->appendTo($target)); |
|
350 | $nestedSet1->name='test'; |
|
351 | $this->assertTrue($nestedSet1->appendTo($target)); |
|
352 | $this->assertTrue($this->checkTree()); |
|
353 | $array[]=$nestedSet1; |
|
354 | $nestedSet2=new NestedSet; |
|
355 | $nestedSet2->name='test'; |
|
356 | $this->assertTrue($nestedSet2->appendTo($target)); |
|
357 | $this->assertTrue($this->checkTree()); |
|
358 | $array[]=$nestedSet2; |
|
359 | $this->assertTrue($this->checkArray($array)); |
|
360 | ||
361 | // many roots |
|
362 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
363 | $target=NestedSetWithManyRoots::model()->findByPk(2); |
|
364 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
365 | $nestedSet1=new NestedSetWithManyRoots; |
|
366 | $this->assertFalse($nestedSet1->appendTo($target)); |
|
367 | $nestedSet1->name='test'; |
|
368 | $this->assertTrue($nestedSet1->appendTo($target)); |
|
369 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
370 | $array[]=$nestedSet1; |
|
371 | $nestedSet2=new NestedSetWithManyRoots; |
|
372 | $nestedSet2->name='test'; |
|
373 | $this->assertTrue($nestedSet2->appendTo($target)); |
|
374 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
375 | $array[]=$nestedSet2; |
|
376 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
377 | } |
|
378 | ||
379 | public function testInsertBefore() |
|
380 | { |
|
@@ 379-414 (lines=36) @@ | ||
376 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
377 | } |
|
378 | ||
379 | public function testInsertBefore() |
|
380 | { |
|
381 | // single root |
|
382 | $array=NestedSet::model()->findAll(); |
|
383 | $target=NestedSet::model()->findByPk(5); |
|
384 | $this->assertTrue($target instanceof NestedSet); |
|
385 | $nestedSet1=new NestedSet; |
|
386 | $this->assertFalse($nestedSet1->insertBefore($target)); |
|
387 | $nestedSet1->name='test'; |
|
388 | $this->assertTrue($nestedSet1->insertBefore($target)); |
|
389 | $this->assertTrue($this->checkTree()); |
|
390 | $array[]=$nestedSet1; |
|
391 | $nestedSet2=new NestedSet; |
|
392 | $nestedSet2->name='test'; |
|
393 | $this->assertTrue($nestedSet2->insertBefore($target)); |
|
394 | $this->assertTrue($this->checkTree()); |
|
395 | $array[]=$nestedSet2; |
|
396 | $this->assertTrue($this->checkArray($array)); |
|
397 | ||
398 | // many roots |
|
399 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
400 | $target=NestedSetWithManyRoots::model()->findByPk(5); |
|
401 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
402 | $nestedSet1=new NestedSetWithManyRoots; |
|
403 | $this->assertFalse($nestedSet1->insertBefore($target)); |
|
404 | $nestedSet1->name='test'; |
|
405 | $this->assertTrue($nestedSet1->insertBefore($target)); |
|
406 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
407 | $array[]=$nestedSet1; |
|
408 | $nestedSet2=new NestedSetWithManyRoots; |
|
409 | $nestedSet2->name='test'; |
|
410 | $this->assertTrue($nestedSet2->insertBefore($target)); |
|
411 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
412 | $array[]=$nestedSet2; |
|
413 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
414 | } |
|
415 | ||
416 | public function testInsertAfter() |
|
417 | { |
|
@@ 416-451 (lines=36) @@ | ||
413 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
414 | } |
|
415 | ||
416 | public function testInsertAfter() |
|
417 | { |
|
418 | // single root |
|
419 | $array=NestedSet::model()->findAll(); |
|
420 | $target=NestedSet::model()->findByPk(2); |
|
421 | $this->assertTrue($target instanceof NestedSet); |
|
422 | $nestedSet1=new NestedSet; |
|
423 | $this->assertFalse($nestedSet1->insertAfter($target)); |
|
424 | $nestedSet1->name='test'; |
|
425 | $this->assertTrue($nestedSet1->insertAfter($target)); |
|
426 | $this->assertTrue($this->checkTree()); |
|
427 | $array[]=$nestedSet1; |
|
428 | $nestedSet2=new NestedSet; |
|
429 | $nestedSet2->name='test'; |
|
430 | $this->assertTrue($nestedSet2->insertAfter($target)); |
|
431 | $this->assertTrue($this->checkTree()); |
|
432 | $array[]=$nestedSet2; |
|
433 | $this->assertTrue($this->checkArray($array)); |
|
434 | ||
435 | // many roots |
|
436 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
437 | $target=NestedSetWithManyRoots::model()->findByPk(2); |
|
438 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
439 | $nestedSet1=new NestedSetWithManyRoots; |
|
440 | $this->assertFalse($nestedSet1->insertAfter($target)); |
|
441 | $nestedSet1->name='test'; |
|
442 | $this->assertTrue($nestedSet1->insertAfter($target)); |
|
443 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
444 | $array[]=$nestedSet1; |
|
445 | $nestedSet2=new NestedSetWithManyRoots; |
|
446 | $nestedSet2->name='test'; |
|
447 | $this->assertTrue($nestedSet2->insertAfter($target)); |
|
448 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
449 | $array[]=$nestedSet2; |
|
450 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
451 | } |
|
452 | ||
453 | public function testMoveBefore() |
|
454 | { |