예제 #1
0
<?php

CoverageAnalysis::add(ROOT_PATH . '/libs/Sifo/CacheDisk.php');
/**
 * Test class for CacheDisk.
 * Generated by PHPUnit on 2009-11-01 at 12:17:06.
 */
class CacheDiskTest extends PHPUnit_Extensions_ControllerTest
{
    /**
     * @var CacheDisk
     */
    protected $object;
    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->object = new \Sifo\CacheDisk();
    }
    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        $this->object = null;
    }
    /**
     * Test object correct creation.
예제 #2
0
<?php

CoverageAnalysis::add(ROOT_PATH . '/libs/Sifo/Benchmark.php');
/**
 * Test class for Benchmark.
 * Generated by PHPUnit on 2009-11-01 at 12:17:00.
 */
class BenchmarkTest extends PHPUnit_Extensions_ControllerTest
{
    /**
     * @var Benchmark
     */
    protected $object;
    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->object = new \Sifo\Benchmark();
    }
    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        $this->object = null;
    }
    /**
     * Test object correct creation.
예제 #3
0
<?php

CoverageAnalysis::add(ROOT_PATH . '/libs/Sifo/Controller.php');
/**
 * Controller class is abstract, so we need a mock (for now).
 */
class ControllerMock extends \Sifo\Controller
{
    public function build()
    {
    }
}
/**
 * Test class for Controller.
 * Generated by PHPUnit on 2009-11-01 at 12:17:06.
 */
class ControllerTest extends PHPUnit_Extensions_ControllerTest
{
    /**
     * @var Controller
     */
    protected $object;
    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->object = new ControllerMock();
    }
    /**
예제 #4
0
파일: VPU.php 프로젝트: ninodafonte/SIFO
 /**
  * Render the code coverage report if enabled.
  *
  * @uses CoverageAnalysis
  * @access public
  * @param array $results Test suite results.
  * @return string
  */
 public function coverageReport($results)
 {
     $buffer = '';
     if (!CoverageAnalysis::isEnabled()) {
         ob_start();
         include 'ui/coverage_disabled.html';
         $buffer = ob_get_contents();
         ob_end_clean();
         return $buffer;
     }
     $coverage_files = CoverageAnalysis::getFiles();
     foreach ($coverage_files as $file) {
         $coverage_report = '';
         $file_contents = file($file);
         $lines_executed = array();
         $lines_executable = array();
         foreach ($results['coverage'][$file] as $key => $val) {
             if ($val > 0) {
                 $lines_executed[] = $key;
             } else {
                 $lines_not_executed[] = $key;
             }
         }
         $source_code = '';
         foreach ($file_contents as $line) {
             // Remove the php tags from source code, to fix an eval error in snapshots.
             $source_code .= preg_replace('/<\\?(php)?|\\?>/', '', $line);
         }
         $stats = array('lines_total' => count($file_contents), 'lines_executed' => count($lines_executed), 'lines_not_executed' => count($lines_not_executed));
         $stats['lines_used'] = $stats['lines_executed'] + $stats['lines_not_executed'];
         $stats['lines_not_used'] = $stats['lines_total'] - $stats['lines_used'];
         $stats['coverage'] = round($stats['lines_executed'] / $stats['lines_used'] * 100, 2);
         $stats['percentage_executed'] = round($stats['lines_executed'] / $stats['lines_used'] * 100, 2);
         $stats['percentage_not_executed'] = 100 - ceil($stats['coverage']);
         $stats['status'] = $this->getCoverageStatus($stats['coverage']);
         ob_start();
         include 'ui/coverage.html';
         $coverage_report = ob_get_contents();
         ob_end_clean();
         $buffer .= $coverage_report;
     }
     return $buffer;
 }
예제 #5
0
<?php

CoverageAnalysis::add(ROOT_PATH . '/libs/Sifo/Config.php');
/**
 * Yea, a mock to override the constructor, truly great.
 */
class ConfigMock extends \Sifo\Config
{
    public function __construct($instance_name)
    {
        return parent::__construct($instance_name);
    }
}
/**
 * Test class for Config.
 * Generated by PHPUnit on 2009-11-01 at 12:17:05.
 */
class ConfigTest extends PHPUnit_Extensions_ControllerTest
{
    /**
     * @var Config
     */
    protected $object;
    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->object = new ConfigMock('tests');
    }
예제 #6
0
 /**
  * Start XDebug code coverage.
  *
  * @access public
  * @return null if XDebug is not present.
  */
 public static function start()
 {
     if (count(self::$files) <= 0 || !self::isEnabled()) {
         return null;
     }
     xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
     self::$coverage_started = true;
 }