4) Each testXXX() method must return either TEST_PASSED or TEST_FAILED. If it does not, it is marked as being defective.
 public static function suite()
 {
     $suite = new TestSuite('AmpolirosCore');
     $suite->addTestSuite(new ReflectionClass('AmpolirosTest'));
     $suite->addTestSuite(new ReflectionClass('AmpConfigTest'));
     return $suite;
 }
Exemple #2
0
 function runAllTests()
 {
     $test = new TestSuite();
     $test->addTestFile($this->webTestDir . 'wtest_uploadform.php');
     $test->addTestFile($this->webTestDir . 'wtest_loginform.php');
     $test->run(new HtmlReporter());
 }
Exemple #3
0
 public static function suite()
 {
     $suite = new TestSuite('Haanga test suite');
     $suite->addTestSuite('templateTest');
     $suite->addTestSuite('errorTest');
     return $suite;
 }
 public static function suite()
 {
     require 'ampoliros.php';
     $suite = new TestSuite('Ampoliros');
     $suite->addTest(AllAmpolirosCoreTests::suite());
     $suite->addTest(AllAmpolirosDatatransferTests::suite());
     return $suite;
 }
 /**
  * Genereates a nice report of the test.
  *
  * It instantiate a SimpleTest TestSuite and launches a Reporter.
  * This method is typically called by a TestRunner.
  *
  * @return void
  * @see    KortTestRunner
  * @see    KortCliReporter
  * @see    KortHTMLReporter
  */
 public function report()
 {
     $test = new \TestSuite($this->getLabel());
     $test->add($this);
     if (\TextReporter::inCli()) {
         exit($test->run(new KortCliReporter()) ? 0 : 1);
     }
     $test->run(new KortHTMLReporter());
 }
Exemple #6
0
 /**
  * Check if the test object should be filtered out.
  *
  * @param TestSuite|TestCase $test
  * @return bool
  */
 protected function matched($test)
 {
     foreach ($this->groups as $group) {
         if ($test->in_group($group)) {
             return false;
         }
     }
     return true;
 }
 /**
  * Add child TestSuite to the provided TestSuite from the XML node
  *
  * @param TestSuite         $testSuite
  * @param \SimpleXMLElement $xml
  */
 public function addTestSuite(TestSuite $testSuite, \SimpleXMLElement $xml)
 {
     foreach ($xml->xpath('./testsuite') as $element) {
         $suite = new TestSuite((string) $element['name'], (string) $element['file'], (string) $element['namespace'], (string) $element['fullPackage']);
         $this->addTestCase($suite, $element);
         $this->addTestSuite($suite, $element);
         $testSuite->addTestSuite($suite);
     }
 }
 /**
  * Runs the indicated test case in isolation with the
  * URI: /simpletests/test/path/to/filename
  *
  * For example, to run test_user.php, indicate the path relative to the "tests" directory.
  * http://hostname/test/model/test_user.php
  */
 function test()
 {
     $nodes = Router::$segments;
     unset($nodes[0]);
     unset($nodes[1]);
     $path = implode('/', $nodes);
     $test = new TestSuite("Test " . $path);
     $test->addTestFile(APPPATH . "tests/" . $path);
     $test->run(new HtmlReporter());
 }
 public static function call_simpletest($task, $type = 'text', $dirs = array())
 {
     // remove E_STRICT because simpletest is not E_STRICT compatible
     $old_error_reporting = error_reporting();
     $new_error_reporting = $old_error_reporting;
     if ($new_error_reporting & E_STRICT) {
         $new_error_reporting = $new_error_reporting ^ E_STRICT;
     }
     include_once 'simpletest/unit_tester.php';
     include_once 'simpletest/web_tester.php';
     if (!class_exists('TestSuite')) {
         throw new pakeException('You must install SimpleTest to use this task.');
     }
     require_once 'simpletest/reporter.php';
     require_once 'simpletest/mock_objects.php';
     set_include_path('test' . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path());
     $base_test_dir = 'test';
     $test_dirs = array();
     // run tests only in these subdirectories
     if ($dirs) {
         foreach ($dirs as $dir) {
             $test_dirs[] = $base_test_dir . DIRECTORY_SEPARATOR . $dir;
         }
     } else {
         $test_dirs[] = $base_test_dir;
     }
     $test = new TestSuite('Test suite in (' . implode(', ', $test_dirs) . ')');
     $files = pakeFinder::type('file')->name('*Test.php')->in($test_dirs);
     if (count($files) > 0) {
         foreach ($files as $file) {
             $test->addFile($file);
         }
         ob_start();
         if ($type == 'html') {
             $result = $test->run(new HtmlReporter());
         } else {
             if ($type == 'xml') {
                 $result = $test->run(new XmlReporter());
             } else {
                 $result = $test->run(new TextReporter());
             }
         }
         $content = ob_get_contents();
         ob_end_clean();
         if ($task->is_verbose()) {
             echo $content;
         }
     } else {
         throw new pakeException('No test to run.');
     }
     error_reporting($old_error_reporting);
 }
