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


PHP lime_test::get_temp_directory方法代码示例

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


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

示例1: process

    public function process($files)
    {
        if (!is_array($files)) {
            $files = array($files);
        }
        $tmp_file = lime_test::get_temp_directory() . DIRECTORY_SEPARATOR . 'test.php';
        foreach ($files as $file) {
            $tmp = <<<EOF
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
include('{$file}');
echo '<PHP_SER>'.serialize(xdebug_get_code_coverage()).'</PHP_SER>';
EOF;
            file_put_contents($tmp_file, $tmp);
            ob_start();
            passthru(sprintf('%s "%s" 2>&1', $this->harness->php_cli, $tmp_file), $return);
            $retval = ob_get_clean();
            if (0 != $return) {
                // something may have gone wrong, we should warn the user so they know
                // it's a bug in their code and not symfony's
                $this->harness->output->echoln(sprintf('Warning: %s returned status %d, results may be inaccurate', $file, $return), 'ERROR');
            }
            if (false === ($cov = unserialize(substr($retval, strpos($retval, '<PHP_SER>') + 9, strpos($retval, '</PHP_SER>') - 9)))) {
                if (0 == $return) {
                    // failed to serialize, but PHP said it should of worked.
                    // something is seriously wrong, so abort with exception
                    throw new Exception(sprintf('Unable to unserialize coverage for file "%s"', $file));
                } else {
                    // failed to serialize, but PHP warned us that this might have happened.
                    // so we should ignore and move on
                    continue;
                    // continue foreach loop through $this->harness->files
                }
            }
            foreach ($cov as $file => $lines) {
                if (!isset($this->coverage[$file])) {
                    $this->coverage[$file] = $lines;
                    continue;
                }
                foreach ($lines as $line => $flag) {
                    if ($flag == 1) {
                        $this->coverage[$file][$line] = 1;
                    }
                }
            }
        }
        if (file_exists($tmp_file)) {
            unlink($tmp_file);
        }
    }
开发者ID:WIZARDISHUNGRY,项目名称:lime_test,代码行数:50,代码来源:lime.php

示例2: run

    public function run()
    {
        if (!function_exists('xdebug_start_code_coverage')) {
            throw new Exception('You must install and enable xdebug before using lime coverage.');
        }
        if (!ini_get('xdebug.extended_info')) {
            throw new Exception('You must set xdebug.extended_info to 1 in your php.ini to use lime coverage.');
        }
        if (!count($this->harness->files)) {
            throw new Exception('You must register some test files before running coverage!');
        }
        if (!count($this->files)) {
            throw new Exception('You must register some files to cover!');
        }
        $coverage = array();
        $tmp_file = lime_test::get_temp_directory() . DIRECTORY_SEPARATOR . 'test.php';
        foreach ($this->harness->files as $file) {
            $tmp = <<<EOF
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
include('{$file}');
echo '<PHP_SER>'.serialize(xdebug_get_code_coverage()).'</PHP_SER>';
EOF;
            file_put_contents($tmp_file, $tmp);
            ob_start();
            passthru(sprintf('%s "%s" 2>&1', $this->harness->php_cli, $tmp_file), $return);
            $retval = ob_get_clean();
            if (0 != $return) {
                // something may have gone wrong, we should warn the user so they know
                // it's a bug in their code and not symfony's
                $this->harness->output->echoln(sprintf('Warning: %s returned status %d, results may be inaccurate', $file, $return), 'ERROR');
            }
            if (false === ($cov = unserialize(substr($retval, strpos($retval, '<PHP_SER>') + 9, strpos($retval, '</PHP_SER>') - 9)))) {
                if (0 == $return) {
                    // failed to serialize, but PHP said it should of worked.
                    // something is seriously wrong, so abort with exception
                    throw new Exception(sprintf('Unable to unserialize coverage for file "%s"', $file));
                } else {
                    // failed to serialize, but PHP warned us that this might have happened.
                    // so we should ignore and move on
                    continue;
                    // continue foreach loop through $this->harness->files
                }
            }
            foreach ($cov as $file => $lines) {
                if (!in_array($file, $this->files)) {
                    continue;
                }
                if (!isset($coverage[$file])) {
                    $coverage[$file] = $lines;
                    continue;
                }
                foreach ($lines as $line => $flag) {
                    if ($flag == 1) {
                        $coverage[$file][$line] = 1;
                    }
                }
            }
        }
        unlink($tmp_file);
        ksort($coverage);
        $total_php_lines = 0;
        $total_covered_lines = 0;
        foreach ($this->files as $file) {
            $is_covered = isset($coverage[$file]);
            $cov = isset($coverage[$file]) ? $coverage[$file] : array();
            $covered_lines = array();
            $missing_lines = array();
            foreach ($cov as $line => $flag) {
                switch ($flag) {
                    case 1:
                        $covered_lines[] = $line;
                        break;
                    case -1:
                        $missing_lines[] = $line;
                        break;
                }
            }
            $total_lines = count($covered_lines) + count($missing_lines);
            $output = $this->harness->output;
            $percent = $total_lines ? count($covered_lines) * 100 / $total_lines : 0;
            $total_php_lines += $total_lines;
            $total_covered_lines += count($covered_lines);
            $relative_file = $this->get_relative_file($file);
            $output->echoln(sprintf("%-70s %3.0f%%", substr($relative_file, -min(70, strlen($relative_file))), $percent), $percent == 100 ? 'INFO' : ($percent > 90 ? 'PARAMETER' : ($percent < 20 ? 'ERROR' : '')));
            if ($this->verbose && $is_covered && $percent != 100) {
                $output->comment(sprintf("missing: %s", $this->format_range($missing_lines)));
            }
        }
        $output->echoln(sprintf("TOTAL COVERAGE: %3.0f%%", $total_php_lines ? $total_covered_lines * 100 / $total_php_lines : 0));
    }
