Skip to content

Commit b1e119c

Browse files
harm-lessharm-less
authored andcommitted
Requirements bugfixes
1 parent 7b046e6 commit b1e119c

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/FQ/query/FilesQueryRequirements.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ protected function requirementLast(FilesQuery $query) {
214214
}
215215

216216
if (!$oneExists) {
217+
var_dump($lastRootDirId);
217218
if ($lastRootDirId === null) {
218219
return new FileQueryRequirementsException('Query requires at least one file to exist in at least one child directory, but there isn\'t even a root directory. Make sure you have at least one root directory in your query');
219220
}

tests/FQ/Tests/Query/FilesQueryRequirementsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ public function testRequirementLastSuccess() {
164164
$success = $this->callNonPublicMethod('requirementLast', array($this->query()));
165165
$this->assertTrue($success);
166166
}
167+
public function testRequirementLastFailureNoRootDir() {
168+
$this->setExpectedException('\FQ\Exceptions\FileQueryRequirementsException', 'Query requires at least one file to exist in at least one child directory, but there isn\'t even a root directory. Make sure you have at least one root directory in your query');
169+
$this->query()->getRootDirSelection()->excludeDirById(self::ROOT_DIR_DEFAULT_ID);
170+
$this->runQuery();
171+
$this->callNonPublicMethod('requirementLast', array($this->query()));
172+
}
167173
public function testRequirementLastFailure() {
168174
$this->setExpectedException('\FQ\Exceptions\FileQueryRequirementsException');
169175
$this->files()->addRootDir($this->_newActualRootDirSecond());

tests/FQ/Tests/Query/FilesQueryTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,40 @@ public function testListBasePathsWithReversedSetToTrue() {
220220
}
221221
$index++;
222222
}
223+
224+
$rawPaths = $query->listRawPaths();
225+
$index = 0;
226+
foreach ($paths as $rootDirId => $path) {
227+
if ($index === 0) {
228+
$this->assertEquals(self::ROOT_DIR_DEFAULT_ID, $rootDirId);
229+
$this->assertEquals(self::ROOT_DIR_DEFAULT_BASE_PATH . '/child1/File1.php', $path);
230+
}
231+
else if ($index === 1) {
232+
$this->assertEquals(self::ROOT_DIR_SECOND_ID, $rootDirId);
233+
$this->assertEquals(self::ROOT_DIR_SECOND_BASE_PATH . '/child1/File1.php', $path);
234+
}
235+
$index++;
236+
}
237+
}
238+
239+
public function testListRawPathsWithReversedSetToTrue() {
240+
$this->files()->addRootDir($this->_newActualRootDirSecond());
241+
$query = $this->query();
242+
$query->reverse(true);
243+
$this->runQuery('File1');
244+
$rawPaths = $query->listRawPaths();
245+
$index = 0;
246+
foreach ($rawPaths as $rootDirId => $path) {
247+
if ($index === 0) {
248+
$this->assertEquals(self::ROOT_DIR_DEFAULT_ID, $rootDirId);
249+
$this->assertEquals(self::ROOT_DIR_DEFAULT_ABSOLUTE_PATH . '/child1/File1.php', $path);
250+
}
251+
else if ($index === 1) {
252+
$this->assertEquals(self::ROOT_DIR_SECOND_ID, $rootDirId);
253+
$this->assertEquals(self::ROOT_DIR_SECOND_ABSOLUTE_PATH . '/child1/File1.php', $path);
254+
}
255+
$index++;
256+
}
223257
}
224258

225259
public function testHasPathsWhenQueryHasNotRan() {

0 commit comments

Comments
 (0)