Exemple #10
0
 public function testContentOfRecorderWithOnePassAndOneFailure()
 {
     $test = new TestSuite();
     $test->addFile(dirname(__FILE__) . '/support/recorder_sample.php');
     $recorder = new Recorder(new SimpleReporter());
     $test->run($recorder);
     $this->assertEqual(count($recorder->results), 2);
     $this->assertIsA($recorder->results[0], 'SimpleResultOfPass');
     $this->assertEqual('testTrueIsTrue', array_pop($recorder->results[0]->breadcrumb));
     $this->assertPattern('/ at \\[.*\\Wrecorder_sample\\.php line 9\\]/', $recorder->results[0]->message);
     $this->assertIsA($recorder->results[1], 'SimpleResultOfFail');
     $this->assertEqual('testFalseIsTrue', array_pop($recorder->results[1]->breadcrumb));
     $this->assertPattern("/Expected false, got \\[Boolean: true\\] at \\[.*\\Wrecorder_sample\\.php line 14\\]/", $recorder->results[1]->message);
 }
Exemple #11
0
 public static function suite()
 {
     $suite = new TestSuite('onPHP-' . ONPHP_VERSION);
     foreach (self::$paths as $testPath) {
         foreach (glob($testPath . '*Test' . EXT_CLASS, GLOB_BRACE) as $file) {
             $suite->addTestFile($file);
         }
     }
     // meta, DB and DAOs ordered tests portion
     if (self::$dbs) {
         try {
             Singleton::getInstance('DBTestPool', self::$dbs)->connect();
         } catch (Exception $e) {
             Singleton::dropInstance('DBTestPool');
             Singleton::getInstance('DBTestPool');
         }
         // build stuff from meta
         $metaDir = ONPHP_TEST_PATH . 'meta' . DIRECTORY_SEPARATOR;
         $path = ONPHP_META_PATH . 'bin' . DIRECTORY_SEPARATOR . 'build.php';
         $_SERVER['argv'] = array();
         $_SERVER['argv'][0] = $path;
         $_SERVER['argv'][1] = $metaDir . 'config.inc.php';
         $_SERVER['argv'][2] = $metaDir . 'config.meta.xml';
         $_SERVER['argv'][] = '--force';
         $_SERVER['argv'][] = '--no-schema-check';
         $_SERVER['argv'][] = '--drop-stale-files';
         include $path;
         // provide paths to autogenerated stuff
         set_include_path(get_include_path() . PATH_SEPARATOR . ONPHP_META_AUTO_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_DAO_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_PROTO_DIR . PATH_SEPARATOR . ONPHP_META_DAO_DIR . PATH_SEPARATOR . ONPHP_META_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_PROTO_DIR);
         $daoTest = new DAOTest();
         $out = MetaConfiguration::me()->getOutput();
         foreach (DBTestPool::me()->getPool() as $connector => $db) {
             DBPool::me()->setDefault($db);
             $out->info('Using ')->info(get_class($db), true)->infoLine(' connector.');
             try {
                 $daoTest->drop();
             } catch (DatabaseException $e) {
                 // previous shutdown was clean
             }
             $daoTest->create()->fill(false);
             MetaConfiguration::me()->checkIntegrity();
             $out->newLine();
             $daoTest->drop();
         }
         DBPool::me()->dropDefault();
     }
     $suite->addTestSuite('DAOTest');
     return $suite;
 }
 /**
  * @param TestSuite $testSuite
  * @param $file
  */
 public function save(TestSuite $testSuite, $file)
 {
     $close = false;
     if (!is_resource($file)) {
         $file = fopen($file, 'w');
         $close = true;
     }
     fwrite($file, "<?xml version=\"1.0\" ?>\n");
     fwrite($file, "<testsuites>\n");
     fwrite($file, (string) $testSuite->toXml());
     fwrite($file, "</testsuites>");
     if ($close) {
         fclose($file);
     }
 }
