file = tmpfile(); fwrite($this->file, <<file); $tmpFilename = $metaData['uri']; $files = new FilesEntry($tmpFilename, $this->findPHP()); $classes = $files->getClasses($namespace, ClassFinder::ALLOW_CLASSES); $this->assertEquals($expected, $classes, 'FilesEntry should be able to determine the classes defined in a given file.'); } public function getClassesDataProvider() { return array( array( 'Foo\Bar', array( 'Foo\Bar\Foo', 'Foo\Bar\Bar' ) ), array( 'Baz', array( 'Baz\Boo' ) ), array( 'Stupid', array() ) ); } /** * @param $namespace * @param $expected * @dataProvider knowsNamespaceDataProvider */ public function testKnowsNamespace($namespace, $expected) { $metaData = stream_get_meta_data($this->file); $tmpFilename = $metaData['uri']; $files = new FilesEntry($tmpFilename, $this->findPHP()); $classes = $files->knowsNamespace($namespace); $this->assertEquals($expected, $classes, 'FilesEntry should be able to determine the classes defined in a given file.'); } public function knowsNamespaceDataProvider() { return array( array( 'Foo\Bar', true ), array( 'Foo', true ), array( 'Baz', true, ), array( 'Stupid', false ), array( 'Foobar', false ) ); } private function findPHP() { if (defined("PHP_BINARY")) { // PHP_BINARY was made available in PHP 5.4 $php = PHP_BINARY; } else { $isHostWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; if ($isHostWindows) { exec('where php', $output); $php = $output[0]; } else { exec('which php', $output); $php = $output[0]; } } return $php; } }