当前位置: 首页>>代码示例>>PHP>>正文


PHP TestSuite::addFile方法代码示例

本文整理汇总了PHP中TestSuite::addFile方法的典型用法代码示例。如果您正苦于以下问题:PHP TestSuite::addFile方法的具体用法?PHP TestSuite::addFile怎么用?PHP TestSuite::addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestSuite的用法示例。


在下文中一共展示了TestSuite::addFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: glob

 function __construct()
 {
     parent::TestSuite("All Generic Tephlon Tests");
     $tFiles = glob("*Test.php");
     foreach ($tFiles as $f) {
         echo "adding {$f}";
         parent::addFile($f);
         parent::run(new TextReporter());
     }
 }
开发者ID:vladikius,项目名称:tephlon,代码行数:10,代码来源:BasicTestSuite.php

示例2: call_simpletest

 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);
 }
开发者ID:rosko,项目名称:pake,代码行数:52,代码来源:pakeSimpletestTask.class.php

示例3: testContentOfRecorderWithOnePassAndOneFailure

 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);
 }
开发者ID:guicara,项目名称:simpletest,代码行数:14,代码来源:recorder_test.php

示例4: testPass

 public 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->returnsByValue('write', -1);
     $pathparts = pathinfo($fullpath);
     $filename = $pathparts['basename'];
     $test = new TestSuite($filename);
     $test->addFile($fullpath);
     $test->run(new EclipseReporter($listener));
     $this->assertEqual($expected, $listener->output);
 }
开发者ID:simpletest,项目名称:simpletest,代码行数:16,代码来源:eclipse_test.php

示例5: TestSuite

 function testContentOfRecorderWithOnePassAndOneFailure()
 {
     $test = new TestSuite();
     $test->addFile(dirname(__FILE__) . '/sample.php');
     $recorder = new Recorder();
     $test->run($recorder);
     $this->assertEqual(count($recorder->results), 2);
     $d = '[\\\\\\/]';
     // backslash or slash
     $this->assertEqual(count($recorder->results[0]), 4);
     $this->assertPattern("/" . substr(time(), 9) . "/", $recorder->results[0]['time']);
     $this->assertEqual($recorder->results[0]['status'], "Passed");
     $this->assertPattern("/sample\\.php->SampleTestForRecorder->testTrueIsTrue/i", $recorder->results[0]['test']);
     $this->assertPattern("/ at \\[.*recorder{$d}test{$d}sample\\.php line 7\\]/", $recorder->results[0]['message']);
     $this->assertEqual(count($recorder->results[1]), 4);
     $this->assertPattern("/" . substr(time(), 9) . "/", $recorder->results[1]['time']);
     $this->assertEqual($recorder->results[1]['status'], "Failed");
     $this->assertPattern("/sample\\.php->SampleTestForRecorder->testFalseIsTrue/i", $recorder->results[1]['test']);
     $this->assertPattern("/Expected false, got \\[Boolean: true\\] at \\[.*recorder{$d}test{$d}sample\\.php line 11\\]/", $recorder->results[1]['message']);
 }
开发者ID:sebs,项目名称:simpletest,代码行数:20,代码来源:test.php

示例6: call_simpletest

 public static function call_simpletest(pakeTask $task, $type = 'text', $dirs = array())
 {
     if (!class_exists('TestSuite')) {
         throw new pakeException('You must install SimpleTest to use this task.');
     }
     SimpleTest::ignore('UnitTestCase');
     $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;
     }
     $files = pakeFinder::type('file')->name('*Test.php')->in($test_dirs);
     if (count($files) == 0) {
         throw new pakeException('No test to run.');
     }
     $test = new TestSuite('Test suite in (' . implode(', ', $test_dirs) . ')');
     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;
     }
 }
开发者ID:JasonWayne,项目名称:markdown-resume,代码行数:40,代码来源:pakeSimpletestTask.class.php

示例7: foreach

