예제 #1
0
 /**
  * Add Mockery files to PHPUnit's blacklist so they don't showup on coverage reports
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     if (class_exists('\\PHP_CodeCoverage_Filter') && method_exists('\\PHP_CodeCoverage_Filter', 'getInstance')) {
         \PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(__DIR__ . '/../../../Mockery/', '.php', '', 'PHPUNIT');
         \PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__DIR__ . '/../../../Mockery.php', 'PHPUNIT');
     }
 }
예제 #2
0
 /**
  * Get the code coverage filter instance we will use for tests.
  * When running PHPUnit 3.5, this will return the singleton instance.
  * When running PHPUnit 3.6, this will return the instance we hold internally;
  * this same instance will be passed to PHPUnit in AgaviTesting::dispatch().
  *
  * @return     PHP_CodeCoverage_Filter The code coverage filter for our tests.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      1.0.7
  * @deprecated 1.1.0 Use AgaviPhpUnitCli
  */
 public static function getCodeCoverageFilter()
 {
     if (self::$codeCoverageFilter === null) {
         // PHP_CodeCoverage doesn't expose any version info, we'll have to check if there is a static getInstance method
         self::$codeCoverageFilter = method_exists('PHP_CodeCoverage_Filter', 'getInstance') ? PHP_CodeCoverage_Filter::getInstance() : new PHP_CodeCoverage_Filter();
     }
     return self::$codeCoverageFilter;
 }
 /** 
  * Initialise the wrapper class.
  */
 public function init()
 {
     require_once 'PHP/CodeCoverage.php';
     require_once 'PHP/CodeCoverage/Report/HTML.php';
     require_once 'PHPUnit/Autoload.php';
     require_once 'PHP/CodeCoverage/Filter.php';
     PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');
 }
예제 #4
0
 /**
  * Set up the test suite.
  *
  * @return void
  * @access protected
  */
 protected function setUp()
 {
     // Update the code coverage blacklist -- we don't want to analyze all the
     // test code or any external PEAR libraries that we include:
     PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('/usr/share/php');
     PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('/usr/local/lib');
     PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(dirname(__FILE__));
     // Clear out Smarty files to ensure testing begins with a clean slate:
     $this->_smartyCleanup();
 }
예제 #5
0
 function phpunit_autoload($class)
 {
     if (strpos($class, 'PHPUnit_') === 0) {
         $file = str_replace('_', '/', $class) . '.php';
         $file = PHPUnit_Util_Filesystem::fileExistsInIncludePath($file);
         if ($file) {
             require_once $file;
             PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist($file, 'PHPUNIT');
         }
     }
 }
	protected function setCodeCoverageIgnores()
	{
		$codeCoverageFilter = PHP_CodeCoverage_Filter::getInstance();
		$codeCoverageFilter->addDirectoryToBlacklist(dirname(__FILE__));
		
		foreach($this->codeCoverageIgnoreDirectoryList as $oneDirectory)
		{
			$codeCoverageFilter->addDirectoryToBlacklist($oneDirectory);
		}
		
		$codeCoverageFilter->addFilesToBlackList($this->codeCoverageIgnoreFileList);
	}
예제 #7
0
파일: Spec.php 프로젝트: rafeca/Spec-PHP
 /**
  * Initializes the Spec library
  *
  * @static
  * @param bool $autoload    Unless it's false it will register a custom autoloader
  * @return bool
  */
 public static function init($autoload = true)
 {
     static $alreadyInitialized = false;
     if ($alreadyInitialized) {
         return false;
     }
     // Register auto loader
     if ($autoload) {
         self::autoload();
     }
     // Register stream wrapper for spec files
     $scheme = self::SCHEME;
     if (!in_array($scheme, stream_get_wrappers())) {
         // Get loaded extensions
         $extensions = array_merge(get_loaded_extensions(), get_loaded_extensions(true));
         // Check if the Suhosin patch is loaded
         if (in_array('suhosin', $extensions)) {
             $list = ini_get('suhosin.executor.include.whitelist');
             $list = explode(',', $list);
             $list = array_filter(array_map('trim', $list));
             if (!in_array($scheme, $list)) {
                 throw new \RuntimeException("The Suhosin patch has been detected but the custom '{$scheme}' scheme was not found as allowed. " . "Please review your php.ini settings to include '{$scheme}' in 'suhosin.executor.include.whitelist'.");
             }
         }
         stream_wrapper_register($scheme, __NAMESPACE__ . '\\Spec\\StreamWrapper');
     }
     // Black list Spec files for PHPUnit
     if (class_exists('\\PHP_CodeCoverage_Filter', false)) {
         $filter = \PHP_CodeCoverage_Filter::getInstance();
         $filter->addFileToBlacklist(__FILE__, 'PHPUNIT');
         $filter->addDirectoryToBlacklist(__DIR__ . DIRECTORY_SEPARATOR . 'Spec', '.php', '', 'PHPUNIT', FALSE);
         // Also add Hamcrest matcher library from the include path
         $paths = explode(PATH_SEPARATOR, get_include_path());
         foreach ($paths as $path) {
             if (is_file($path . DIRECTORY_SEPARATOR . 'Hamcrest/MatcherAssert.php')) {
                 $filter->addDirectoryToBlacklist($path . DIRECTORY_SEPARATOR . 'Hamcrest', '.php', '', 'PHPUNIT', FALSE);
                 break;
             }
         }
     }
     // include standard matchers and keywords
     include_once __DIR__ . '/Spec/keywords.php';
     include_once __DIR__ . '/Spec/matchers.php';
     // Setup suite stack
     self::$suites = new \SplStack();
     return true;
 }
