示例#1
0
 public static function suite()
 {
     PHPUnit_Util_Filter::addFileToFilter(__FILE__);
     $suite = new PHPUnit_Framework_TestSuite('Joeh Framework');
     $suite->addTestSuite('Joeh_Net_CurlTest');
     $suite->addTestSuite('Joeh_Net_Curl_OptionTest');
     return $suite;
 }
示例#2
0
 public function __construct($name, $directory)
 {
     $this->name = $name;
     $files = Kohana::list_files($directory);
     foreach ($files as $file) {
         if (!is_file($file)) {
             continue;
         }
         if (substr_compare($file, 'Base_Test' . EXT, strlen($file) - strlen('Base_Test' . EXT)) !== 0) {
             PHPUnit_Util_Filter::addFileToFilter($file);
             $this->addTestFile($file);
         }
     }
 }
示例#3
0
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('Adamantium Test Suite');
     $directories = getTestDirectories();
     foreach ($directories as $directory) {
         foreach (glob($directory . '*.test.php') as $file) {
             $class = preg_replace('/(.*)\\.test\\.php/', '\\1', basename($file));
             require_once $file;
             $suite->addTestSuite($class . 'Test');
         }
     }
     PHPUnit_Util_Filter::addFileToFilter('test.php');
     PHPUnit_Util_Filter::addFileToFilter('settings.php');
     return $suite;
 }
示例#4
0
 public static function addTests($suite, $files)
 {
     foreach ($files as $file) {
         if (is_array($file)) {
             self::addTests($suite, $file);
         } else {
             if (is_file($file)) {
                 // The default PHPUnit TestCase extension
                 if (!strpos($file, 'TestCase' . EXT)) {
                     $suite->addTestFile($file);
                 } else {
                     require_once $file;
                 }
                 PHPUnit_Util_Filter::addFileToFilter($file);
             }
         }
     }
 }
