/** * Collects tests. * * @return mixed * @throws Stagehand_TestRunner_Exception */ public function collect() { foreach ($this->config->testingResources as $testingResource) { $absoluteTargetPath = realpath($testingResource); if ($absoluteTargetPath === false) { throw new Stagehand_TestRunner_Exception('The directory or file [ ' . $testingResource . ' ] is not found'); } if (is_dir($absoluteTargetPath)) { $directoryScanner = new Stagehand_DirectoryScanner(array($this, 'collectTestCases')); $directoryScanner->setRecursivelyScans($this->config->recursivelyScans); $directoryScanner->scan($absoluteTargetPath); } else { $this->collectTestCasesFromFile($absoluteTargetPath); } } return $this->suite; }
/** * @test */ public function scanADirectoryNonRecursively() { $scanner = new Stagehand_DirectoryScanner(array($this, 'collectElements')); $scanner->setRecursivelyScans(false); $scanner->scan($this->scanDirectory); $this->assertEquals(2, count($this->elements)); $this->assertContains($this->scanDirectory . DIRECTORY_SEPARATOR . 'foo.txt', $this->elements); $this->assertContains($this->scanDirectory . DIRECTORY_SEPARATOR . 'bar', $this->elements); }