24 require_once(__DIR__ .
'/../../../common-dir.php');
26 class ItemTest extends \PHPUnit\Framework\TestCase
29 private $parentId = 432;
30 private $fileId = 123;
31 private $fileMode = 21;
32 private $fileName =
"<fileName>";
34 private $itemTreeBounds;
38 protected function setUp()
40 $this->itemTreeBounds = M::mock(ItemTreeBounds::class);
42 $this->item =
new Item($this->itemTreeBounds, $this->parentId, $this->fileId, $this->fileMode, $this->fileName);
45 protected function tearDown()
50 public function testGetId()
52 $this->itemTreeBounds->shouldReceive(
"getItemId")->once()->withNoArgs()->andReturn($this->
id);
54 assertThat($this->item->getId(), is($this->
id));
57 public function testGetParentId()
59 assertThat($this->item->getParentId(), is($this->parentId));
62 public function testGetFileMode()
64 assertThat($this->item->getFileMode(), is($this->fileMode));
67 public function testGetFileName()
69 assertThat($this->item->getFileName(), is($this->fileName));
72 public function testGetFileId()
74 assertThat($this->item->getFileId(), is($this->fileId));
77 public function testGetItemTreeBounds()
79 assertThat($this->item->getItemTreeBounds(), is($this->itemTreeBounds));
82 public function testContainsFileTreeItems()
84 $this->itemTreeBounds->shouldReceive(
"containsFiles")->withNoArgs()->andReturn(
true);
86 $this->assertTrue($this->item->containsFileTreeItems());
89 public function testDoesNotContainFileTreeItems()
91 $this->itemTreeBounds->shouldReceive(
"containsFiles")->withNoArgs()->andReturn(
false);
93 $this->assertFalse($this->item->containsFileTreeItems());
96 public function testHasParent()
98 $this->assertTrue($this->item->hasParent());
101 public function testHasNoParent()
103 $this->item =
new Item($this->itemTreeBounds, null, $this->fileId,
104 $this->fileMode, $this->fileName);
105 $this->assertFalse($this->item->hasParent());
108 public function testIsContainer()
110 $this->assertFalse($this->item->isContainer());
113 public function testIsFile()
115 $this->assertTrue($this->item->isFile());