$events = $notifications->getEvents();
foreach ($events as $type => $subtypes) {
    foreach ($subtypes as $subtype => $actions) {
        $notifications->unregisterEvent($type, $subtype);
    }
}
// disable emails
_elgg_services()->setValue('mailer', new InMemoryTransport());
// Disable maximum execution time.
// Tests take a while...
set_time_limit(0);
$suite = new TestSuite('Elgg Core Unit Tests');
// emit a hook to pull in all tests
$test_files = elgg_trigger_plugin_hook('unit_test', 'system', null, array());
foreach ($test_files as $file) {
    $suite->addFile($file);
}
if (TextReporter::inCli()) {
    // In CLI error codes are returned: 0 is success
    $start_time = microtime(true);
    $reporter = new TextReporter();
    $result = $suite->Run($reporter) ? 0 : 1;
    echo sprintf("Time: %.2f seconds, Memory: %.2fMb\n", microtime(true) - $start_time, memory_get_peak_usage() / 1048576.0);
    // deactivate plugins that were activated for test suite
    foreach ($plugins as $key => $id) {
        $plugin = elgg_get_plugin_from_id($id);
        $plugin->deactivate();
    }
    exit($result);
}
$old = elgg_set_ignore_access(true);
开发者ID:cyrixhero,项目名称:Elgg,代码行数:31,代码来源:suite.php

示例8: exit

EOM;
    exit(0);
}
$testFiles = array_filter($options->values('--file'));
$dirs = array_filter($options->values('--dir'));
// default to this app's tests
if (!$options->has('--file', '--dir')) {
    $dirs[] = BASEDIR;
}
// add all directories
foreach ($dirs as $dir) {
    $classloader->includePaths(array($dir . '/classes', $dir . '/tests'));
}
// write an include path
$classloader->export();
require_once 'autorun.php';
$suite = new TestSuite('Tests');
if ($testFiles) {
    foreach ($testFiles as $test) {
        $suite->addFile($test);
    }
} else {
    foreach ($dirs as $dir) {
        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir . '/tests'));
        foreach ($iterator as $file) {
            if (preg_match('/(UseCase|Test).php$/', $file->getFileName())) {
                $suite->addFile($file->getPathname());
            }
        }
    }
}
开发者ID:snikch,项目名称:ergo,代码行数:31,代码来源:runtests.php

示例9: dirname

<?php

define('SIMPLE_TEST', '../../simpletest/');
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'web_tester.php';
require_once '../../phpQuery/phpQuery.php';
define('C5_ENVIRONMENT_ONLY', true);
define('DIR_BASE', dirname(__FILE__) . '/..');
require '../concrete/dispatcher.php';
require 'testing_base.php';
$c = Page::getByID(1);
$cp = new Permissions($c);
$a = Area::get($c, 'Main');
$ap = new Permissions($a);
class ShowPasses extends HtmlReporter
{
    function ShowPasses()
    {
        $this->HtmlReporter();
    }
    function paintPass($message)
    {
        parent::paintPass($message);
        print "<span class=\"pass\">Pass</span>: ";
        print " {$message}<br />\n";
    }
}
$t = new TestSuite('All Tests');
$t->addFile($_SERVER['DOCUMENT_ROOT'] . '/web/tests/template_tests.php');
$t->addFile($_SERVER['DOCUMENT_ROOT'] . '/web/tests/block_override_tests.php');
$t->run(new ShowPasses());
开发者ID:ceko,项目名称:concrete5-1,代码行数:31,代码来源:all_tests.php

示例10: define

<?php

if (!defined('ALLTESTRUNNER')) {
    require_once '../../test_bootstrap.php';
    define('TESTGROUPRUNNER', true);
}
$editTest = new TestSuite('Edit Controllers');
$editTest->addFile('bulldoc/test/cases/edit/page_edit/controller_test.php');
if (!defined('ALLTESTRUNNER')) {
    $editTest->run(new HtmlReporter());
}
开发者ID:googlecode-mirror,项目名称:bulldoc,代码行数:11,代码来源:group_run.php

示例11: TestSuite

if (defined('STDIN') && count($argv) > 1) {
    if ($argv[1] == 'noseeds') {
        $test_seeds = false;
    }
}
$test = new TestSuite('All tests');
// All tests should be of the form NNN_description.php
// Notably, this excludes all.php and base.php, which are special
$test_files = glob(dirname(__FILE__) . "/*_*.php");
foreach ($test_files as $file) {
    $go = true;
    if (strpos($file, 'Seed') && !$test_seeds) {
        $go = false;
    }
    if ($go) {
        $test->addFile($file);
    }
}
if (TextReporter::inCli()) {
    echo "\n\n";
    $code = $test->run(new TextReporter()) ? 0 : 1;
    if ($code == 0) {
        echo "\nResult: PASS\n";
    } else {
        echo "\nResult: FAIL\n";
    }
    exit($code);
}
?>