示例#5
0
文件: PHPUnitTask.php 项目: hunde/bsc
 /**
  * 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.
  */
 function init()
 {
     if (version_compare(PHP_VERSION, '5.0.3') < 0) {
         throw new BuildException("PHPUnit2Task requires PHP version >= 5.0.3.", $this->getLocation());
     }
     /**
      * Determine PHPUnit version number
      */
     @(include_once 'PHPUnit/Runner/Version.php');
     @(include_once 'PHPUnit2/Runner/Version.php');
     if (class_exists('PHPUnit_Runner_Version')) {
         $version = PHPUnit_Runner_Version::id();
     } elseif (class_exists('PHPUnit2_Runner_Version')) {
         $version = PHPUnit2_Runner_Version::id();
     } else {
         throw new BuildException("PHPUnit task depends on PHPUnit 2 or 3 package being installed.", $this->getLocation());
     }
     if (version_compare($version, "3.0.0") >= 0) {
         PHPUnitUtil::$installedVersion = 3;
         if (version_compare($version, "3.2.0") >= 0) {
             PHPUnitUtil::$installedMinorVersion = 2;
         }
     } else {
         PHPUnitUtil::$installedVersion = 2;
     }
     /**
      * 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';
     /**
      * Add some defaults to the PHPUnit filter
      */
     $pwd = dirname(__FILE__);
     if (PHPUnitUtil::$installedVersion == 3) {
         require_once 'PHPUnit/Framework.php';
         require_once 'PHPUnit/Util/Filter.php';
         // point PHPUnit_MAIN_METHOD define to non-existing method
         if (!defined('PHPUnit_MAIN_METHOD')) {
             define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
         }
         PHPUnit_Util_Filter::addFileToFilter($pwd . '/PHPUnitTask.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter($pwd . '/PHPUnitTestRunner.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Task.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Target.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Project.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Phing.php', 'PHING');
     } else {
         require_once 'PHPUnit2/Framework.php';
         require_once 'PHPUnit2/Util/Filter.php';
         PHPUnit2_Util_Filter::addFileToFilter($pwd . '/PHPUnitTask.php');
         PHPUnit2_Util_Filter::addFileToFilter($pwd . '/PHPUnitTestRunner.php');
         PHPUnit2_Util_Filter::addFileToFilter($pwd . '/../../../Task.php');
         PHPUnit2_Util_Filter::addFileToFilter($pwd . '/../../../Target.php');
         PHPUnit2_Util_Filter::addFileToFilter($pwd . '/../../../Project.php');
         PHPUnit2_Util_Filter::addFileToFilter($pwd . '/../../../Phing.php');
     }
 }
示例#6
0
 /**
  * Add files to test suite $suite
  *
  * Uses recursion to scan subdirectories
  *
  * @param PHPUnit_Framework_TestSuite  $suite   The test suite to add to
  * @param array                        $files   Array of files to test
  */
 static function addTests(PHPUnit_Framework_TestSuite $suite, array $files)
 {
     foreach ($files as $file) {
         if (is_array($file)) {
             self::addTests($suite, $file);
         } else {
             // Make sure we only include php files
             if (is_file($file) and substr($file, -strlen(EXT)) === EXT) {
                 // The default PHPUnit TestCase extension
                 if (!strpos($file, 'TestCase' . EXT)) {
                     $suite->addTestFile($file);
                 } else {
                     require_once $file;
                 }
                 PHPUnit_Util_Filter::addFileToFilter($file);
             }
         }
     }
 }
示例#7
0
文件: suite.php 项目: bmdevel/ezc
*/
require_once 'formatting_properties.php';
require_once 'formatting_property_collection.php';
require_once 'paragraph_property_generator_test.php';
require_once 'text_property_generator_test.php';
require_once 'style.php';
require_once 'style_converters.php';
require_once 'text_processor_test.php';
require_once 'list_level_style_test.php';
require_once 'style_parser_test.php';
require_once 'style_extractor_test.php';
require_once 'meta_generator_test.php';
/**
 * This file is not in use, yet, therefore not tested.
 */
PHPUnit_Util_Filter::addFileToFilter(dirname(__FILE__) . '/../../src/document/xml/odt/filter/element/html_table.php');
class ezcDocumentOdtSuite extends PHPUnit_Framework_TestSuite
{
    public static function suite()
    {
        return new ezcDocumentOdtSuite();
    }
    public function __construct()
    {
        parent::__construct();
        $this->setName("Document ODT tests");
        $this->addTest(ezcDocumentOdtFormattingPropertiesTest::suite());
        $this->addTest(ezcDocumentOdtFormattingPropertyCollectionTest::suite());
        $this->addTest(ezcDocumentOdtStyleParagraphPropertyGeneratorTest::suite());
        $this->addTest(ezcDocumentOdtStyleTextPropertyGeneratorTest::suite());
        $this->addTest(ezcDocumentOdtStyleTest::suite());
示例#8
0
 /**
  * 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) {
         PHPUnit_Util_Filter::addFileToFilter($blacklistedFile, 'PHPUNIT');
     }
 }
示例#9
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.
  */
 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';
     /**
      * Add some defaults to the PHPUnit filter
      */
     $pwd = dirname(__FILE__);
     require_once 'PHPUnit/Framework.php';
     require_once 'PHPUnit/Util/Filter.php';
     // point PHPUnit_MAIN_METHOD define to non-existing method
     if (!defined('PHPUnit_MAIN_METHOD')) {
         define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
     }
     PHPUnit_Util_Filter::addFileToFilter($pwd . '/PHPUnitTask.php');
     PHPUnit_Util_Filter::addFileToFilter($pwd . '/PHPUnitTestRunner.php');
     PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Task.php');
     PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Target.php');
     PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Project.php');
     PHPUnit_Util_Filter::addFileToFilter($pwd . '/../../../Phing.php');
 }
示例#10
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.
  */
 function init()
 {
     if (version_compare(PHP_VERSION, '5.0.3') < 0) {
         throw new BuildException("PHPUnit2Task requires PHP version >= 5.0.3.", $this->getLocation());
     }
     /**
      * Ugly hack to get PHPUnit version number
      */
     $config = new PEAR_Config();
     $registry = new PEAR_Registry($config->get('php_dir'));
     $pkg_info = $registry->_packageInfo("PHPUnit", null, "pear.phpunit.de");
     if ($pkg_info != NULL) {
         if (version_compare($pkg_info['version']['api'], "3.0.0") >= 0) {
             PHPUnitUtil::$installedVersion = 3;
         } else {
             PHPUnitUtil::$installedVersion = 2;
         }
     } else {
         /**
          * Try to find PHPUnit2
          */
         require_once 'PHPUnit2/Util/Filter.php';
         if (!class_exists('PHPUnit2_Util_Filter')) {
             throw new BuildException("PHPUnit2Task depends on PEAR PHPUnit2 package being installed.", $this->getLocation());
         }
         PHPUnitUtil::$installedVersion = 2;
     }
     // 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';
     //require_once 'phing/tasks/ext/phpunit/SummaryPHPUnit2ResultFormatter.php';
     // add some defaults to the PHPUnit filter
     if (PHPUnitUtil::$installedVersion == 3) {
         require_once 'PHPUnit/Util/Filter.php';
         // point PHPUnit_MAIN_METHOD define to non-existing method
         define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
         PHPUnit_Util_Filter::addFileToFilter('PHPUnitTask.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('PHPUnitTestRunner.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Task.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Target.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Project.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Phing.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing.php', 'PHING');
     } else {
         require_once 'PHPUnit2/Util/Filter.php';
         PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTask.php');
         PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTestRunner.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Task.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Target.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Project.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Phing.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing.php');
     }
 }
示例#11
0
 /**
  * @param string $type      The type of concrete Log subclass to use.
  *                          Currently, valid values are 'console',
  *                          'syslog', 'sql', 'file', and 'mcal'.
  * @param string $name      The name of the actually log file, table, or
  *                          other specific store to use. Defaults to an
  *                          empty string, with which the subclass will
  *                          attempt to do something intelligent.
  * @param string $ident     The identity reported to the log system.
  * @param array  $conf      A hash containing any additional configuration
  *                          information that a subclass might need.
  * @param int $maxLevel     Maximum priority level at which to log.
  */
 public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG)
 {
     if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Log.php')) {
         PHPUnit_Util_Filesystem::collectStart();
         require_once 'Log.php';
         $this->log = Log::factory($type, $name, $ident, $conf, $maxLevel);
         foreach (PHPUnit_Util_Filesystem::collectEnd() as $blacklistedFile) {
             PHPUnit_Util_Filter::addFileToFilter($blacklistedFile, 'PHPUNIT');
         }
     } else {
         throw new RuntimeException('Log is not available.');
     }
 }
示例#12
0
文件: AllTests.php 项目: lortnus/zf1
 *
 * @category   Zend
 * @package    Zend_Ldap
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $
 */
/**
 * Test helper
 */
require_once dirname(__FILE__) . '/../../TestHelper.php';
if (!defined('PHPUnit_MAIN_METHOD')) {
    define('PHPUnit_MAIN_METHOD', 'Zend_Ldap_AllTests::main');
}
PHPUnit_Util_Filter::addFileToFilter(__FILE__);
/**
 * @see Zend_Ldap_OfflineTest
 */
require_once 'Zend/Ldap/OfflineTest.php';
/**
 * @category   Zend
 * @package    Zend_Ldap
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Ldap_AllTests
{
    public static function main()
    {
示例#13
0
 /**
  * @param  array $arguments
  * @since  Method available since Release 3.2.1
  */
 protected function handleConfiguration(array &$arguments)
 {
     if (isset($arguments['configuration'])) {
         $arguments['configuration'] = new PHPUnit_Util_Configuration($arguments['configuration']);
         $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration();
     } else {
         $arguments['pmd'] = array();
     }
     $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
     $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
     $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE;
     $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : '';
     $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
     $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE;
     if (isset($arguments['configuration'])) {
         $arguments['configuration']->handlePHPConfiguration();
         $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
         PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
         foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToFilter($file);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromFilter($file);
         }
         foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToWhitelist($file);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromWhitelist($file);
         }
         $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
         if (isset($phpunitConfiguration['ansi']) && !isset($arguments['ansi'])) {
             $arguments['ansi'] = $phpunitConfiguration['ansi'];
         }
         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['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
             $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
         }
         $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'];
         }
         $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['coverage-xml']) && !isset($arguments['coverageClover'])) {
             $arguments['coverageClover'] = $loggingConfiguration['coverage-xml'];
         }
         if (isset($loggingConfiguration['coverage-source']) && !isset($arguments['coverageSource'])) {
             $arguments['coverageSource'] = $loggingConfiguration['coverage-source'];
         }
         if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) {
             $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz'];
         }
         if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
             $arguments['jsonLogfile'] = $loggingConfiguration['json'];
         }
         if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) {
             $arguments['metricsXML'] = $loggingConfiguration['metrics-xml'];
         }
         if (isset($loggingConfiguration['plain'])) {
             $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
         }
         if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) {
             if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) {
                 $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines'];
             }
             if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) {
                 $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches'];
             }
             $arguments['pmdXML'] = $loggingConfiguration['pmd-xml'];
         }
         if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
             $arguments['tapLogfile'] = $loggingConfiguration['tap'];
         }
         if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) {
             $arguments['xmlLogfile'] = $loggingConfiguration['test-xml'];
             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'];
         }
         $browsers = $arguments['configuration']->getSeleniumBrowserConfiguration();
         if (!empty($browsers)) {
             require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
             PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
         }
     }
     $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
     $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
     $arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : 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['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;
 }
 /**
  * Constructor.
  *
  * @param  mixed $out
  */
 public function __construct($out = NULL)
 {
     if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Image/GraphViz.php')) {
         PHPUnit_Util_Filesystem::collectStart();
         require_once 'Image/GraphViz.php';
         $this->graph = new Image_GraphViz(TRUE, array('overlap' => 'scale', 'splines' => 'true', 'sep' => '.1', 'fontsize' => '8'));
         parent::__construct($out);
         foreach (PHPUnit_Util_Filesystem::collectEnd() as $blacklistedFile) {
             PHPUnit_Util_Filter::addFileToFilter($blacklistedFile, 'PHPUNIT');
         }
     } else {
         throw new RuntimeException('Image_GraphViz is not available.');
     }
 }