예제 #8
0
 protected function createRunner()
 {
     if ($this->version36) {
         $filter = new PHP_CodeCoverage_Filter();
     } else {
         $filter = PHP_CodeCoverage_Filter::getInstance();
     }
     $filter->addFileToBlacklist(__FILE__, 'PHPUNIT');
     $filter->addFileToBlacklist(__DIR__ . '/JelixTestSuite.class.php', 'PHPUNIT');
     $filter->addFileToBlacklist(__DIR__ . '/junittestcase.class.php', 'PHPUNIT');
     $filter->addFileToBlacklist(__DIR__ . '/junittestcasedb.class.php', 'PHPUNIT');
     $filter->addFileToBlacklist(dirname(__DIR__) . '/phpunit.inc.php', 'PHPUNIT');
     if ($this->version36) {
         return new PHPUnit_TextUI_TestRunner($this->arguments['loader'], $filter);
     } else {
         return new PHPUnit_TextUI_TestRunner($this->arguments['loader']);
     }
 }
 /**
  * Set white / black lists
  */
 public function setWhiteAndBlacklists()
 {
     if ($this->isPhpunitVersionGreaterOrEquals("3.6.0")) {
         // TODO not sure if this is working - we need to validate that
         $filter = new PHP_CodeCoverage_Filter();
         $filter->addDirectoryToBlacklist(PATH_TO_TEST_DIR);
         $filter->addDirectoryToBlacklist(PATH_TO_TINE_LIBRARY);
         $filter->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Setup');
         $filter->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Zend');
         $filter->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/vendor');
     } else {
         if ($this->isPhpunitVersionGreaterOrEquals("3.5.0")) {
             PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_TEST_DIR);
             PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_TINE_LIBRARY);
             PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Setup');
             PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Zend');
         } else {
             PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_TEST_DIR);
             PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_TINE_LIBRARY);
             PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_REAL_DIR . '/Setup');
             PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_REAL_DIR . '/Zend');
         }
     }
 }
예제 #10
0
 *
 * (c) 2011 Jan Sorgalla <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