Exemple #13
0
 function runAllTests()
 {
     $test = new TestSuite();
     /*//$test->addTestFile(dirname(__FILE__).'/testcrud.php');
     		$test->addTestFile(dirname(__FILE__).'/testdatabase.php');
     		$test->addTestFile(dirname(__FILE__).'/testcrudasmodel.php');
     		//$test->addTestFile(dirname(__FILE__).'/testusersignup.php'); obselete - users store themselves
     		$test->addTestFile(dirname(__FILE__).'/testupload.php');
     		$test->addTestFile(dirname(__FILE__).'/testscript.php');
     		$test->addTestFile(dirname(__FILE__).'/testmarkjson.php');
     		$test->addTestFile(dirname(__FILE__).'/testpayment.php');
     		$test->addTestFile(dirname(__FILE__).'/testpagegroup.php');*/
     $test->addTestFile(dirname(__FILE__) . '/testscript.php');
     $test->run(new HtmlReporter());
 }
 /**
  * @param \Iterator $files
  * @param TestSuite $testSuite
  *
  * @return TestSuite
  */
 public function merge(\Iterator $files, TestSuite $testSuite = null)
 {
     if (!$testSuite) {
         $testSuite = new TestSuite(null, null, null, null);
     }
     $loader = new PHPUnitLoader();
     foreach ($files as $file) {
         $suite = $loader->load($file->getContents());
         if (!$suite) {
             continue;
         }
         $testSuite->addTestSuite($suite);
     }
     return $testSuite;
 }
Exemple #15
0
 function testPass()
 {
     $listener = new MockSimpleSocket();
     $fullpath = realpath(dirname(__FILE__) . '/support/test1.php');
     $testpath = EclipseReporter::escapeVal($fullpath);
     $expected = "{status:\"pass\",message:\"pass1 at [{$testpath} line 4]\",group:\"{$testpath}\",case:\"test1\",method:\"test_pass\"}";
     //this should work...but it doesn't so the next line and the last line are the hacks
     //$listener->expectOnce('write',array($expected));
     $listener->setReturnValue('write', -1);
     $pathparts = pathinfo($fullpath);
     $filename = $pathparts['basename'];
     $test = new TestSuite($filename);
     $test->addTestFile($fullpath);
     $test->run(new EclipseReporter($listener));
     $this->assertEqual($expected, $listener->output);
 }
Exemple #16
0
 function __construct()
 {
     parent::__construct();
     $dr = $_SERVER['DOCUMENT_ROOT'] . "/dtest/utests/";
     $this->addFile($dr . 'ControllerTests.php');
     $this->addFile($dr . 'ViewTests.php');
 }
 function __construct()
 {
     parent::__construct();
     $this->addFile(dirname(__FILE__) . '/unit/unit-test-wpps-module.php');
     $this->addFile(dirname(__FILE__) . '/unit/unit-test-wpps-settings.php');
     $this->addFile(dirname(__FILE__) . '/unit/unit-test-wpps-instance-class.php');
 }
 public function __construct()
 {
     parent::__construct();
     $this->addFile(TestPath . 'languageforge/lexicon/dto/LexBaseViewDto_Test.php');
     $this->addFile(TestPath . 'languageforge/lexicon/dto/LexDbeDto_Test.php');
     $this->addFile(TestPath . 'languageforge/lexicon/dto/LexProjectDto_Test.php');
 }
Exemple #19
0
 function __construct()
 {
     parent::__construct('All tests');
     $p = dirname(__FILE__);
     ini_set('include_path', dirname($p) . PATH_SEPARATOR . ini_get('include_path'));
     $this->addFile($p . '/ForgeUpgrade_BucketFilterTest.php');
 }
 /**
  * Extend run() method to recognize cli mode.
  *
  * @param SimpleReporter Reporter for HTML mode
  * @param SimpleReporter Reporter for CLI mode
  * @access public
  */
 function run(&$htmlReporter, &$cliReporter)
 {
     if (EvoTextReporter::inCli()) {
         exit(parent::run($cliReporter) ? 0 : 1);
     }
     parent::run($htmlReporter);
 }
Exemple #21
0
 public function __construct()
 {
     parent::__construct('Gihp porcelain tests');
     $this->add(new porcelain\tree());
     $this->add(new porcelain\tag());
     $this->add(new porcelain\branch());
 }
 public function __construct()
 {
     parent::__construct();
     $this->addFile(TestPath . 'languageforge/semdomtrans/commands/AllTests.php');
     $this->addFile(TestPath . 'languageforge/semdomtrans/dto/AllTests.php');
     $this->addFile(TestPath . 'languageforge/semdomtrans/models/AllTests.php');
 }