示例#15
0
 /**
  * Blacklist a set of files in PHPUnit code coverage
  *
  * @param array $blacklist_items A set of files to blacklist
  * @param Unittest_TestSuite $suite The test suite
  */
 public static function blacklist(array $blacklist_items, Unittest_TestSuite $suite = NULL)
 {
     if (self::$phpunit_v35) {
         foreach ($blacklist_items as $item) {
             if (is_dir($item)) {
                 $suite->addDirectoryToBlacklist($item);
             } else {
                 $suite->addFileToBlacklist($item);
             }
         }
     } else {
         foreach ($blacklist_items as $item) {
             if (is_dir($item)) {
                 PHPUnit_Util_Filter::addDirectoryToFilter($item);
             } else {
                 PHPUnit_Util_Filter::addFileToFilter($item);
             }
         }
     }
 }
示例#16
0
文件: PHPUnit.php 项目: swk/bluebox
 protected function _blacklist()
 {
     PHPUnit_Util_Filter::addFileToFilter(__FILE__);
     $folders = array('vendor', 'libraries/drivers/Database');
     foreach ($folders as $folder) {
         $files = self::list_files($folder, TRUE);
         foreach ($files as $file) {
             if (is_file($file)) {
                 PHPUnit_Util_Filter::addFileToFilter($file);
                 PHPUnit_Util_Filter::removeFileFromWhitelist($file);
             }
         }
     }
 }