// Get base and application path
$rootPath = dirname(__DIR__);
set_include_path(implode(PATH_SEPARATOR, array($rootPath . '/tests', $rootPath . '/src', get_include_path())));
// Setup autoloading
spl_autoload_register(function ($className) {
    if (strpos($className, 'PHPUnit_') === false && strpos($className, 'DotsUnited\\') === false) {
        return;
    }
    if (false !== strripos($className, '\\')) {
        $replace = '\\';
    } else {
        $replace = '_';
    }
    require str_replace($replace, DIRECTORY_SEPARATOR, $className) . '.php';
}, true, true);
// Define filters for clover report
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist($rootPath . '/src');
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist($rootPath . '/tests');
if (defined('PEAR_INSTALL_DIR') && is_dir(PEAR_INSTALL_DIR)) {
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PEAR_INSTALL_DIR);
}
if (defined('PHP_LIBDIR') && is_dir(PEAR_INSTALL_DIR)) {
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PHP_LIBDIR);
}
unset($rootPath);
예제 #11
0
function phpunit_autoload($class) {
    static $classes = NULL;
    static $path = NULL;
    static $filter = NULL;

    if ($classes === NULL) {
        $classes = array(
          'phpunit_util_class' => '/Util/Class.php',
          'phpunit_util_skeleton' => '/Util/Skeleton.php',
          'phpunit_util_testdox_resultprinter_html' => '/Util/TestDox/ResultPrinter/HTML.php',
          'phpunit_util_testdox_resultprinter_text' => '/Util/TestDox/ResultPrinter/Text.php',
          'phpunit_util_testdox_resultprinter' => '/Util/TestDox/ResultPrinter.php',
          'phpunit_util_testdox_nameprettifier' => '/Util/TestDox/NamePrettifier.php',
          'phpunit_util_skeleton_class' => '/Util/Skeleton/Class.php',
          'phpunit_util_skeleton_test' => '/Util/Skeleton/Test.php',
          'phpunit_util_test' => '/Util/Test.php',
          'phpunit_util_printer' => '/Util/Printer.php',
          'phpunit_util_globalstate' => '/Util/GlobalState.php',
          'phpunit_util_configuration' => '/Util/Configuration.php',
          'phpunit_util_testsuiteiterator' => '/Util/TestSuiteIterator.php',
          'phpunit_util_xml' => '/Util/XML.php',
          'phpunit_util_filesystem' => '/Util/Filesystem.php',
          'phpunit_util_getopt' => '/Util/Getopt.php',
          'phpunit_util_fileloader' => '/Util/Fileloader.php',
          'phpunit_util_invalidargumenthelper' => '/Util/InvalidArgumentHelper.php',
          'phpunit_util_php' => '/Util/PHP.php',
          'phpunit_util_filter' => '/Util/Filter.php',
          'phpunit_util_errorhandler' => '/Util/ErrorHandler.php',
          'phpunit_util_file' => '/Util/File.php',
          'phpunit_util_diff' => '/Util/Diff.php',
          'phpunit_util_type' => '/Util/Type.php',
          'phpunit_util_log_dbus' => '/Util/Log/DBUS.php',
          'phpunit_util_log_junit' => '/Util/Log/JUnit.php',
          'phpunit_util_log_tap' => '/Util/Log/TAP.php',
          'phpunit_util_log_xhprof' => '/Util/Log/XHProf.php',
          'phpunit_util_log_json' => '/Util/Log/JSON.php',
          'phpunit_framework_testlistener' => '/Framework/TestListener.php',
          'phpunit_framework_assert' => '/Framework/Assert.php',
          'phpunit_framework_test' => '/Framework/Test.php',
          'phpunit_framework_warning' => '/Framework/Warning.php',
          'phpunit_framework_comparisonfailure' => '/Framework/ComparisonFailure.php',
          'phpunit_framework_incompletetest' => '/Framework/IncompleteTest.php',
          'phpunit_framework_syntheticerror' => '/Framework/SyntheticError.php',
          'phpunit_framework_testresult' => '/Framework/TestResult.php',
          'phpunit_framework_expectationfailedexception' => '/Framework/ExpectationFailedException.php',
          'phpunit_framework_error' => '/Framework/Error.php',
          'phpunit_framework_testcase' => '/Framework/TestCase.php',
          'phpunit_framework_error_warning' => '/Framework/Error/Warning.php',
          'phpunit_framework_error_notice' => '/Framework/Error/Notice.php',
          'phpunit_framework_testsuite_dataprovider' => '/Framework/TestSuite/DataProvider.php',
          'phpunit_framework_constraint' => '/Framework/Constraint.php',
          'phpunit_framework_skippedtestsuiteerror' => '/Framework/SkippedTestSuiteError.php',
          'phpunit_framework_comparisonfailure_object' => '/Framework/ComparisonFailure/Object.php',
          'phpunit_framework_comparisonfailure_scalar' => '/Framework/ComparisonFailure/Scalar.php',
          'phpunit_framework_comparisonfailure_array' => '/Framework/ComparisonFailure/Array.php',
          'phpunit_framework_comparisonfailure_string' => '/Framework/ComparisonFailure/String.php',
          'phpunit_framework_comparisonfailure_type' => '/Framework/ComparisonFailure/Type.php',
          'phpunit_framework_testfailure' => '/Framework/TestFailure.php',
          'phpunit_framework_exception' => '/Framework/Exception.php',
          'phpunit_framework_skippedtest' => '/Framework/SkippedTest.php',
          'phpunit_framework_incompletetesterror' => '/Framework/IncompleteTestError.php',
          'phpunit_framework_selfdescribing' => '/Framework/SelfDescribing.php',
          'phpunit_framework_testsuite' => '/Framework/TestSuite.php',
          'phpunit_framework_skippedtesterror' => '/Framework/SkippedTestError.php',
          'phpunit_framework_constraint_isempty' => '/Framework/Constraint/IsEmpty.php',
          'phpunit_framework_constraint_stringcontains' => '/Framework/Constraint/StringContains.php',
          'phpunit_framework_constraint_stringstartswith' => '/Framework/Constraint/StringStartsWith.php',
          'phpunit_framework_constraint_and' => '/Framework/Constraint/And.php',
          'phpunit_framework_constraint_isanything' => '/Framework/Constraint/IsAnything.php',
          'phpunit_framework_constraint_isequal' => '/Framework/Constraint/IsEqual.php',
          'phpunit_framework_constraint_isfalse' => '/Framework/Constraint/IsFalse.php',
          'phpunit_framework_constraint_traversablecontainsonly' => '/Framework/Constraint/TraversableContainsOnly.php',
          'phpunit_framework_constraint_istype' => '/Framework/Constraint/IsType.php',
          'phpunit_framework_constraint_attribute' => '/Framework/Constraint/Attribute.php',
          'phpunit_framework_constraint_isinstanceof' => '/Framework/Constraint/IsInstanceOf.php',
          'phpunit_framework_constraint_greaterthan' => '/Framework/Constraint/GreaterThan.php',
          'phpunit_framework_constraint_or' => '/Framework/Constraint/Or.php',
          'phpunit_framework_constraint_not' => '/Framework/Constraint/Not.php',
          'phpunit_framework_constraint_objecthasattribute' => '/Framework/Constraint/ObjectHasAttribute.php',
          'phpunit_framework_constraint_lessthan' => '/Framework/Constraint/LessThan.php',
          'phpunit_framework_constraint_traversablecontains' => '/Framework/Constraint/TraversableContains.php',
          'phpunit_framework_constraint_stringmatches' => '/Framework/Constraint/StringMatches.php',
          'phpunit_framework_constraint_classhasattribute' => '/Framework/Constraint/ClassHasAttribute.php',
          'phpunit_framework_constraint_fileexists' => '/Framework/Constraint/FileExists.php',
          'phpunit_framework_constraint_xor' => '/Framework/Constraint/Xor.php',
          'phpunit_framework_constraint_isidentical' => '/Framework/Constraint/IsIdentical.php',
          'phpunit_framework_constraint_count' => '/Framework/Constraint/Count.php',
          'phpunit_framework_constraint_arrayhaskey' => '/Framework/Constraint/ArrayHasKey.php',
          'phpunit_framework_constraint_classhasstaticattribute' => '/Framework/Constraint/ClassHasStaticAttribute.php',
          'phpunit_framework_constraint_stringendswith' => '/Framework/Constraint/StringEndsWith.php',
          'phpunit_framework_constraint_pcrematch' => '/Framework/Constraint/PCREMatch.php',
          'phpunit_framework_constraint_isnull' => '/Framework/Constraint/IsNull.php',
          'phpunit_framework_constraint_istrue' => '/Framework/Constraint/IsTrue.php',
          'phpunit_framework_assertionfailederror' => '/Framework/AssertionFailedError.php',
          'phpunit_extensions_repeatedtest' => '/Extensions/RepeatedTest.php',
          'phpunit_extensions_phpttestcase' => '/Extensions/PhptTestCase.php',
          'phpunit_extensions_ticketlistener' => '/Extensions/TicketListener.php',
          'phpunit_extensions_phpttestcase_logger' => '/Extensions/PhptTestCase/Logger.php',
          'phpunit_extensions_outputtestcase' => '/Extensions/OutputTestCase.php',
          'phpunit_extensions_ticketlistener_trac' => '/Extensions/TicketListener/Trac.php',
          'phpunit_extensions_ticketlistener_googlecode' => '/Extensions/TicketListener/GoogleCode.php',
          'phpunit_extensions_ticketlistener_github' => '/Extensions/TicketListener/GitHub.php',
          'phpunit_extensions_grouptestsuite' => '/Extensions/GroupTestSuite.php',
          'phpunit_extensions_phpttestsuite' => '/Extensions/PhptTestSuite.php',
          'phpunit_extensions_testdecorator' => '/Extensions/TestDecorator.php',
          'phpunit_textui_resultprinter' => '/TextUI/ResultPrinter.php',
          'phpunit_textui_command' => '/TextUI/Command.php',
          'phpunit_textui_testrunner' => '/TextUI/TestRunner.php',
          'phpunit_runner_standardtestsuiteloader' => '/Runner/StandardTestSuiteLoader.php',
          'phpunit_runner_version' => '/Runner/Version.php',
          'phpunit_runner_basetestrunner' => '/Runner/BaseTestRunner.php',
          'phpunit_runner_testsuiteloader' => '/Runner/TestSuiteLoader.php'
        );

        $path = dirname(__FILE__);

        $filter = PHP_CodeCoverage_Filter::getInstance();
    }

    $cn = strtolower($class);

    if (isset($classes[$cn])) {
        $file = $path . $classes[$cn];

        require $file;

        $filter->addFileToBlackList($file, 'PHPUNIT');
    }
}
예제 #12
0
}
if (!defined('SELENIUM_SERVER')) {
    define('SELENIUM_SERVER', 'cormorant.crtdev.local');
}
if (!defined('TESTS_LOG_DIR')) {
    define('TESTS_LOG_DIR', LC_DIR_VAR . 'log' . LC_DS);
}
if (isset($_SERVER['argv']) && preg_match('/--log-xml\\s+(\\S+)\\s/s', implode(' ', $_SERVER['argv']), $match)) {
    XLite_Tests_MetricWriter::init($match[1] . '.speed');
    unset($match);
}
if (!defined('INCLUDE_ONLY_TESTS') || !preg_match('/DEPLOY_/', constant('INCLUDE_ONLY_TESTS'))) {
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_ROOT . LC_DS . '.dev');
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_SRC . LC_DS . 'etc');
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist(PATH_SRC . LC_DS . 'var' . LC_DS . 'run' . LC_DS . 'classes');
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_SRC . LC_DS . 'var' . LC_DS . 'run' . LC_DS . 'classes' . LC_DS . 'XLite' . LC_DS . 'Model' . LC_DS . 'Proxy');
}
foreach (glob(LC_DIR_ROOT . 'var/log/selenium.*.html') as $f) {
    @unlink($f);
}
/**
 * Class to sort out files gathered by RecursiveIteratorIterator
 *
 * @package    X-Lite_Tests
 * @subpackage Main
 * @see        ____class_see____
 * @since      1.0.10
 */
