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


PHP PHPUnit_Framework_TestCase::prepareTemplate方法代码示例

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


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

示例1: prepareTemplate

 /**
  * Define constants after including files.
  */
 function prepareTemplate(Text_Template $template)
 {
     $template->setVar(array('constants' => ''));
     $template->setVar(array('wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString()));
     parent::prepareTemplate($template);
 }
开发者ID:dannyoz,项目名称:tls,代码行数:9,代码来源:testcase.php

示例2: prepareTemplate

    /**
     * Performs custom preparations on the process isolation template.
     *
     * @param        Text_Template $template
     *
     * @author       Felix Gilcher <felix.gilcher@bitextender.com>
     * @since        1.0.2
     */
    protected function prepareTemplate(Text_Template $template)
    {
        parent::prepareTemplate($template);
        // FIXME: workaround for php unit bug (https://github.com/sebastianbergmann/phpunit/pull/1338)
        $template->setVar(array('dataName' => "'.(" . var_export($this->myDataName, true) . ").'"));
        // FIXME: if we have full composer autoloading we can remove this
        // we need to restore the included files even without global state, since otherwise
        // the agavi test class files would be missing.
        // We can't write include()s directly since Agavi possibly get's bootstrapped later
        // in the process (but before the test instance is created) and if we'd load any
        // files which are being loaded by the bootstrap process chaos would ensue since
        // the bootstrap process uses plain include()s without _once
        $fileAutoloader = sprintf('
			spl_autoload_register(function($name) {
				$classMap = %s;
				if(isset($classMap[$name])) {
					include($classMap[$name]);
				}
			});
		', var_export($this->getDependendClasses(), true));
        // these constants are either used by out bootstrap wrapper script
        // (AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP) or can be used by the user's
        // bootstrap script (AGAVI_TESTING_IN_SEPERATE_PROCESS)
        $constants = sprintf('
			define("AGAVI_TESTING_IN_SEPERATE_PROCESS", true);
			define("AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP", %s);
			', var_export(isset($GLOBALS["__PHPUNIT_BOOTSTRAP"]) ? $GLOBALS["__PHPUNIT_BOOTSTRAP"] : null, true));
        $isolatedTestSettings = array('environment' => $this->getIsolationEnvironment(), 'defaultContext' => $this->getIsolationDefaultContext(), 'clearCache' => $this->getClearCache(), 'bootstrap' => $this->doBootstrap());
        $globals = sprintf('
			$GLOBALS["AGAVI_TESTING_CONFIG"] = %s;
			$GLOBALS["AGAVI_TESTING_ISOLATED_TEST_SETTINGS"] = %s;
			$GLOBALS["__PHPUNIT_BOOTSTRAP"] = %s;
			', var_export(AgaviConfig::toArray(), true), var_export($isolatedTestSettings, true), var_export(__DIR__ . '/scripts/IsolatedBootstrap.php', true));
        if (!$this->preserveGlobalState) {
            $template->setVar(array('included_files' => $fileAutoloader, 'constants' => $constants, 'globals' => $globals));
        } else {
            // HACK: oh great, text/template doesn't expose the already set variables, but we need to modify
            // them instead of overwriting them. So let's use the reflection to the rescue here.
            $reflected = new ReflectionObject($template);
            $property = $reflected->getProperty('values');
            $property->setAccessible(true);
            $oldVars = $property->getValue($template);
            $template->setVar(array('included_files' => $fileAutoloader, 'constants' => $oldVars['constants'] . PHP_EOL . $constants, 'globals' => $oldVars['globals'] . PHP_EOL . $globals));
        }
    }
开发者ID:horros,项目名称:agavi,代码行数:53,代码来源:AgaviPhpUnitTestCase.class.php

示例3: prepareTemplate

 /**
  * Define constants after requires/includes
  *
  * See http://kpayne.me/2012/07/02/phpunit-process-isolation-and-constant-already-defined/
  * for more details
  *
  * @param \Text_Template $template
  */
 public function prepareTemplate(\Text_Template $template)
 {
     $template->setVar(array('globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';'));
     parent::prepareTemplate($template);
 }
开发者ID:cmmarslender,项目名称:timer,代码行数:13,代码来源:TestCase.php

示例4: prepareTemplate

 /**
  * Performs custom preparations on the process isolation template.
  *
  * @param        Text_Template $template
  *
  * @author       Felix Gilcher <felix.gilcher@bitextender.com>
  * @since        1.0.2
  */
 protected function prepareTemplate(Text_Template $template)
 {
     parent::prepareTemplate($template);
     $vars = array('agavi_environment' => '', 'agavi_default_context' => '', 'agavi_clear_cache' => 'false');
     if (null !== ($env = $this->getIsolationEnvironment())) {
         $vars['agavi_environment'] = $env;
     }
     if (null !== ($ctx = $this->getIsolationDefaultContext())) {
         $vars['agavi_default_context'] = $ctx;
     }
     if ($this->getClearCache()) {
         $vars['agavi_clear_cache'] = 'true';
         // literal strings required for proper template rendering
     }
     $template->setVar($vars);
     $templateFile = $this->getTemplateFile();
     if (null !== $templateFile) {
         $template->setFile($templateFile);
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:28,代码来源:AgaviPhpUnitTestCase.class.php


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