<?php

/**
 * @author David Rogers <*****@*****.**>
 * @package Test_Model
 * @category Test_Cases
 */
/**
 * Require the parent class: ethos_Test_TestCase
 */
require_once 'ethos/Test/TestCase.php';
/**
 * Exclude this file from the code coverage reports when running simple unit tests
 * on test fixtures.
 */
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'UNIT_TESTS');
/**
 * @author David Rogers <*****@*****.**>
 * @package Test_Model
 * @category Test_Cases
 *
 * @todo Add test_get_default() to test getting a yet-unset field returns the default value
 * @todo Add test_getStorage_bogus() to test getting a bogus Storage adapter
 * @todo Add test_getStorage_new() to test instantiating a Storage adapter from the "storage" option
 */
class Test_Model_AbstractTest extends ethos_Test_TestCase
{
    /**
     * A common assertion for the Model test cases is that an array $fixture (usually
     * the $sharedFixture) has a particular $field and that the expected $value
     * is set to that position.
示例#18
0
 private function handleCoverageFilter($file)
 {
     if ($this->consider_covers_files == false) {
         return;
     }
     $data = file_get_contents($file);
     foreach (explode("\n", $data) as $line) {
         $file = str_replace(array('BASE', 'APP', 'LIB', 'FWK', '*'), array(AK_BASE_DIR, AK_APP_DIR, AK_LIB_DIR, AK_FRAMEWORK_DIR, ''), $line);
         if (is_file($file)) {
             $this->consider_covers_files == 'white' ? PHPUnit_Util_Filter::addFileToWhitelist($file) : PHPUnit_Util_Filter::addFileToFilter($file);
         } elseif (is_dir($file)) {
             $this->consider_covers_files == 'white' ? PHPUnit_Util_Filter::addDirectoryToWhitelist($file) : PHPUnit_Util_Filter::addDirectoryToFilter($file);
         }
     }
 }
示例#19
0
<?php

// PHPUnit 3.4 compat
if (method_exists('PHPUnit_Util_Filter', 'addDirectoryToFilter')) {
    PHPUnit_Util_Filter::addDirectoryToFilter(__DIR__);
    PHPUnit_Util_Filter::addFileToFilter(__DIR__ . '/../src/Jackalope/Transport/curl.php');
}
/**
 * Bootstrap file for jackalope
 *
 * This file does some basic stuff that's project specific.
 *
 * function getRepository(config) which returns the repository
 * function getJCRSession(config) which returns the session
 *
 * TODO: remove the following once it has been moved to a base file
 * function getSimpleCredentials(user, password) which returns simpleCredentials
 *
 * constants necessary to the JCR 1.0/JSR-170 and JSR-283 specs
 */
// Make sure we have the necessary config
$necessaryConfigValues = array('jcr.url', 'jcr.user', 'jcr.pass', 'jcr.workspace', 'jcr.transport');
foreach ($necessaryConfigValues as $val) {
    if (empty($GLOBALS[$val])) {
        die('Please set ' . $val . ' in your phpunit.xml.' . "\n");
    }
}
/** autoloader: jackalope-api-tests relies on an autoloader.
 */
require_once dirname(__FILE__) . '/../src/Jackalope/autoloader.php';
/**
示例#20
0
 /**
  * Constructs a new TestSuite:
  *
  *   - PHPUnit_Framework_TestSuite() constructs an empty TestSuite.
  *
  *   - PHPUnit_Framework_TestSuite(ReflectionClass) constructs a
  *     TestSuite from the given class.
  *
  *   - PHPUnit_Framework_TestSuite(ReflectionClass, String)
  *     constructs a TestSuite from the given class with the given
  *     name.
  *
  *   - PHPUnit_Framework_TestSuite(String) either constructs a
  *     TestSuite from the given class (if the passed string is the
  *     name of an existing class) or constructs an empty TestSuite
  *     with the given name.
  *
  * @param  mixed  $theClass
  * @param  string $name
  * @throws InvalidArgumentException
  * @access public
  */
 public function __construct($theClass = '', $name = '')
 {
     $argumentsValid = FALSE;
     if (is_object($theClass) && $theClass instanceof ReflectionClass) {
         $argumentsValid = TRUE;
     } else {
         if (is_string($theClass) && $theClass !== '' && class_exists($theClass, FALSE)) {
             $argumentsValid = TRUE;
             if ($name == '') {
                 $name = $theClass;
             }
             $theClass = new ReflectionClass($theClass);
         } else {
             if (is_string($theClass)) {
                 $this->setName($theClass);
                 return;
             }
         }
     }
     if (!$argumentsValid) {
         throw new InvalidArgumentException();
     }
     PHPUnit_Util_Filter::addFileToFilter(realpath($theClass->getFilename()), 'TESTS');
     if ($name != '') {
         $this->setName($name);
     } else {
         $this->setName($theClass->getName());
     }
     $constructor = $theClass->getConstructor();
     if ($constructor !== NULL && !$constructor->isPublic()) {
         $this->addTest(self::warning(sprintf('Class "%s" has no public constructor.', $theClass->getName())));
         return;
     }
     $className = $theClass->getName();
     $names = array();
     $classGroups = PHPUnit_Util_Test::getGroups($theClass);
     foreach ($theClass->getMethods() as $method) {
         if (strpos($method->getDeclaringClass()->getName(), 'PHPUnit_') !== 0) {
             $this->addTestMethod($method, PHPUnit_Util_Test::getGroups($method, $classGroups), $names, $theClass);
         }
     }
     if (empty($this->tests)) {
         $this->addTest(self::warning(sprintf('No tests found in class "%s".', $theClass->getName())));
     }
 }
示例#21
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['pmd'] = $arguments['configuration']->getPMDConfiguration();
     } else {
         $arguments['pmd'] = array();
     }
     $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['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE;
     $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : '';
     $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
     $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE;
     if (isset($arguments['configuration'])) {
         $arguments['configuration']->handlePHPConfiguration();
         $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
         PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
         foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix'], $dir['group'], $dir['prefix']);
         }
         foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToFilter($file);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix'], $dir['group'], $dir['prefix']);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromFilter($file);
         }
         foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
         }
         foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToWhitelist($file);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromWhitelist($file);
         }
         $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'];
         }
         $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['coverage-xml']) && !isset($arguments['coverageClover'])) {
             $arguments['coverageClover'] = $loggingConfiguration['coverage-xml'];
         }
         if (isset($loggingConfiguration['coverage-source']) && !isset($arguments['coverageSource'])) {
             $arguments['coverageSource'] = $loggingConfiguration['coverage-source'];
         }
         if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) {
             $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz'];
         }
         if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
             $arguments['jsonLogfile'] = $loggingConfiguration['json'];
         }
         if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) {
             $arguments['metricsXML'] = $loggingConfiguration['metrics-xml'];
         }
         if (isset($loggingConfiguration['plain'])) {
             $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
         }
         if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) {
             if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) {
                 $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines'];
             }
             if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) {
                 $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches'];
             }
             $arguments['pmdXML'] = $loggingConfiguration['pmd-xml'];
         }
         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'];
         }
     }
     $arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL;
     $arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL;
     $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
     $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
     $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;
     if ($arguments['filter'] !== FALSE && preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) {
         $arguments['filter'] = '/' . $arguments['filter'] . '/';
     }
 }