class XLite_Tests_SortedIterator extends SplHeap
{
    public function __construct(Iterator $iterator)
예제 #13
0
                break;
            default:
                $finfo = finfo_open();
                $mime = finfo_file($finfo, $file, FILEINFO_MIME);
                finfo_close($finfo);
                break;
        }
        $size = filesize($file);
        $time = filemtime($file);
        header('HTTP/1.1 200 OK');
        header('Content-Type: ' . $mime);
        header('Content-Length: ' . $size);
        header('Etag: ' . md5("{$size}-{$time}"));
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', $time));
        readfile($file);
    } else {
        header('HTTP/1.0 404 Not Found');
    }
    exit(0);
}
require $config['phpunit'] . 'PHPUnit/Autoload.php';
$filter = PHP_CodeCoverage_Filter::getInstance();
$filter->addDirectoryToBlacklist(__DIR__, '.php', '', 'PHPUNIT', FALSE);
$filter->addDirectoryToBlacklist(__DIR__ . '/templates', '.php', '', 'PHPUNIT', FALSE);
$filter->addDirectoryToBlacklist($config['tpldir'], '.php', '', 'PHPUNIT', FALSE);
$filter->addFileToBlacklist(__FILE__, 'PHPUNIT', FALSE);
$filter->addFileToBlacklist($_SERVER['SCRIPT_FILENAME'], 'PHPUNIT', FALSE);
require __DIR__ . '/PHPUnit_Html_Printer.php';
require __DIR__ . '/PHPUnit_Html_TestRunner.php';
PHPUnit_HTML_TestRunner::run($config);
/* vim: set expandtab tabstop=4 shiftwidth=4: */
예제 #14
0
jimport('joomla.session.session');

// We need also these:
jimport('joomla.plugin.helper');

$_SERVER['HTTP_HOST'] = 'http://localhost';
$_SERVER['REQUEST_URI'] = '/index.php';
//$_SERVER['REMOTE_ADDR'] = '127.0.0.1';

$app = JFactory::getApplication('site');

if (!defined('KPATH_TESTS'))
{
	define('KPATH_TESTS', dirname(__FILE__));
}

// Exclude all of the tests from code coverage reports
if (class_exists('PHP_CodeCoverage_Filter')) {
	PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(JPATH_BASE . '/tests');
} else {
	PHPUnit_Util_Filter::addDirectoryToFilter(JPATH_BASE . '/tests');
}

// Set error handling.
JError::setErrorHandling(E_NOTICE, 'ignore');
JError::setErrorHandling(E_WARNING, 'ignore');
JError::setErrorHandling(E_ERROR, 'ignore');