开发者ID:ajith24,项目名称:ajithworld,代码行数:91,代码来源:lime.php

示例3: run

    function run()
    {
        if (!function_exists('xdebug_start_code_coverage')) {
            throw new Exception('You must install and enable xdebug before using lime coverage.');
        }
        if (!ini_get('xdebug.extended_info')) {
            throw new Exception('You must set xdebug.extended_info to 1 in your php.ini to use lime coverage.');
        }
        if (!count($this->harness->files)) {
            throw new Exception('You must register some test files before running coverage!');
        }
        if (!count($this->files)) {
            throw new Exception('You must register some files to cover!');
        }
        $coverage = array();
        $tmp_file = lime_test::get_temp_directory() . DIRECTORY_SEPARATOR . 'test.php';
        foreach ($this->harness->files as $file) {
            $tmp = <<<EOF
<?php
xdebug_start_code_coverage();
ob_start();
include('{$file}');
ob_end_clean();
echo '<PHP_SER>'.serialize(xdebug_get_code_coverage()).'</PHP_SER>';
EOF;
            file_put_contents($tmp_file, $tmp);
            ob_start();
            passthru(sprintf('%s -d html_errors=off -d open_basedir= -q "%s" 2>&1', $this->harness->php_cli, $tmp_file), $return);
            $retval = ob_get_clean();
            if (0 == $return) {
                if (false === ($cov = unserialize(substr($retval, strpos($retval, '<PHP_SER>') + 9, strpos($retval, '</PHP_SER>') - 9)))) {
                    throw new Exception(sprintf('Unable to unserialize coverage for file "%s"', $file));
                }
                foreach ($cov as $file => $lines) {
                    if (!isset($coverage[$file])) {
                        $coverage[$file] = array();
                    }
                    foreach ($lines as $line => $count) {
                        if (!isset($coverage[$file][$line])) {
                            $coverage[$file][$line] = 0;
                        }
                        $coverage[$file][$line] = $coverage[$file][$line] + $count;
                    }
                }
            }
        }
        unlink($tmp_file);
        ksort($coverage);
        $total_php_lines = 0;
        $total_covered_lines = 0;
        foreach ($this->files as $file) {
            $cov = isset($coverage[$file]) ? $coverage[$file] : array();
            list($cov, $php_lines) = $this->compute(file_get_contents($file), $cov);
            $output = $this->harness->output;
            $percent = count($php_lines) ? count($cov) * 100 / count($php_lines) : 100;
            $total_php_lines += count($php_lines);
            $total_covered_lines += count($cov);
            $relative_file = $this->get_relative_file($file);
            $output->echoln(sprintf("%-70s %3.0f%%", substr($relative_file, -min(70, strlen($relative_file))), $percent), $percent == 100 ? 'INFO' : ($percent > 90 ? 'PARAMETER' : ($percent < 20 ? 'ERROR' : '')));
            if ($this->verbose && $percent != 100) {
                $output->comment(sprintf("missing: %s", $this->format_range(array_keys(array_diff_key($php_lines, $cov)))));
            }
        }
        $output->echoln(sprintf("TOTAL COVERAGE: %3.0f%%", $total_covered_lines * 100 / $total_php_lines));
    }