示例#22
0
 protected function updateTicket($ticketId, $newStatus, $message, $resolution)
 {
     if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('XML/RPC2/Client.php')) {
         PHPUnit_Util_Filesystem::collectStart();
         require_once 'XML/RPC2/Client.php';
         $ticket = XML_RPC2_Client::create($this->scheme . '://' . $this->username . ':' . $this->password . '@' . $this->hostpath, array('prefix' => 'ticket.'));
         try {
             $ticketInfo = $ticket->get($ticketId);
         } catch (XML_RPC2_FaultException $e) {
             throw new PHPUnit_Framework_Exception(sprintf("Trac fetch failure: %d: %s\n", $e->getFaultCode(), $e->getFaultString()));
         }
         try {
             printf("Updating Trac ticket #%d, status: %s\n", $ticketId, $newStatus);
             $ticket->update($ticketId, $message, array('status' => $newStatus, 'resolution' => $resolution));
         } catch (XML_RPC2_FaultException $e) {
             throw new PHPUnit_Framework_Exception(sprintf("Trac update failure: %d: %s\n", $e->getFaultCode(), $e->getFaultString()));
         }
         foreach (PHPUnit_Util_Filesystem::collectEnd() as $blacklistedFile) {
             PHPUnit_Util_Filter::addFileToFilter($blacklistedFile, 'PHPUNIT');
         }
     } else {
         throw new PHPUnit_Framework_Exception('XML_RPC2 is not available.');
     }
 }