// Load Kunena API
require_once JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
KunenaFactory::loadLanguage();
예제 #15
0
//PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist(TESTS_PATH . '/../Lib');
$useLowerCase = false;
if (is_dir(TESTS_PATH . '/../lib/nimbles')) {
    $useLowerCase = true;
    define('NIMBLES_PATH', realpath(TESTS_PATH . '/../lib'));
    define('NIMBLES_LIBRARY', realpath(TESTS_PATH . '/../lib/nimbles'));
} else {
    define('NIMBLES_PATH', realpath(TESTS_PATH . '/../Lib'));
    define('NIMBLES_LIBRARY', realpath(TESTS_PATH . '/../Lib/Nimbles'));
}
$dirs = scandir(NIMBLES_LIBRARY);
$testFiles = array();
foreach ($dirs as $dir) {
    if (false !== ($testcase = realpath(NIMBLES_LIBRARY . $dir . ($useLowerCase ? '/testcase.php' : '/TestCase.php')))) {
        $testFiles[] = $testcase;
    }
    if (false !== ($testsuite = realpath(NIMBLES_LIBRARY . $dir . ($useLowerCase ? '/testsuite.php' : '/TestSuite.php')))) {
        $testFiles[] = $testsuite;
    }
}
PHP_CodeCoverage_Filter::getInstance()->addFilesToBlacklist($testFiles);
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(TESTS_PATH, array('.php', '.inc'));
// surpress warnings if timezone has not been set on the system
date_default_timezone_set(@date_default_timezone_get());
if (file_exists(NIMBLES_PATH . '/nimbles.php')) {
    require_once realpath(NIMBLES_PATH . '/nimbles.php');
} else {
    require_once realpath(NIMBLES_PATH . '/Nimbles.php');
}
new Nimbles();
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(TESTS_PATH . '/..'));
예제 #16
0
 /**
  * Initialize Task.
  * This method includes any necessary PHPUnit2 libraries and triggers
  * appropriate error if they cannot be found.  This is not done in header
  * because we may want this class to be loaded w/o triggering an error.
  */
 public function init()
 {
     if (version_compare(PHP_VERSION, '5.0.3') < 0) {
         throw new BuildException("PHPUnitTask requires PHP version >= 5.0.3", $this->getLocation());
     }
     /**
      * Determine PHPUnit version number
      */
     @(include_once 'PHPUnit/Runner/Version.php');
     $version = PHPUnit_Runner_Version::id();
     if (version_compare($version, '3.2.0') < 0) {
         throw new BuildException("PHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation());
     }
     /**
      * Other dependencies that should only be loaded when class is actually used.
      */
     require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
     require_once 'phing/tasks/ext/phpunit/BatchTest.php';
     require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
     /**
      * point PHPUnit_MAIN_METHOD define to non-existing method
      */
     if (!defined('PHPUnit_MAIN_METHOD')) {
         define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
     }
     /**
      * Add some defaults to the PHPUnit filter
      */
     $pwd = dirname(__FILE__);
     $path = realpath($pwd . '/../../../');
     if (version_compare($version, '3.5.0') >= 0) {
         PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist($path);
     } else {
         require_once 'PHPUnit/Framework.php';
         require_once 'PHPUnit/Util/Filter.php';
         PHPUnit_Util_Filter::addDirectoryToFilter($path);
     }
 }
예제 #17
0
// Include helper class
require_once dirname(__FILE__) . '/includes/JUnitHelper.php';
// Define expected Joomla constants.
define('DS', '/');
if (!defined('JPATH_BASE')) {
    // JPATH_BASE can be defined in init.php
    // This gets around problems with soft linking the unittest folder into a Joomla tree,
    // or using the unittest framework from a central location.
    define('JPATH_BASE', JUnitHelper::normalize(dirname(__FILE__)) . '/test_application');
}
if (!defined('JPATH_TESTS')) {
    define('JPATH_TESTS', dirname(__FILE__));
}
//// Fix magic quotes.
@ini_set('magic_quotes_runtime', 0);
// Maximise error reporting.
@ini_set('zend.ze1_compatibility_mode', '0');
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Include the base test cases.
require_once JPATH_TESTS . '/includes/JoomlaTestCase.php';
require_once JPATH_TESTS . '/includes/JoomlaDatabaseTestCase.php';
// Include relative constants, JLoader and the jimport and jexit functions.
require_once JPATH_BASE . '/defines.php';
require_once JPATH_PLATFORM . '/import.php';
// Exclude all of the tests from code coverage reports
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(JPATH_TESTS);
// Set error handling.
JError::setErrorHandling(E_NOTICE, 'ignore');
JError::setErrorHandling(E_WARNING, 'ignore');
JError::setErrorHandling(E_ERROR, 'ignore');
예제 #18
0
 protected function printException($idx, $title, \Exception $ex)
 {
     $indent = str_repeat(' ', strlen("  {$idx}) "));
     if ($ex instanceof \PHPUnit_Framework_SyntheticError) {
         $trace = $ex->getSyntheticTrace();
     } else {
         $trace = $ex->getTrace();
     }
     // Insert exception as first element of the trace
     array_unshift($trace, array('file' => $ex->getFile(), 'line' => $ex->getLine()));
     // Process and filter stack trace
     $last = null;
     $offending = null;
     $stacktrace = array();
     $groups = $this->debug ? array() : array('DEFAULT', 'PHPUNIT');
     $filter = \PHP_CodeCoverage_Filter::getInstance();
     foreach ($trace as $frame) {
         if (isset($frame['file']) && isset($frame['line']) && !$filter->isFiltered($frame['file'], $groups, TRUE)) {
             // Skip duplicated frames
             if (!$this->debug && $last && $last['file'] === $frame['file'] && $last['line'] === $frame['line']) {
                 continue;
             }
             $last = $frame;
             // Skip blacklisted eval frames: /path/to/file(line) : eval()'d code:line
             if (preg_match('/^(.+?)\\([0-9]+\\)\\s:\\seval/', $frame['file'], $m)) {
                 if ($filter->isFiltered($m[1], $groups, TRUE)) {
                     continue;
                 }
             }
             // Check spec files
             if (0 === strpos($frame['file'], Spec::SCHEME . '://')) {
                 $frame['file'] = substr($frame['file'], strlen(Spec::SCHEME . '://'));
                 if (0 !== strpos($frame['file'], '/')) {
                     $frame['file'] = '.' . DIRECTORY_SEPARATOR . $frame['file'];
                 }
                 $lines = file($frame['file']);
                 $offending = trim($lines[$frame['line'] - 1]);
             }
             $stacktrace[] = $frame['file'] . ':' . $frame['line'];
         }
     }
     // Print title
     $this->write("  {$idx}) {$title}" . PHP_EOL);
     // Print exception message
     $msg = str_replace(PHP_EOL, PHP_EOL . $indent, $ex->getMessage());
     $this->write($indent . "{$msg}" . PHP_EOL);
     // Print offending spec line if found
     if ($offending) {
         $ch = $this->colors ? '❯' : '>';
         $this->write($indent . "{$ch} {$offending}" . PHP_EOL);
     }
     $ch = '#';
     foreach ($stacktrace as $frame) {
         $this->write("{$indent}{$ch} {$frame}" . PHP_EOL);
         if (!$this->verbose && !$this->debug) {
             break;
         }
     }
     $this->write(PHP_EOL);
 }
 * @todo put that in config.inc as well or remove that?
 */
define('CONFIGURATION', PATH_TO_TEST_DIR . "/conf.xml");
/*
 * Set up basic tine 2.0 environment
 */
require_once 'bootstrap.php';
// add test paths to autoloader
$autoloader = (require 'vendor/autoload.php');
$autoloader->set('', $path);
/*
 * Set white / black lists
 */
$phpUnitVersion = explode(' ', PHPUnit_Runner_Version::getVersionString());
if (version_compare($phpUnitVersion[1], "3.6.0") >= 0) {
    $filter = new PHP_CodeCoverage_Filter();
    $filter->addDirectoryToBlacklist(dirname(__FILE__));
} else {
    if (version_compare($phpUnitVersion[1], "3.5.0") >= 0) {
        PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(dirname(__FILE__));
    } else {
        PHPUnit_Util_Filter::addDirectoryToFilter(dirname(__FILE__));
    }
}
// get config
$configData = (include 'phpunitconfig.inc.php');
$config = new Zend_Config($configData);
$_SERVER['DOCUMENT_ROOT'] = $config->docroot;
Setup_TestServer::getInstance()->initFramework();
Tinebase_Core::set('locale', new Zend_Locale($config->locale));
Tinebase_Core::set('testconfig', $config);
 /**
  * 
  * Initializes the framework for all the tests
  */
 protected function initFramework(&$result = null)
 {
     //if we got codeCoverage then we add the rest of the server folders
     $codeCoverageFilter = PHP_CodeCoverage_Filter::getInstance();
     if ($codeCoverageFilter) {
         $testsBaseDir = dirname(__FILE__);
         $whiteList = $codeCoverageFilter->getWhitelist();
         if (!in_array("{$testsBaseDir}/../../api_v3", $whiteList)) {
             //				KalturaLog::debug("Adding" . $testsBaseDir . "/../../api_v3" . "to the CodeCoverage filter\n");
             //$codeCoverageFilter->addDirectoryToWhitelist($testsBaseDir . "/../../api_v3/services");
             //$codeCoverageFilter->addDirectoryToWhitelist($testsBaseDir . "/../../api_v3/lib");
         }
         if (!in_array("{$testsBaseDir}/../../plugins", $whiteList)) {
             //				KalturaLog::debug("Adding" . $testsBaseDir . "/../../plugins" . "to the CodeCoverage filter\n");
             //				$codeCoverageFilter->addDirectoryToWhitelist($testsBaseDir . "/../../plugins");
         }
     }
     if ($result) {
         if ($result instanceof KalturaTestResult) {
             if (!$result->isListenerExists('KalturaTestListener')) {
                 KalturaLog::debug("adding KalturaTestListener to result\n");
                 $result->addListener(new KalturaTestListener());
             }
         }
     }
     if (KalturaTestCaseBase::$isFrameworkInit == false) {
         KalturaLog::debug("Initing framework\n");
         $class = get_class($this);
         $classPath = KAutoloader::getClassFilePath($class);
         KalturaTestListener::setFailureFilePath(dirname($classPath) . "/testsData/{$class}.failures");
         KalturaTestListener::setDataFilePath(dirname($classPath) . "/testsData/{$class}.data");
         KalturaTestListener::setTotalFailureFilePath(KALTURA_TESTS_PATH . "/common/totalFailures.failures");
         $result->addListener(new KalturaTestListener());
         KalturaTestCaseBase::$isFrameworkInit = true;
         //If the test case failures wasn't added
         if (KalturaTestListener::getTestCaseFailures() == null) {
             KalturaTestListener::setCurrentTestCase($class);
             //Then add the test case failure
             KalturaTestListener::setTestCaseFailures(new KalturaTestCaseFailures(KalturaTestListener::getCurrentTestCase()));
             $testCaseFailures = KalturaTestListener::getTestCaseFailures();
             $testProcedureName = $this->getName(false);
             $testProcedure = $testCaseFailures->getTestProcedureFailure($testProcedureName);
             if (!$testProcedure) {
                 $testCaseFailures->addTestProcedureFailure(new KalturaTestProcedureFailure());
             } else {
                 KalturaLog::alert("Test procedure [{$testProcedureName}] already exists");
             }
         }
     }
 }
예제 #21
0
<?php

/**
 * Copyright 2009, 2010, 2011, 2014 Yuriy Timofeev <*****@*****.**>
 * @author Yuriy Timofeev <*****@*****.**>
 * @package webacula
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public License
 */
require_once dirname(__FILE__) . '/application/bootstrap.php';
require_once dirname(__FILE__) . '/application/controllers/AllTests.php';
require_once dirname(__FILE__) . '/application/models/AllTests.php';
/* какие каталоги учитывать при построении отчета */
if (PHPUnit_Runner_Version::id() >= '3.5.0') {
    // PHPUnit 3.5.5
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist('../application');
    PHP_CodeCoverage_Filter::getInstance()->removeFileFromWhitelist('../application/views/helpers');
} else {
    // PHPUnit 3.4
    PHPUnit_Util_Filter::addDirectoryToWhitelist('../application');
    PHPUnit_Util_Filter::removeFileFromWhitelist('../application/views/helpers');
}
class AllTests
{
    public static function main()
    {
        $parameters = array();
        PHPUnit_TextUI_TestRunner::run(self::suite(), $parameters);
    }
    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('Webacula Test Suite');
예제 #22
0
 /**
  * Constructor.
  *
  * @param  PHP_CodeCoverage_Driver $driver
  * @param  PHP_CodeCoverage_Filter $filter
  * @throws InvalidArgumentException
  */
 public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCoverage_Filter $filter = NULL)
 {
     if ($driver === NULL) {
         $driver = new PHP_CodeCoverage_Driver_Xdebug();
     }
     if ($filter === NULL) {
         $filter = PHP_CodeCoverage_Filter::getInstance();
     }
     $this->driver = $driver;
     $this->filter = $filter;
     if (defined('PHP_CODECOVERAGE_TESTSUITE')) {
         $this->isCodeCoverageTestSuite = TRUE;
     }
     if (defined('FILE_ITERATOR_TESTSUITE')) {
         $this->isFileIteratorTestSuite = TRUE;
     }
     if (defined('PHP_TIMER_TESTSUITE')) {
         $this->isTimerTestSuite = TRUE;
     }
     if (defined('PHP_TOKENSTREAM_TESTSUITE')) {
         $this->isTokenStreamTestSuite = TRUE;
     }
 }
예제 #23
0
파일: Filesystem.php 프로젝트: qcodo/qcodo
 /**
  * Stops the collection of loaded files and adds
  * the names of the loaded files to the blacklist.
  *
  * @return array
  * @since  Method available since Release 3.4.6
  */
 public static function collectEndAndAddToBlacklist()
 {
     foreach (self::collectEnd() as $blacklistedFile) {
         PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist($blacklistedFile, 'PHPUNIT');
     }
 }
예제 #24
0
 /**
  * @covers PHP_CodeCoverage_Filter::getInstance
  */
 public function testFactory()
 {
     $filter = PHP_CodeCoverage_Filter::getInstance();
     $this->assertSame($filter, PHP_CodeCoverage_Filter::getInstance());
 }
예제 #25
0
 /**
  * @param  array $arguments
  * @since  Method available since Release 3.2.1
  */
 protected function handleConfiguration(array &$arguments)
 {
     if (isset($arguments['configuration']) && !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) {
         $arguments['configuration'] = PHPUnit_Util_Configuration::getInstance($arguments['configuration']);
     }
     $arguments['debug'] = isset($arguments['debug']) ? $arguments['debug'] : FALSE;
     $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
     $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
     $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE;
     if (isset($arguments['configuration'])) {
         $arguments['configuration']->handlePHPConfiguration();
         $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
         if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
             $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
         }
         if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
             $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
         }
         if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
             $arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
         }
         if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
             $arguments['colors'] = $phpunitConfiguration['colors'];
         }
         if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
             $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
         }
         if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
             $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
         }
         if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
             $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
         }
         if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
             $arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
         }
         if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
             $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
         }
         if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
             $arguments['verbose'] = $phpunitConfiguration['verbose'];
         }
         $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
         if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
             $arguments['groups'] = $groupConfiguration['include'];
         }
         if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
             $arguments['excludeGroups'] = $groupConfiguration['exclude'];
         }
         foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
             if (!class_exists($listener['class'], FALSE) && $listener['file'] !== '') {
                 $file = PHPUnit_Util_Filesystem::fileExistsInIncludePath($listener['file']);
                 if ($file !== FALSE) {
                     require $file;
                 }
             }
             if (class_exists($listener['class'], FALSE)) {
                 if (count($listener['arguments']) == 0) {
                     $listener = new $listener['class']();
                 } else {
                     $listenerClass = new ReflectionClass($listener['class']);
                     $listener = $listenerClass->newInstanceArgs($listener['arguments']);
                 }
                 if ($listener instanceof PHPUnit_Framework_TestListener) {
                     $arguments['listeners'][] = $listener;
                 }
             }
         }
         $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
         if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['reportDirectory'])) {
             if (isset($loggingConfiguration['charset']) && !isset($arguments['reportCharset'])) {
                 $arguments['reportCharset'] = $loggingConfiguration['charset'];
             }
             if (isset($loggingConfiguration['yui']) && !isset($arguments['reportYUI'])) {
                 $arguments['reportYUI'] = $loggingConfiguration['yui'];
             }
             if (isset($loggingConfiguration['highlight']) && !isset($arguments['reportHighlight'])) {
                 $arguments['reportHighlight'] = $loggingConfiguration['highlight'];
             }
             if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
                 $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
             }
             if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
                 $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
             }
             $arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
         }
         if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
             $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
         }
         if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
             $arguments['jsonLogfile'] = $loggingConfiguration['json'];
         }
         if (isset($loggingConfiguration['plain'])) {
             $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
         }
         if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
             $arguments['tapLogfile'] = $loggingConfiguration['tap'];
         }
         if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
             $arguments['junitLogfile'] = $loggingConfiguration['junit'];
             if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
                 $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
             }
         }
         if (isset($loggingConfiguration['story-html']) && !isset($arguments['storyHTMLFile'])) {
             $arguments['storyHTMLFile'] = $loggingConfiguration['story-html'];
         }
         if (isset($loggingConfiguration['story-text']) && !isset($arguments['storyTextFile'])) {
             $arguments['storsTextFile'] = $loggingConfiguration['story-text'];
         }
         if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
             $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
         }
         if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
             $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
         }
     }
     if (isset($arguments['configuration'])) {
         $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
         $filter = PHP_CodeCoverage_Filter::getInstance();
         foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
             $filter->addDirectoryToBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
         }
         foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
             $filter->addFileToBlacklist($file);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
             $filter->removeDirectoryFromBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
             $filter->removeFileFromBlacklist($file);
         }
         if ((isset($arguments['coverageClover']) || isset($arguments['reportDirectory'])) && extension_loaded('xdebug')) {
             PHP_CodeCoverage::getInstance()->setProcessUncoveredFilesFromWhitelist($filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']);
             foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
                 $filter->addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
             }
             foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
                 $filter->addFileToWhitelist($file);
             }
             foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
                 $filter->removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
             }
             foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
                 $filter->removeFileFromWhitelist($file);
             }
         }
     }
     $arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL;
     $arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL;
     $arguments['colors'] = isset($arguments['colors']) ? $arguments['colors'] : FALSE;
     $arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
     $arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
     $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
     $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
     $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
     $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
     $arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : FALSE;
     $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
     $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
     $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
     $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
     $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
     $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
     $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
     if ($arguments['filter'] !== FALSE && preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) {
         $arguments['filter'] = '/' . $arguments['filter'] . '/';
     }
 }
