|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @copyright Copyright (C) Ibexa AS. All rights reserved. |
| 5 | + * @license For full copyright and license information view LICENSE file distributed with this source code. |
| 6 | + */ |
| 7 | +declare(strict_types=1); |
| 8 | + |
| 9 | +namespace Ibexa\Tests\AdminUi\Form\Data; |
| 10 | + |
| 11 | +use Ibexa\AdminUi\Form\Data\TrashItemData; |
| 12 | +use Ibexa\Core\Repository\Values\Content\Location; |
| 13 | +use Ibexa\Core\Repository\Values\Content\TrashItem; |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | + |
| 16 | +final class TrashItemDataTest extends TestCase |
| 17 | +{ |
| 18 | + public function testIsParentInTrashReturnsFalseWhenNoAncestors(): void |
| 19 | + { |
| 20 | + $trashItem = new TrashItem(['path' => ['1', '2', '3'], 'id' => 3]); |
| 21 | + $data = new TrashItemData($trashItem, null, []); |
| 22 | + |
| 23 | + self::assertFalse($data->isParentInTrash()); |
| 24 | + } |
| 25 | + |
| 26 | + public function testIsParentInTrashReturnsFalseWhenPathsMatch(): void |
| 27 | + { |
| 28 | + $trashItem = new TrashItem(['path' => ['1', '2', '3'], 'id' => 3]); |
| 29 | + |
| 30 | + $ancestor = new Location(['path' => ['1', '2']]); |
| 31 | + $data = new TrashItemData($trashItem, null, [$ancestor]); |
| 32 | + |
| 33 | + self::assertFalse($data->isParentInTrash()); |
| 34 | + } |
| 35 | + |
| 36 | + public function testIsParentInTrashReturnsTrueWhenPathsDoNotMatch(): void |
| 37 | + { |
| 38 | + $trashItem = new TrashItem(['path' => ['1', '2', '3'], 'id' => 3]); |
| 39 | + $ancestor = new Location(['path' => ['1']]); |
| 40 | + |
| 41 | + $data = new TrashItemData($trashItem, null, [$ancestor]); |
| 42 | + |
| 43 | + self::assertTrue($data->isParentInTrash()); |
| 44 | + } |
| 45 | + |
| 46 | + public function testIsParentInTrashWithMultipleAncestors(): void |
| 47 | + { |
| 48 | + $trashItem = new TrashItem(['path' => ['1', '2', '3', '4'], 'id' => 4]); |
| 49 | + |
| 50 | + $ancestor1 = new Location(['path' => ['1']]); |
| 51 | + $ancestor2 = new Location(['path' => ['1', '2', '3']]); |
| 52 | + |
| 53 | + $data = new TrashItemData($trashItem, null, [$ancestor1, $ancestor2]); |
| 54 | + |
| 55 | + self::assertFalse($data->isParentInTrash()); |
| 56 | + } |
| 57 | +} |
0 commit comments