예제 #1
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->logLine('Unit testing bee');
     $files = array();
     $dirs = isset($options['dir']) ? $options['dir'] : array();
     if (!isset($options['exclude-project-folder'])) {
         $dirs[] = nbConfig::get('nb_test_dir', 'test/unit');
     }
     if (count($arguments['name'])) {
         foreach ($dirs as $dir) {
             foreach ($arguments['name'] as $name) {
                 $finder = nbFileFinder::create('file')->followLink()->add(basename($name) . 'Test.php');
                 $files = array_merge($files, $finder->in($dir . '/' . dirname($name)));
             }
         }
     } else {
         // filter and register unit tests
         $finder = nbFileFinder::create('file')->add('*Test.php');
         $files = $finder->in($dirs);
     }
     if (count($files) == 0) {
         $this->log('no tests found', nbLogger::ERROR);
         return false;
     }
     $h = new lime_harness();
     $h->register($files);
     $ret = $h->run(isset($options['showall']));
     // print output to file
     if (isset($options['output'])) {
         $fileName = $options['output'];
         $fh = fopen($fileName, 'w');
         if ($fh === false) {
             return $ret;
         }
         fwrite($fh, isset($options['xml']) ? $h->to_xml() : '');
         fclose($fh);
     }
     return $ret;
 }
예제 #2
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
define('SF_DIR', dirname(__FILE__) . '/../../../../lib/vendor/symfony/');
require_once SF_DIR . 'lib/vendor/lime/lime.php';
require_once SF_DIR . 'lib/util/sfToolkit.class.php';
require_once SF_DIR . 'lib/util/sfFinder.class.php';
if ($files = glob(sys_get_temp_dir() . DIRECTORY_SEPARATOR . '/sf_autoload_unit_*')) {
    foreach ($files as $file) {
        unlink($file);
    }
}
$h = new lime_harness(new lime_output_color());
$h->base_dir = realpath(dirname(__FILE__) . '/..');
$h->register(sfFinder::type('file')->prune('fixtures')->name('*Test.php')->in(array($h->base_dir . '/unit', $h->base_dir . '/functional')));
$code = $h->run();
file_put_contents('junit.xml', $h->to_xml());
exit($code ? 0 : 1);
예제 #3
0
<?php

/**
 * cli command to test plugin in a standalone environment.
 *
 * you can provide following options:
 * * --symfony : the symfony lib directory
 * * --xml : export results to this file
 */
// first parse options
$options = array_merge(array('symfony' => '/usr/share/php/symfony/', 'xml' => false), getopt("", array("symfony:", "xml:")));
// create the common include for lib path
$sf_lib_path_include = dirname(dirname(__FILE__)) . '/bootstrap/sf_test_lib.inc';
file_put_contents($sf_lib_path_include, sprintf('<?php if (!isset($_SERVER[\'SYMFONY\'])) {$_SERVER[\'SYMFONY\'] = "%s";}', $options['symfony']));
include dirname(__FILE__) . '/../bootstrap/unit.php';
$h = new lime_harness(new lime_output_color());
$h->register(sfFinder::type('file')->name('*Test.php')->in(dirname(__FILE__) . '/..'));
// run tests
$ret = $h->run() ? 1 : 0;
// export to xml ?
if ($options['xml']) {
    file_put_contents($options['xml'], $h->to_xml());
}
// remove the common include for lib path
unlink($sf_lib_path_include);
exit($ret);
예제 #4
0
파일: prove.php 프로젝트: sympal/sympal
<?php

include dirname(__FILE__) . '/../bootstrap/unit.php';
$h = new lime_harness();
$h->register(sfFinder::type('file')->name('*Test.php')->in(dirname(__FILE__) . '/..'));
$ret = $h->run() ? 0 : 1;
if (isset($argv[1]) && strpos($argv[1], '--xml=') === 0) {
    $file = str_replace('--xml=', '', $argv[1]);
    file_put_contents($file, $h->to_xml());
}
exit($ret);