예제 #26
0
* @version $Id$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert
*
* @package FluentDOM
* @subpackage unitTests
*/
/**
* load necessary files
*/
require_once dirname(__FILE__) . '/../src/FluentDOM.php';
/**
* whitelist the src directory
*/
if (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) {
    PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist(dirname(dirname(__FILE__)) . '/src/', '.php');
}
/**
* Test class for FluentDOM.
*
* @package FluentDOM
* @subpackage unitTests
*/
abstract class FluentDOMTestCase extends PHPUnit_Framework_TestCase
{
    /**
     * directory of this file
     * @var string
     */
    private $_directory = '';
    /**
예제 #27
0
파일: tests.php 프로젝트: azuya/Wi3
 /**
  * Recursively whitelists an array of files
  *
  * @param array $files Array of files to whitelist
  */
 protected static function set_whitelist($files)
 {
     if (self::$phpunit_v35) {
         $filter = PHP_CodeCoverage_Filter::getInstance();
     }
     foreach ($files as $file) {
         if (is_array($file)) {
             self::set_whitelist($file);
         } else {
             if (!isset(Kohana_Tests::$cache[$file])) {
                 $relative_path = substr($file, strrpos($file, 'classes' . DIRECTORY_SEPARATOR) + 8, -strlen(EXT));
                 $cascading_file = Kohana::find_file('classes', $relative_path);
                 // The theory is that if this file is the highest one in the cascading filesystem
                 // then it's safe to whitelist
                 Kohana_Tests::$cache[$file] = $cascading_file === $file;
             }
             if (Kohana_Tests::$cache[$file]) {
                 if (isset($filter)) {
                     $filter->addFileToWhitelist($file);
                 } else {
                     PHPUnit_Util_Filter::addFileToWhitelist($file);
                 }
             }
         }
     }
 }
예제 #28
0
require_once 'PHPUnit/TextUI/TestRunner.php';

require_once 'utf/all_tests.php';
require_once 'request/all_tests.php';
require_once 'security/all_tests.php';
require_once 'template/all_tests.php';
require_once 'text_processing/all_tests.php';
require_once 'dbal/all_tests.php';
require_once 'regex/all_tests.php';
require_once 'network/all_tests.php';
require_once 'random/all_tests.php';

// exclude the test directory from code coverage reports
if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0)
{
	PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('./');
}
else
{
	PHPUnit_Util_Filter::addDirectoryToFilter('./');
}