Exemple #23
0
 public function __construct()
 {
     parent::__construct('RemoteCP Versioning System Tests');
     $this->addFile(__DIR__ . '/base_test.php');
     $this->addFile(__DIR__ . '/semver_test.php');
     $this->addFile(__DIR__ . '/regression_test.php');
 }
 public function __construct()
 {
     parent::__construct();
     $this->addFile(TestPath . 'scriptureforge/commands/TextCommands_Test.php');
     $this->addFile(TestPath . 'scriptureforge/commands/SessionCommands_Test.php');
     $this->addFile(TestPath . 'scriptureforge/commands/QuestionCommands_Test.php');
     $this->addFile(TestPath . 'scriptureforge/commands/SfchecksUploadCommands_Test.php');
 }
 function SqlWrapperNGTestSuite()
 {
     parent::TestSuite("SQLWrapper New Generation");
     $this->addTestFile('core/tests/sqlwrapperng/base.sqlcreator.class.test.php');
     $this->addTestFile('core/tests/sqlwrapperng/mysql.sqlcreator.class.test.php');
     $this->addTestFile('core/tests/sqlwrapperng/datafield.class.test.php');
     $this->addTestFile('core/tests/sqlwrapperng/datatable.class.test.php');
 }
 protected function Form_Create()
 {
     $filesToSkip = array("QUnitTestCaseBase.php", "QTestForm.tpl.php");
     $arrFiles = QFolder::listFilesInFolder(__QCUBED_CORE__ . '/tests/qcubed-unit/');
     $arrTests = array();
     foreach ($arrFiles as $filename) {
         if (!in_array($filename, $filesToSkip)) {
             require_once __QCUBED_CORE__ . '/tests/qcubed-unit/' . $filename;
             $arrTests[] = str_replace(".php", "", $filename);
         }
     }
     $suite = new TestSuite('QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - SimpleTest ' . SimpleTest::getVersion());
     foreach ($arrTests as $className) {
         $suite->add(new $className($this));
     }
     $suite->run(new QHtmlReporter());
 }
 function __construct()
 {
     parent::__construct();
     $this->addFile('UnitToppaAutoLoaderWp.php');
     $this->addFile('UnitToppaDatabaseFacadeWp.php');
     $this->addFile('UnitToppaFunctions.php');
     $this->addFile('UnitToppaHtmlFormField.php');
 }
Exemple #28
0
 function __construct()
 {
     parent::__construct('All tests for SimpleTest ' . SimpleTest::getVersion());
     $this->addFile(dirname(__FILE__) . '/unit_tests.php');
     $this->addFile(dirname(__FILE__) . '/shell_test.php');
     $this->addFile(dirname(__FILE__) . '/live_test.php');
     $this->addFile(dirname(__FILE__) . '/acceptance_test.php');
 }
 public function __construct()
 {
     parent::__construct();
     $this->addFile(TestPath . 'libraries/scriptureforge/AllTests.php');
     $this->addFile(TestPath . 'libraries/LanguageData_Test.php');
     $this->addFile(TestPath . 'libraries/ParatextExport_Test.php');
     $this->addFile(TestPath . 'libraries/Website_Test.php');
 }
 public static function suite()
 {
     $suite = new TestSuite('onPHP-' . ONPHP_VERSION);
     // meta, DB and DAOs ordered tests portion
     if (self::$dbs) {
         try {
             /**
              * @todo fail - constructor with argument, but static method 'me' - without
              */
             Singleton::getInstance('DBTestPool', self::$dbs)->connect();
         } catch (Exception $e) {
             Singleton::dropInstance('DBTestPool');
             Singleton::getInstance('DBTestPool');
         }
         // build stuff from meta
         $metaDir = ONPHP_TEST_PATH . 'meta' . DIRECTORY_SEPARATOR;
         $path = ONPHP_META_PATH . 'bin' . DIRECTORY_SEPARATOR . 'build.php';
         $_SERVER['argv'] = array();
         $_SERVER['argv'][0] = $path;
         $_SERVER['argv'][1] = $metaDir . 'config.inc.php';
         $_SERVER['argv'][2] = $metaDir . 'config.meta.xml';
         $_SERVER['argv'][] = '--force';
         $_SERVER['argv'][] = '--no-schema-check';
         $_SERVER['argv'][] = '--drop-stale-files';
         include $path;
         AutoloaderPool::get('onPHP')->addPaths(array(ONPHP_META_AUTO_BUSINESS_DIR, ONPHP_META_AUTO_DAO_DIR, ONPHP_META_AUTO_PROTO_DIR, ONPHP_META_DAO_DIR, ONPHP_META_BUSINESS_DIR, ONPHP_META_PROTO_DIR));
         $dBCreator = DBTestCreator::create()->setSchemaPath(ONPHP_META_AUTO_DIR . 'schema.php')->setTestPool(DBTestPool::me());
         $out = MetaConfiguration::me()->getOutput();
         foreach (DBTestPool::me()->getPool() as $connector => $db) {
             DBPool::me()->setDefault($db);
             $out->info('Using ')->info(get_class($db), true)->infoLine(' connector.');
             $dBCreator->dropDB(true);
             $dBCreator->createDB()->fillDB();
             MetaConfiguration::me()->checkIntegrity();
             $out->newLine();
             $dBCreator->dropDB();
         }
         DBPool::me()->dropDefault();
     }
     foreach (self::$paths as $testPath) {
         foreach (glob($testPath . '*Test' . EXT_CLASS, GLOB_BRACE) as $file) {
             $suite->addTestFile($file);
         }
     }
     return $suite;
 }