Skip to content

Commit a0bb906

Browse files
harm-lessharm-less
authored andcommitted
Added tests for FilesQueryChild
1 parent c46a568 commit a0bb906

File tree

2 files changed

+68
-9
lines changed

2 files changed

+68
-9
lines changed

src/FQ/query/FilesQueryChild.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,8 @@ class FilesQueryChild {
6363
function __construct(FilesQuery $filesQuery, ChildDir $childDir) {
6464
$this->_filesQuery = $filesQuery;
6565
$this->_childDir = $childDir;
66-
}
6766

68-
public function setRootDirs($dirs) {
69-
$this->_rootDirs = $dirs;
70-
}
71-
public function getRootDirs() {
72-
if ($this->_rootDirs === null) {
73-
return array();
74-
}
75-
return $this->_rootDirs;
67+
$this->reset();
7668
}
7769

7870
/**
@@ -91,6 +83,16 @@ public function reset() {
9183
$this->_filteredBasePaths = null;
9284
}
9385

86+
public function setRootDirs($dirs) {
87+
$this->_rootDirs = $dirs;
88+
}
89+
public function getRootDirs() {
90+
if ($this->_rootDirs === null) {
91+
return array();
92+
}
93+
return $this->_rootDirs;
94+
}
95+
9496
/**
9597
* @return FilesQuery
9698
*/
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace FQ\Tests\Query;
4+
5+
use FQ\Query\FilesQueryChild;
6+
use FQ\Query\FilesQueryRequirements;
7+
8+
class FilesQueryChildTest extends AbstractFilesQueryTests {
9+
10+
11+
protected function setUp()
12+
{
13+
parent::setUp();
14+
15+
$this->nonPublicMethodObject($this->queryChild());
16+
}
17+
18+
public function testConstructor()
19+
{
20+
$filesQueryChild = new FilesQueryChild($this->query(), $this->_newActualChildDir());
21+
$this->assertNotNull($filesQueryChild);
22+
}
23+
24+
public function testReset() {
25+
$queryChild = $this->queryChild();
26+
$queryChild->reset();
27+
}
28+
29+
public function testSetRootDirs() {
30+
$firstRootDir = $this->_newActualRootDir();
31+
$secondRootDir = $this->_newActualRootDirSecond();
32+
$queryChild = $this->queryChild();
33+
$queryChild->setRootDirs(array($firstRootDir, $secondRootDir));
34+
$this->assertEquals(array($firstRootDir, $secondRootDir), $queryChild->getRootDirs());
35+
}
36+
37+
public function testGetRootDirsEmpty() {
38+
$queryChild = $this->queryChild();
39+
$queryChild->setRootDirs(null);
40+
$this->assertEquals(array(), $queryChild->getRootDirs());
41+
}
42+
43+
public function testQuery() {
44+
$queryChild = $this->queryChild();
45+
$this->assertTrue(is_a($queryChild->query(), 'FQ\Query\FilesQuery'));
46+
}
47+
48+
public function testFiles() {
49+
$queryChild = $this->queryChild();
50+
$this->assertTrue(is_a($queryChild->Files(), 'FQ\Files'));
51+
}
52+
53+
public function testChildDir() {
54+
$queryChild = $this->queryChild();
55+
$this->assertTrue(is_a($queryChild->childDir(), 'FQ\Dirs\ChildDir'));
56+
}
57+
}

0 commit comments

Comments
 (0)