开发者ID:umamiMike,项目名称:platform,代码行数:29,代码来源:all.php

示例12: testLoadIfIncluded

 function testLoadIfIncluded()
 {
     $tests = new TestSuite();
     $tests->addFile(dirname(__FILE__) . '/support/test1.php');
     $this->assertEqual($tests->getSize(), 1);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:6,代码来源:autorun_test.php

示例13: Run

 /**
  * Run the tests, returning the reporter output.
  */
 public function Run()
 {
     // Save superglobals that might be tested.
     if (isset($_SESSION)) {
         $oldsession = $_SESSION;
     }
     $oldrequest = $_REQUEST;
     $oldpost = $_POST;
     $oldget = $_GET;
     $oldfiles = $_FILES;
     $oldcookie = $_COOKIE;
     $group_test = new TestSuite($this->testTitle);
     // Add files in tests_dir
     if (is_dir($this->testDir)) {
         if ($dh = opendir($this->testDir)) {
             while (($file = readdir($dh)) !== FALSE) {
                 // Test if file ends with php, then include it.
                 if (substr($file, -(strlen($this->fileExtension) + 1)) == '.' . $this->fileExtension) {
                     $group_test->addFile($this->testDir . "/{$file}");
                 }
             }
             closedir($dh);
         }
     }
     // Start the tests
     ob_start();
     $group_test->run(new $this->Reporter());
     $output_buffer = ob_get_clean();
     // Restore superglobals
     if (isset($oldsession)) {
         $_SESSION = $oldsession;
     }
     $_REQUEST = $oldrequest;
     $_POST = $oldpost;
     $_GET = $oldget;
     $_FILES = $oldfiles;
     $_COOKIE = $oldcookie;
     return $output_buffer;
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:42,代码来源:simpletester.php

示例14: date

<?php

if (!defined('AROOT')) {
    die('NO AROOT!');
}
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
// define constant
define('IN', true);
define('ROOT', dirname(__FILE__) . DS);
define('CROOT', ROOT . 'core' . DS);
define('TROOT', ROOT . 'simpletest' . DS);
// define
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', true);
include_once CROOT . 'lib' . DS . 'core.function.php';
@(include_once AROOT . 'lib' . DS . 'app.function.php');
include_once CROOT . 'config' . DS . 'core.config.php';
include_once AROOT . 'config' . DS . 'app.config.php';
require_once TROOT . 'autorun.php';
require_once TROOT . 'web_tester.php';
$test = new TestSuite('LazyPHP Test Center');
foreach (glob(AROOT . 'test' . DS . 'phptest' . DS . '*.test.php') as $f) {
    $test->addFile($f);
}
echo date("Y-m-d H:i:s");
//$test->run(new HtmlReporter('UTF-8'));
unset($test);
开发者ID:oxmcvusd,项目名称:nowboard,代码行数:29,代码来源:st.init.php

示例15: array

$CI =& get_instance();
ob_end_clean();
$CI->load->library('session');
$CI->session->sess_destroy();
$CI->load->helper('directory');
$CI->load->helper('form');
// Get all main tests
if ($run_all or !empty($_POST) && !isset($_POST['test'])) {
    $test_objs = array('controllers', 'models', 'views', 'libraries', 'bugs', 'helpers');
    foreach ($test_objs as $obj) {
        if (isset($_POST[$obj]) or $run_all) {
            $dir = TESTS_DIR . $obj;
            $dir_files = directory_map($dir);
            foreach ($dir_files as $file) {
                if ($file != 'index.html') {
                    $test_suite->addFile($dir . '/' . $file);
                }
            }
        }
    }
} elseif (isset($_POST['test'])) {
    $file = $_POST['test'];
    if (file_exists(TESTS_DIR . $file)) {
        $test_suite->addFile(TESTS_DIR . $file);
    }
}
// ------------------------------------------------------------------------
/**
 * Function to determine if in cli mode and if so set up variables to make it work
 *
 * @param Array of commandline args
开发者ID:muhamadsyahril,项目名称:codeigniter-simpletest,代码行数:31,代码来源:unit_test.php


注:本文中的TestSuite::addFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。