本文整理匯總了PHP中PHPUnit_Util_Filesystem::classNameToFilename方法的典型用法代碼示例。如果您正苦於以下問題:PHP PHPUnit_Util_Filesystem::classNameToFilename方法的具體用法?PHP PHPUnit_Util_Filesystem::classNameToFilename怎麽用?PHP PHPUnit_Util_Filesystem::classNameToFilename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHPUnit_Util_Filesystem
的用法示例。
在下文中一共展示了PHPUnit_Util_Filesystem::classNameToFilename方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: load
/**
* @param string $suiteClassName
* @param string $suiteClassFile
* @return ReflectionClass
* @throws PHPUnit_Framework_Exception
*/
public function load($suiteClassName, $suiteClassFile = '')
{
$suiteClassName = str_replace('.php', '', $suiteClassName);
if (empty($suiteClassFile)) {
$suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename($suiteClassName);
}
Core_FileReader::addFile($suiteClassFile);
}
示例2: load
/**
* @param string $suiteClassName
* @param string $suiteClassFile
* @return ReflectionClass
* @throws RuntimeException
*/
public function load($suiteClassName, $suiteClassFile = '')
{
$suiteClassName = str_replace('.php', '', $suiteClassName);
if (empty($suiteClassFile)) {
$suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename($suiteClassName);
}
if (!class_exists($suiteClassName, FALSE)) {
PHPUnit_Util_Class::collectStart();
$filename = PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile);
$loadedClasses = PHPUnit_Util_Class::collectEnd();
}
if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
$offset = 0 - strlen($suiteClassName);
foreach ($loadedClasses as $loadedClass) {
$class = new ReflectionClass($loadedClass);
if (substr($loadedClass, $offset) === $suiteClassName && $class->getFileName() == $filename) {
$suiteClassName = $loadedClass;
break;
}
}
}
if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
$testCaseClass = 'PHPUnit_Framework_TestCase';
foreach ($loadedClasses as $loadedClass) {
$class = new ReflectionClass($loadedClass);
$classFile = $class->getFileName();
if ($class->isSubclassOf($testCaseClass) && !$class->isAbstract()) {
$suiteClassName = $loadedClass;
$testCaseClass = $loadedClass;
if ($classFile == realpath($suiteClassFile)) {
break;
}
}
if ($class->hasMethod('suite')) {
$method = $class->getMethod('suite');
if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) {
$suiteClassName = $loadedClass;
if ($classFile == realpath($suiteClassFile)) {
break;
}
}
}
}
}
if (class_exists($suiteClassName, FALSE)) {
$class = new ReflectionClass($suiteClassName);
$filePath = $GLOBALS['base_dir'] . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . $suiteClassFile;
if ($class->getFileName() == realpath($filePath)) {
return $class;
}
}
throw new PHPUnit_Framework_Exception(sprintf('Class %s could not be found in %s.', $suiteClassName, $suiteClassFile));
}
示例3: load
/**
*
* @param string $suiteClassName
* @param string $suiteClassFile
*
* @return ReflectionClass
*
* @throws PHPUnit_Framework_Exception
*/
public function load($suiteClassName, $suiteClassFile = '')
{
$suiteClassName = str_replace('.php', '', $suiteClassName);
if (empty($suiteClassFile)) {
$suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename($suiteClassName);
}
if (!class_exists($suiteClassName, false)) {
$loadedClasses = get_declared_classes();
$filename = PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile);
$loadedClasses = array_values(array_diff(get_declared_classes(), $loadedClasses));
}
if (!class_exists($suiteClassName, false) && !empty($loadedClasses)) {
$offset = 0 - strlen($suiteClassName);
foreach ($loadedClasses as $loadedClass) {
$class = new ReflectionClass($loadedClass);
if (substr($loadedClass, $offset) === $suiteClassName && $class->getFileName() == $filename) {
$suiteClassName = $loadedClass;
break;
}
}
}
if (!class_exists($suiteClassName, false) && !empty($loadedClasses)) {
$testCaseClass = 'PHPUnit_Framework_TestCase';
foreach ($loadedClasses as $loadedClass) {
$class = new ReflectionClass($loadedClass);
$classFile = $class->getFileName();
if ($class->isSubclassOf($testCaseClass) && !$class->isAbstract()) {
$suiteClassName = $loadedClass;
$testCaseClass = $loadedClass;
if ($classFile == realpath($suiteClassFile)) {
break;
}
}
if ($class->hasMethod('suite')) {
$method = $class->getMethod('suite');
if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) {
$suiteClassName = $loadedClass;
if ($classFile == realpath($suiteClassFile)) {
break;
}
}
}
}
}
if (class_exists($suiteClassName, false)) {
$class = new ReflectionClass($suiteClassName);
if ($class->getFileName() == realpath($suiteClassFile)) {
return $class;
}
}
throw new PHPUnit_Framework_Exception(sprintf("Class '%s' could not be found in '%s'.", $suiteClassName, $suiteClassFile));
}
示例4: __construct
/**
* Constructor.
*
* @param string $inClassName
* @param string $inSourceFile
* @param string $outClassName
* @param string $outSourceFile
* @throws RuntimeException
*/
public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '')
{
if (class_exists($inClassName)) {
$reflector = new ReflectionClass($inClassName);
$inSourceFile = $reflector->getFileName();
if ($inSourceFile === FALSE) {
$inSourceFile = '<internal>';
}
unset($reflector);
} else {
if (empty($inSourceFile)) {
$possibleFilenames = array($inClassName . '.php', PHPUnit_Util_Filesystem::classNameToFilename($inClassName));
foreach ($possibleFilenames as $possibleFilename) {
if (is_file($possibleFilename)) {
$inSourceFile = $possibleFilename;
}
}
}
if (empty($inSourceFile)) {
throw new PHPUnit_Framework_Exception(sprintf('Neither "%s" nor "%s" could be opened.', $possibleFilenames[0], $possibleFilenames[1]));
}
if (!is_file($inSourceFile)) {
throw new PHPUnit_Framework_Exception(sprintf('"%s" could not be opened.', $inSourceFile));
}
$inSourceFile = realpath($inSourceFile);
include_once $inSourceFile;
if (!class_exists($inClassName)) {
throw new PHPUnit_Framework_Exception(sprintf('Could not find class "%s" in "%s".', $inClassName, $inSourceFile));
}
}
if (empty($outClassName)) {
$outClassName = $inClassName . 'Test';
}
if (empty($outSourceFile)) {
$outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php';
}
parent::__construct($inClassName, $inSourceFile, $outClassName, $outSourceFile);
}
示例5: handleLoader
/**
* Handles the loading of the PHPUnit_Runner_TestSuiteLoader implementation.
*
* @param string $loaderClass
* @param string $loaderFile
*/
protected function handleLoader($loaderClass, $loaderFile = '')
{
if (!class_exists($loaderClass, FALSE)) {
if ($loaderFile == '') {
$loaderFile = PHPUnit_Util_Filesystem::classNameToFilename($loaderClass);
}
$loaderFile = PHPUnit_Util_Filesystem::fileExistsInIncludePath($loaderFile);
if ($loaderFile !== FALSE) {
require $loaderFile;
}
}
if (class_exists($loaderClass, FALSE)) {
$class = new ReflectionClass($loaderClass);
if ($class->implementsInterface('PHPUnit_Runner_TestSuiteLoader') && $class->isInstantiable()) {
$loader = $class->newInstance();
}
}
if (!isset($loader)) {
PHPUnit_TextUI_TestRunner::showError(sprintf('Could not use "%s" as loader.', $loaderClass));
}
return $loader;
}
示例6: handlePrinter
/**
* Handles the loading of the PHPUnit_Util_Printer implementation.
*
* @param string $printerClass
* @param string $printerFile
* @return PHPUnit_Util_Printer
*/
protected function handlePrinter($printerClass, $printerFile = '')
{
if (!class_exists($printerClass, FALSE)) {
if ($printerFile == '') {
$printerFile = PHPUnit_Util_Filesystem::classNameToFilename($printerClass);
}
$printerFile = stream_resolve_include_path($printerFile);
if ($printerFile) {
require $printerFile;
}
}
if (class_exists($printerClass, FALSE)) {
$class = new ReflectionClass($printerClass);
if ($class->implementsInterface('PHPUnit_Framework_TestListener') && $class->isSubclassOf('PHPUnit_Util_Printer') && $class->isInstantiable()) {
$printer = $class->newInstance();
}
}
if (!isset($printer)) {
PHPUnit_TextUI_TestRunner::showError(sprintf('Could not use "%s" as printer.', $printerClass));
}
return $printer;
}
示例7: handlePrinter
/**
* Handles the loading of the PHPUnit_Util_Printer implementation.
*
* @param string $printerClass
* @param string $printerFile
*
* @return PHPUnit_Util_Printer
*/
protected function handlePrinter($printerClass, $printerFile = '')
{
if (!class_exists($printerClass, false)) {
if ($printerFile == '') {
$printerFile = PHPUnit_Util_Filesystem::classNameToFilename($printerClass);
}
$printerFile = stream_resolve_include_path($printerFile);
if ($printerFile) {
require $printerFile;
}
}
if (class_exists($printerClass)) {
$class = new ReflectionClass($printerClass);
if ($class->implementsInterface('PHPUnit_Framework_TestListener') && $class->isSubclassOf('PHPUnit_Util_Printer') && $class->isInstantiable()) {
if ($class->isSubclassOf('PHPUnit_TextUI_ResultPrinter')) {
return $printerClass;
}
$outputStream = isset($this->arguments['stderr']) ? 'php://stderr' : null;
return $class->newInstance($outputStream);
}
}
$this->showError(sprintf('Could not use "%s" as printer.', $printerClass));
}
示例8: phpunitAutoload
function phpunitAutoload($class)
{
require_once $this->phpUnitPath . '/PHPUnit/Util/Filesystem.php';
if (strpos($class, 'PHPUnit_') === 0 || strpos($class, 'PHP_') === 0 || strpos($class, 'Text_') === 0 || strpos($class, 'File_') === 0 || strpos($class, 'Doctrine') === 0 || strpos($class, 'SebastianBergmann') === 0) {
$file = \PHPUnit_Util_Filesystem::classNameToFilename($class);
if (file_exists($this->phpUnitPath . '/' . $file)) {
require_once $file;
}
}
}