示例#23
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);
     PHPUnit_Util_Timer::start();
     $buffer = $runner->run($this->filename, $options);
     $time = PHPUnit_Util_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)) {
         PHPUnit_Util_Filter::addFileToFilter($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->appendCodeCoverageInformation($this, $coverageData);
         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;
 }
示例#24
0
文件: tests.php 项目: azuya/Wi3
 /**
  * Blacklist a set of files in PHPUnit code coverage
  *
  * @param array A set of files to blacklist
  */
 public static function blacklist(array $blacklist_items)
 {
     if (self::$phpunit_v35) {
         $filter = PHP_CodeCoverage_Filter::getInstance();
         foreach ($blacklist_items as $item) {
             if (is_dir($item)) {
                 $filter->addDirectoryToBlacklist($item);
             } else {
                 $filter->addFileToBlacklist($item);
             }
         }
     } else {
         foreach ($blacklist_items as $item) {
             if (is_dir($item)) {
                 PHPUnit_Util_Filter::addDirectoryToFilter($item);
             } else {
                 PHPUnit_Util_Filter::addFileToFilter($item);
             }
         }
     }
 }
示例#25
0
文件: suite.php 项目: sdboyer/svnlib
<?php

require_once 'PHPUnit/Framework.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'SVNLIB');
/*class SvnlibPHPUnitTestSuite extends PHPUnit_Framework_TestSuite {

}*/
示例#26
0
 * 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     Jan Borsodi <*****@*****.**>
 * @author     Sebastian Bergmann <*****@*****.**>
 * @copyright  2002-2007 Sebastian Bergmann <*****@*****.**>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    SVN: $Id: Verifiable.php 537 2007-02-24 06:58:18Z sb $
 * @link       http://www.phpunit.de/
 * @since      File available since Release 3.0.0
 */
require_once 'PHPUnit/Util/Filter.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
/**
 * Interface for classes which must verify a given expectation.
 *
 * @category   Testing
 * @package    PHPUnit
 * @author     Jan Borsodi <*****@*****.**>
 * @author     Sebastian Bergmann <*****@*****.**>
 * @copyright  2002-2007 Sebastian Bergmann <*****@*****.**>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    Release: 3.2.5
 * @link       http://www.phpunit.de/
 * @since      Interface available since Release 3.0.0
 */
interface PHPUnit_Framework_MockObject_Verifiable
{
示例#27
0
 /**
  * @param  array $arguments
  * @access protected
  * @since  Method available since Release 3.2.1
  */
 protected function handleConfiguration(array &$arguments)
 {
     if (isset($arguments['configuration'])) {
         $arguments['configuration'] = new PHPUnit_Util_Configuration($arguments['configuration']);
         $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration();
     } else {
         $arguments['pmd'] = array();
     }
     $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
     $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
     $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE;
     $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
     $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : '';
     $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
     $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE;
     if (isset($arguments['configuration'])) {
         $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
         PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
         foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToFilter($file);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromFilter($file);
         }
         foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToWhitelist($file);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromWhitelist($file);
         }
         $phpConfiguration = $arguments['configuration']->getPHPConfiguration();
         foreach ($phpConfiguration['ini'] as $name => $value) {
             ini_set($name, $value);
         }
         foreach ($phpConfiguration['var'] as $name => $value) {
             $GLOBALS[$name] = $value;
         }
         $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'];
         }
         $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-xml']) && !isset($arguments['coverageXML'])) {
             $arguments['coverageXML'] = $loggingConfiguration['coverage-xml'];
         }
         if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) {
             $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz'];
         }
         if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
             $arguments['jsonLogfile'] = $loggingConfiguration['json'];
         }
         if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) {
             $arguments['metricsXML'] = $loggingConfiguration['metrics-xml'];
         }
         if (isset($loggingConfiguration['plain'])) {
             $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
         }
         if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) {
             if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) {
                 $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines'];
             }
             if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) {
                 $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches'];
             }
             $arguments['pmdXML'] = $loggingConfiguration['pmd-xml'];
         }
         if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
             $arguments['tapLogfile'] = $loggingConfiguration['tap'];
         }
         if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) {
             $arguments['xmlLogfile'] = $loggingConfiguration['test-xml'];
             if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
                 $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
             }
         }
         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'];
         }
     }
     $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
     $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
     $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
     $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
     $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
     $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
     $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
     $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
     $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
     $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
     if (isset($arguments['reportDirectory'])) {
         $arguments['reportDirectory'] = $this->getDirectory($arguments['reportDirectory']);
     }
 }