class phpbb_all_tests
{
	public static function main()
	{
		PHPUnit_TextUI_TestRunner::run(self::suite());
	}

	public static function suite()
	{
예제 #29
0
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * @category   Testing
 * @package    PHPUnit
 * @author     Kore Nordmann <*****@*****.**>
 * @author     Sebastian Bergmann <*****@*****.**>
 * @copyright  2002-2010 Sebastian Bergmann <*****@*****.**>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @link       http://www.phpunit.de/
 * @since      File available since Release 3.0.0
 */
require_once 'PHPUnit/Util/Type.php';
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');
/**
 * Constraint that checks if one value is equal to another.
 *
 * Equality is checked with PHP's == operator, the operator is explained in
 * detail at {@url http://www.php.net/manual/en/types.comparisons.php}.
 * Two values are equal if they have the same value disregarding type.
 *
 * The expected value is passed in the constructor.
 *
 * @category   Testing
 * @package    PHPUnit
 * @author     Kore Nordmann <*****@*****.**>
 * @author     Sebastian Bergmann <*****@*****.**>
 * @copyright  2002-2010 Sebastian Bergmann <*****@*****.**>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
예제 #30
0
 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @param  array                        $options
  * @return PHPUnit_Framework_TestResult
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array())
 {
     if (!class_exists('PEAR_RunTest', FALSE)) {
         throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.');
     }
     if (isset($GLOBALS['_PEAR_destructor_object_list']) && is_array($GLOBALS['_PEAR_destructor_object_list']) && !empty($GLOBALS['_PEAR_destructor_object_list'])) {
         $pearDestructorObjectListCount = count($GLOBALS['_PEAR_destructor_object_list']);
     } else {
         $pearDestructorObjectListCount = 0;
     }
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $coverage = $result->getCollectCodeCoverageInformation();
     $options = array_merge($options, $this->options);
     if (!isset($options['include_path'])) {
         $options['include_path'] = get_include_path();
     }
     if ($coverage) {
         $options['coverage'] = TRUE;
     } else {
         $options['coverage'] = FALSE;
     }
     $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE);
     $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options);
     if ($coverage) {
         $runner->xdebug_loaded = TRUE;
     } else {
         $runner->xdebug_loaded = FALSE;
     }
     $result->startTest($this);
     PHP_Timer::start();
     $buffer = $runner->run($this->filename, $options);
     $time = PHP_Timer::stop();
     error_reporting($currentErrorReporting);
     $base = basename($this->filename);
     $path = dirname($this->filename);
     $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
     $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
     $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
     $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
     $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
     $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
     if (file_exists($phpFile)) {
         PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist($phpFile, 'TESTS');
     }
     if (is_object($buffer) && $buffer instanceof PEAR_Error) {
         $result->addError($this, new RuntimeException($buffer->getMessage()), $time);
     } else {
         if ($buffer == 'SKIPPED') {
             $result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0);
         } else {
             if ($buffer != 'PASSED') {
                 $result->addFailure($this, PHPUnit_Framework_ComparisonFailure::diffEqual(file_get_contents($expFile), file_get_contents($outFile)), $time);
             }
         }
     }
     foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
         if (file_exists($file)) {
             unlink($file);
         }
     }
     if ($coverage && file_exists($coverageFile)) {
         eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
         unset($coverageData[$phpFile]);
         $result->getCodeCoverage()->append($coverageData, $this);
         unlink($coverageFile);
     }
     $result->endTest($this, $time);
     // Do not invoke PEAR's destructor mechanism for PHP 4
     // as it raises an E_STRICT.
     if ($pearDestructorObjectListCount == 0) {
         unset($GLOBALS['_PEAR_destructor_object_list']);
     } else {
         $count = count($GLOBALS['_PEAR_destructor_object_list']) - $pearDestructorObjectListCount;
         for ($i = 0; $i < $count; $i++) {
             array_pop($GLOBALS['_PEAR_destructor_object_list']);
         }
     }
     return $result;
 }