开发者ID:taryono,项目名称:school,代码行数:65,代码来源:lime.php

示例4: dirname

<?php

/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 - 2008 Carl Vondrick <carl@carlsoft.net>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id: sfLuceneProjectConfigHandlerTest.php 7116 2008-01-20 22:43:28Z Carl.Vondrick $
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(2, limeade_output::get());
$limeade = new limeade_sf($t);
$app = $limeade->bootstrap();
$luceneade = new limeade_lucene($limeade);
$luceneade->configure()->clear_sandbox()->load_models();
$config = new sfLuceneProjectConfigHandler();
$response = $config->execute(array($luceneade->data_dir . '/configTest/project.yml'));
file_put_contents(lime_test::get_temp_directory() . '/search.yml.php', $response);
require lime_test::get_temp_directory() . '/search.yml.php';
unlink(lime_test::get_temp_directory() . '/search.yml.php');
$t->ok(isset($config), '->execute() creates a $config variable');
$t->is_deeply($config, array('testLucene' => array('models' => array('FakeModel' => array('fields' => array('id' => array('type' => 'text', 'boost' => 1, 'transform' => NULL), 'title' => array('type' => 'text', 'boost' => 1, 'transform' => NULL), 'description' => array('type' => 'text', 'boost' => 3, 'transform' => NULL)), 'title' => 'title', 'description' => 'description', 'categories' => array(0 => 'Forum'), 'route' => 'forum/showForum?id=%id%', 'validator' => 'isIndexable', 'rebuild_limit' => 5, 'peer' => 'FakeForumPeer', 'partial' => 'forumResult', 'indexer' => NULL)), 'index' => array('encoding' => 'UTF-8', 'cultures' => array(0 => 'en', 1 => 'fr'), 'stop_words' => array(0 => 'and', 1 => 'the'), 'short_words' => 2, 'analyzer' => 'utf8num', 'case_sensitive' => false, 'mb_string' => true, 'param' => array()), 'interface' => array('categories' => true, 'advanced' => true), 'factories' => array('indexers' => array(), 'results' => array())), 'barLucene' => array('models' => array('FakeModel' => array('fields' => array(), 'partial' => NULL, 'route' => NULL, 'indexer' => NULL, 'title' => NULL, 'description' => NULL, 'peer' => 'FakeModelPeer', 'rebuild_limit' => 250, 'validator' => NULL, 'categories' => array())), 'index' => array('encoding' => 'utf-8', 'cultures' => array(0 => NULL), 'stop_words' => array(0 => 'a', 1 => 'an', 2 => 'at', 3 => ' the', 4 => 'and', 5 => 'or', 6 => 'is', 7 => 'am', 8 => 'are', 9 => 'of'), 'short_words' => 2, 'analyzer' => 'textnum', 'case_sensitive' => false, 'mb_string' => false, 'param' => array()), 'factories' => array('indexers' => array(), 'results' => array())), 'fooLucene' => array('models' => array(), 'index' => array('encoding' => 'utf-8', 'cultures' => array(0 => NULL), 'stop_words' => array(0 => 'a', 1 => 'an', 2 => 'at', 3 => ' the', 4 => 'and', 5 => 'or', 6 => 'is', 7 => 'am', 8 => 'are', 9 => 'of'), 'short_words' => 2, 'analyzer' => 'textnum', 'case_sensitive' => false, 'mb_string' => false, 'param' => array()), 'factories' => array('indexers' => array(), 'results' => array()))), '->execute() writes the correct configuration from the YAML file');
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:28,代码来源:sfLuceneProjectConfigHandlerTest.php


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