• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Text_Template类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fetchFrontendResponse

 /**
  * @param array $requestArguments
  * @param bool $failOnFailure
  * @return Response
  */
 protected function fetchFrontendResponse(array $requestArguments, $failOnFailure = true)
 {
     if (!empty($requestArguments['url'])) {
         $requestUrl = '/' . ltrim($requestArguments['url'], '/');
     } else {
         $requestUrl = '/?' . GeneralUtility::implodeArrayForUrl('', $requestArguments);
     }
     if (property_exists($this, 'instancePath')) {
         $instancePath = $this->instancePath;
     } else {
         $instancePath = ORIGINAL_ROOT . 'typo3temp/functional-' . substr(sha1(get_class($this)), 0, 7);
     }
     $arguments = array('documentRoot' => $instancePath, 'requestUrl' => 'http://localhost' . $requestUrl);
     $template = new \Text_Template(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/request.tpl');
     $template->setVar(array('arguments' => var_export($arguments, true), 'originalRoot' => ORIGINAL_ROOT));
     $php = \PHPUnit_Util_PHP::factory();
     $response = $php->runJob($template->render());
     $result = json_decode($response['stdout'], true);
     if ($result === null) {
         $this->fail('Frontend Response is empty');
     }
     if ($failOnFailure && $result['status'] === Response::STATUS_Failure) {
         $this->fail('Frontend Response has failure:' . LF . $result['error']);
     }
     $response = new Response($result['status'], $result['content'], $result['error']);
     return $response;
 }
开发者ID:helhum,项目名称:ext_scaffold,代码行数:32,代码来源:RenderingTest.php


示例2: render

 /**
  * @param PHP_CodeCoverage_Report_Node_File $node
  * @param string                            $file
  */
 public function render(PHP_CodeCoverage_Report_Node_File $node, $file)
 {
     $template = new Text_Template($this->templatePath . 'file.html', '{{', '}}');
     $template->setVar(array('items' => $this->renderItems($node), 'lines' => $this->renderSource($node)));
     $this->setCommonTemplateVariables($template, $node);
     $template->renderTo($file);
 }
开发者ID:akarimgh,项目名称:matrix42-slim-api,代码行数:11,代码来源:File.php


示例3: render

 /**
  * @param FileNode $node
  * @param string   $file
  */
 public function render(FileNode $node, $file)
 {
     $template = new \Text_Template($this->templatePath . 'file.html', '{{', '}}');
     $template->setVar(['items' => $this->renderItems($node), 'lines' => $this->renderSource($node)]);
     $this->setCommonTemplateVariables($template, $node);
     $template->renderTo($file);
 }
开发者ID:thanghexp,项目名称:project,代码行数:11,代码来源:File.php


示例4: renderRelease

 /**
  * @param Release $release
  * @param bool    $latest
  *
  * @return string
  */
 private function renderRelease(Release $release, $latest = false)
 {
     $item = new \Text_Template(__DIR__ . '/../templates/item.html');
     $manifest = '';
     if (!empty($release->manifest())) {
         $manifest = sprintf(' class="phar" data-title="Manifest" data-content="<ul>%s</ul>" data-placement="bottom" data-html="true"', implode('', array_map(function ($item) {
             return '<li>' . $item . '</li>';
         }, $release->manifest())));
     }
     $item->setVar(['domain' => $this->domain(), 'package' => $release->package(), 'version' => $release->version(), 'date' => $release->date(), 'size' => $release->size(), 'sha256' => $release->sha256(), 'strongOpen' => $latest ? '<strong>' : '', 'strongClose' => $latest ? '</strong>' : '', 'manifest' => $manifest]);
     return $item->render();
 }
开发者ID:matheusgomes17,项目名称:phar-site-generator,代码行数:18,代码来源:PageRenderer.php


示例5: render

 /**
  * @param ReleaseCollection $releases
  */
 public function render(ReleaseCollection $releases)
 {
     $feedTemplate = new \Text_Template(__DIR__ . '/../templates/feed.xml');
     $feedItemTemplate = new \Text_Template(__DIR__ . '/../templates/item.xml');
     $rdfList = '';
     $rdfItems = '';
     foreach ($releases->latestReleasesSortedByDate() as $release) {
         $rdfList .= sprintf('    <rdf:li rdf:resource="%s/%s-%s.phar"/>' . "\n", $this->domain(), $release->package(), $release->version());
         $feedItemTemplate->setVar(['domain' => $this->domain(), 'package' => $release->package(), 'version' => $release->version(), 'date' => $release->date(), 'content' => '']);
         $rdfItems .= $feedItemTemplate->render();
     }
     $feedTemplate->setVar(['items_list' => $rdfList, 'items' => $rdfItems, 'domain' => $this->domain(), 'email' => $this->email()]);
     $feedTemplate->renderTo($this->target());
 }
开发者ID:matheusgomes17,项目名称:phar-site-generator,代码行数:17,代码来源:FeedRenderer.php


示例6: resultPrintAfter

 /**
  * @param PrintResultEvent $printResultEvent
  * @throws \Codeception\Exception\ModuleRequireException
  */
 public function resultPrintAfter(PrintResultEvent $printResultEvent)
 {
     if (count($this->failedIdentifiers) > 0) {
         $items = '';
         $itemTemplate = new \Text_Template($this->config['templateFolder'] . 'Item.html');
         foreach ($this->failedIdentifiers as $vars) {
             $itemTemplate->setVar($vars);
             $items .= $itemTemplate->render();
         }
         $pageTemplate = new \Text_Template($this->config['templateFolder'] . 'Page.html');
         $pageTemplate->setVar(array('items' => $items));
         $reportPath = $this->fileSystemUtil->getFailImageDirectory() . 'index.html';
         $pageTemplate->renderTo($reportPath);
         $printResultEvent->getPrinter()->write('Report has been created: ' . $reportPath . "\n");
     }
 }
开发者ID:sascha-egerer,项目名称:css-regression,代码行数:20,代码来源:CssRegressionReporter.php


示例7: getParsedTemplateByNameAndHash

 /**
  * parse a given template name with given hash of key-value pairs
  *
  * @param string $name
  * @param array $hash
  * @return string
  */
 public static function getParsedTemplateByNameAndHash($name, array $hash = array())
 {
     $tpl = new \Text_Template(self::getTemplateFileByName($name));
     $tpl->setVar($hash);
     return $tpl->render();
 }
开发者ID:basuritas-php,项目名称:phpunitgenerator,代码行数:13,代码来源:Helper.php


示例8: renderDashboard

 /**
  * @param PHP_CodeCoverage_Report_HTML_Node_Directory $root
  * @param string                                      $file
  * @param string                                      $title
  */
 protected function renderDashboard(PHP_CodeCoverage_Report_HTML_Node_Directory $root, $file, $title)
 {
     $classes = $this->classes($root);
     $template = new Text_Template(PHP_CodeCoverage_Report_HTML::$templatePath . 'dashboard.html');
     $template->setVar(array('title' => $title, 'charset' => $this->options['charset'], 'date' => date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']), 'version' => '@package_version@', 'php_version' => PHP_VERSION, 'generator' => $this->options['generator'], 'least_tested_methods' => $this->leastTestedMethods($classes), 'top_project_risks' => $this->topProjectRisks($classes), 'cc_values' => $this->classComplexity($classes), 'ccd_values' => $this->classCoverageDistribution($classes), 'backlink' => basename(str_replace('.dashboard', '', $file))));
     $template->renderTo($file);
 }
开发者ID:redlion09,项目名称:pcppi,代码行数:12,代码来源:HTML.php


示例9: 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


示例10: render

 /**
  * Renders this node.
  *
  * @param string  $target
  * @param string  $title
  * @param string  $charset
  * @param integer $lowUpperBound
  * @param integer $highLowerBound
  * @param string  $generator
  */
 public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35, $highLowerBound = 70, $generator = '')
 {
     if ($this->yui) {
         $template = new Text_Template(PHP_CodeCoverage_Report_HTML::$templatePath . 'file.html');
         $yuiTemplate = new Text_Template(PHP_CodeCoverage_Report_HTML::$templatePath . 'yui_item.js');
     } else {
         $template = new Text_Template(PHP_CodeCoverage_Report_HTML::$templatePath . 'file_no_yui.html');
     }
     $i = 1;
     $lines = '';
     foreach ($this->codeLines as $line) {
         $css = '';
         if (!isset($this->ignoredLines[$i]) && isset($this->executedLines[$i])) {
             $count = '';
             // Array: Line is executable and was executed.
             // count(Array) = Number of tests that hit this line.
             if (is_array($this->executedLines[$i])) {
                 $color = 'lineCov';
                 $numTests = count($this->executedLines[$i]);
                 $count = sprintf('%8d', $numTests);
                 if ($this->yui) {
                     $buffer = '';
                     $testCSS = '';
                     foreach ($this->executedLines[$i] as $test) {
                         switch ($test['status']) {
                             case 0:
                                 $testCSS = ' class=\\"testPassed\\"';
                                 break;
                             case 1:
                             case 2:
                                 $testCSS = ' class=\\"testIncomplete\\"';
                                 break;
                             case 3:
                                 $testCSS = ' class=\\"testFailure\\"';
                                 break;
                             case 4:
                                 $testCSS = ' class=\\"testError\\"';
                                 break;
                             default:
                                 $testCSS = '';
                         }
                         $buffer .= sprintf('<li%s>%s</li>', $testCSS, addslashes(htmlspecialchars($test['id'])));
                     }
                     if ($numTests > 1) {
                         $header = $numTests . ' tests cover';
                     } else {
                         $header = '1 test covers';
                     }
                     $header .= ' line ' . $i;
                     $yuiTemplate->setVar(array('line' => $i, 'header' => $header, 'tests' => $buffer), FALSE);
                     $this->yuiPanelJS .= $yuiTemplate->render();
                 }
             } else {
                 if ($this->executedLines[$i] == -1) {
                     $color = 'lineNoCov';
                     $count = sprintf('%8d', 0);
                 } else {
                     $color = 'lineDeadCode';
                     $count = '        ';
                 }
             }
             $css = sprintf('<span class="%s">       %s : ', $color, $count);
         }
         $fillup = array_shift($this->codeLinesFillup);
         if ($fillup > 0) {
             $line .= str_repeat(' ', $fillup);
         }
         $lines .= sprintf('<span class="lineNum" id="container%d"><a name="%d"></a>' . '<a href="#%d" id="line%d">%8d</a> </span>%s%s%s' . "\n", $i, $i, $i, $i, $i, !empty($css) ? $css : '                : ', !$this->highlight ? htmlspecialchars($line) : $line, !empty($css) ? '</span>' : '');
         $i++;
     }
     $items = '';
     foreach ($this->classes as $className => $classData) {
         if ($classData['executedLines'] == $classData['executableLines']) {
             $numTestedClasses = 1;
             $testedClassesPercent = 100;
         } else {
             $numTestedClasses = 0;
             $testedClassesPercent = 0;
         }
         $numMethods = 0;
         $numTestedMethods = 0;
         foreach ($classData['methods'] as $method) {
             if ($method['executableLines'] > 0) {
                 $numMethods++;
                 if ($method['executedLines'] == $method['executableLines']) {
                     $numTestedMethods++;
                 }
             }
         }
         $items .= $this->doRenderItem(array('name' => sprintf('<b><a href="#%d">%s</a></b>', $classData['startLine'], $className), 'numClasses' => 1, 'numTestedClasses' => $numTestedClasses, 'testedClassesPercent' => sprintf('%01.2f', $testedClassesPercent), 'numMethods' => $numMethods, 'numTestedMethods' => $numTestedMethods, 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent($numTestedMethods, $numMethods, TRUE), 'numExecutableLines' => $classData['executableLines'], 'numExecutedLines' => $classData['executedLines'], 'executedLinesPercent' => PHP_CodeCoverage_Util::percent($classData['executedLines'], $classData['executableLines'], TRUE)), $lowUpperBound, $highLowerBound);
//.........这里部分代码省略.........
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:101,代码来源:File.php


示例11: prepareTemplate

 /**
  * we need process isolation to prevent "headers already sent"
  *
  * but process isolation triggers another error, because phpunit tries to load all previously included files
  * where throw_exception.php should not be called
  *
  * however disabled globalState prevents constants in bootstrap.php to be loaded
  *
  * that is why we need this ugly hack method
  *
  * @param \Text_Template $template
  */
 protected function prepareTemplate(\Text_Template $template)
 {
     $template->setVar(array('iniSettings' => '', 'constants' => '', 'included_files' => '', 'globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = ' . var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], TRUE) . ";\n"));
 }
开发者ID:thomblin,项目名称:slimline,代码行数:16,代码来源:dbTest.php


示例12: run

 /**
  * Runs the test case and collects the results in a TestResult object.
  * If no TestResult object is passed a new one will be created.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @return PHPUnit_Framework_TestResult
  * @throws InvalidArgumentException
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     if ($result === NULL) {
         $result = $this->createResult();
     }
     $this->setExpectedExceptionFromAnnotation();
     $this->setUseErrorHandlerFromAnnotation();
     $this->setUseOutputBufferingFromAnnotation();
     if ($this->useErrorHandler !== NULL) {
         $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
         $result->convertErrorsToExceptions($this->useErrorHandler);
     }
     $this->result = $result;
     if (!empty($this->dependencies) && !$this->inIsolation) {
         $className = get_class($this);
         $passed = $this->result->passed();
         $passedKeys = array_keys($passed);
         $numKeys = count($passedKeys);
         for ($i = 0; $i < $numKeys; $i++) {
             $pos = strpos($passedKeys[$i], ' with data set');
             if ($pos !== FALSE) {
                 $passedKeys[$i] = substr($passedKeys[$i], 0, $pos);
             }
         }
         $passedKeys = array_flip(array_unique($passedKeys));
         foreach ($this->dependencies as $dependency) {
             if (strpos($dependency, '::') === FALSE) {
                 $dependency = $className . '::' . $dependency;
             }
             if (!isset($passedKeys[$dependency])) {
                 $result->addError($this, new PHPUnit_Framework_SkippedTestError(sprintf('This test depends on "%s" to pass.', $dependency)), 0);
                 return;
             } else {
                 if (isset($passed[$dependency])) {
                     $this->dependencyInput[] = $passed[$dependency];
                 } else {
                     $this->dependencyInput[] = NULL;
                 }
             }
         }
     }
     if ($this->runTestInSeparateProcess === TRUE && $this->inIsolation !== TRUE && !$this instanceof PHPUnit_Extensions_SeleniumTestCase && !$this instanceof PHPUnit_Extensions_PhptTestCase) {
         $class = new ReflectionClass($this);
         $template = new Text_Template(sprintf('%s%sProcess%sTestCaseMethod.tpl', dirname(__FILE__), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
         if ($this->preserveGlobalState) {
             $constants = PHPUnit_Util_GlobalState::getConstantsAsString();
             $globals = PHPUnit_Util_GlobalState::getGlobalsAsString();
             $includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString();
         } else {
             $constants = '';
             $globals = '';
             $includedFiles = '';
         }
         if ($result->getCollectCodeCoverageInformation()) {
             $coverage = 'TRUE';
         } else {
             $coverage = 'FALSE';
         }
         $data = addcslashes(serialize($this->data), "'");
         $dependencyInput = addcslashes(serialize($this->dependencyInput), "'");
         $includePath = addslashes(get_include_path());
         $template->setVar(array('filename' => $class->getFileName(), 'className' => $class->getName(), 'methodName' => $this->name, 'collectCodeCoverageInformation' => $coverage, 'data' => $data, 'dataName' => $this->dataName, 'dependencyInput' => $dependencyInput, 'constants' => $constants, 'globals' => $globals, 'include_path' => $includePath, 'included_files' => $includedFiles));
         $this->prepareTemplate($template);
         PHPUnit_Util_PHP::runJob($template->render(), $this, $result);
     } else {
         $result->run($this);
     }
     if ($this->useErrorHandler !== NULL) {
         $result->convertErrorsToExceptions($oldErrorHandlerSetting);
     }
     $this->result = NULL;
     return $result;
 }
开发者ID:strager,项目名称:phpunit,代码行数:81,代码来源:TestCase.php


示例13: 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(['globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';']);
     parent::prepareTemplate($template);
 }
开发者ID:ChrisWiegman,项目名称:chriswiegman-theme,代码行数:13,代码来源:TestCase.php


示例14: generate

 /**
  * Generates the class' source.
  *
  * @return mixed
  */
 public function generate()
 {
     $methods = '';
     foreach ($this->findTestedMethods() as $method) {
         $methodTemplate = new Text_Template(sprintf('%s%sTemplate%sMethod.tpl', dirname(__FILE__), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
         $methodTemplate->setVar(array('methodName' => $method));
         $methods .= $methodTemplate->render();
     }
     $classTemplate = new Text_Template(sprintf('%s%sTemplate%sClass.tpl', dirname(__FILE__), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
     $classTemplate->setVar(array('className' => $this->outClassName['fullyQualifiedClassName'], 'methods' => $methods, 'date' => date('Y-m-d'), 'time' => date('H:i:s')));
     return $classTemplate->render();
 }
开发者ID:nickpro,项目名称:sugarcrm_dev,代码行数:17,代码来源:Class.php


示例15: generateMockedMethodDefinition

 /**
  * @param  string  $templateDir
  * @param  string  $className
  * @param  string  $methodName
  * @param  string  $modifier
  * @param  string  $arguments_decl
  * @param  string  $arguments_call
  * @param  string  $reference
  * @param  boolean $static
  * @return string
  */
 protected static function generateMockedMethodDefinition($templateDir, $className, $methodName, $modifier = 'public', $arguments_decl = '', $arguments_call = '', $reference = '', $static = FALSE)
 {
     if ($static) {
         $template = new Text_Template($templateDir . 'mocked_static_method.tpl');
     } else {
         $template = new Text_Template($templateDir . 'mocked_object_method.tpl');
     }
     $template->setVar(array('arguments_decl' => $arguments_decl, 'arguments_call' => $arguments_call, 'arguments_count' => !empty($arguments_call) ? count(explode(',', $arguments_call)) : 0, 'class_name' => $className, 'method_name' => $methodName, 'modifier' => $modifier, 'reference' => $reference));
     return $template->render();
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:21,代码来源:Generator.php


示例16: run

 /**
  * Runs the test case and collects the results in a TestResult object.
  * If no TestResult object is passed a new one will be created.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @return PHPUnit_Framework_TestResult
  * @throws PHPUnit_Framework_Exception
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     if ($result === NULL) {
         $result = $this->createResult();
     }
     if (!$this instanceof PHPUnit_Framework_Warning) {
         $this->setTestResultObject($result);
         $this->setUseErrorHandlerFromAnnotation();
         $this->setUseOutputBufferingFromAnnotation();
     }
     if ($this->useErrorHandler !== NULL) {
         $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
         $result->convertErrorsToExceptions($this->useErrorHandler);
     }
     if (!$this->handleDependencies()) {
         return;
     }
     if ($this->runTestInSeparateProcess === TRUE && $this->inIsolation !== TRUE && !$this instanceof PHPUnit_Extensions_SeleniumTestCase && !$this instanceof PHPUnit_Extensions_PhptTestCase) {
         $class = new ReflectionClass($this);
         $template = new Text_Template(sprintf('%s%sProcess%sTestCaseMethod.tpl', __DIR__, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
         if ($this->preserveGlobalState) {
             $constants = PHPUnit_Util_GlobalState::getConstantsAsString();
             $globals = PHPUnit_Util_GlobalState::getGlobalsAsString();
             $includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString();
         } else {
             $constants = '';
             $globals = '';
             $includedFiles = '';
         }
         if ($result->getCollectCodeCoverageInformation()) {
             $coverage = 'TRUE';
         } else {
             $coverage = 'FALSE';
         }
         if ($result->isStrict()) {
             $strict = 'TRUE';
         } else {
             $strict = 'FALSE';
         }
         $data = var_export(serialize($this->data), TRUE);
         $dependencyInput = var_export(serialize($this->dependencyInput), TRUE);
         $includePath = var_export(get_include_path(), TRUE);
         // must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
         // the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
         $data = "'." . $data . ".'";
         $dependencyInput = "'." . $dependencyInput . ".'";
         $includePath = "'." . $includePath . ".'";
         $template->setVar(array('filename' => $class->getFileName(), 'className' => $class->getName(), 'methodName' => $this->name, 'collectCodeCoverageInformation' => $coverage, 'data' => $data, 'dataName' => $this->dataName, 'dependencyInput' => $dependencyInput, 'constants' => $constants, 'globals' => $globals, 'include_path' => $includePath, 'included_files' => $includedFiles, 'strict' => $strict));
         $this->prepareTemplate($template);
         $php = PHPUnit_Util_PHP::factory();
         $php->runJob($template->render(), $this, $result);
     } else {
         $result->run($this);
     }
     if ($this->useErrorHandler !== NULL) {
         $result->convertErrorsToExceptions($oldErrorHandlerSetting);
     }
     $this->result = NULL;
     return $result;
 }
开发者ID:Kapitonova,项目名称:codex,代码行数:68,代码来源:TestCase.php


示例17: run

    /**
     * Runs the test case and collects the results in a TestResult object.
     * If no TestResult object is passed a new one will be created.
     *
     * @param  PHPUnit_Framework_TestResult $result
     * @return PHPUnit_Framework_TestResult
     * @throws InvalidArgumentException
     */
    public function run(PHPUnit_Framework_TestResult $result = NULL)
    {
        if ($result === NULL) {
            $result = $this->createResult();
        }

        $this->result = $result;

        $this->setExpectedExceptionFromAnnotation();
        $this->setUseErrorHandlerFromAnnotation();
        $this->setUseOutputBufferingFromAnnotation();

        if ($this->useErrorHandler !== NULL) {
            $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
            $result->convertErrorsToExceptions($this->useErrorHandler);
        }

        if (!$this->handleDependencies()) {
            return;
        }

        if ($this->runTestInSeparateProcess === TRUE &&
            $this->inIsolation !== TRUE &&
            !$this instanceof PHPUnit_Extensions_SeleniumTestCase &&
            !$this instanceof PHPUnit_Extensions_PhptTestCase) {
            $class = new ReflectionClass($this);

            $template = new Text_Template(
              sprintf(
                '%s%sProcess%sTestCaseMethod.tpl',

                dirname(__FILE__),
                DIRECTORY_SEPARATOR,
                DIRECTORY_SEPARATOR,
                DIRECTORY_SEPARATOR
              )
            );

            if ($this->preserveGlobalState) {
                $constants     = PHPUnit_Util_GlobalState::getConstantsAsString();
                $globals       = PHPUnit_Util_GlobalState::getGlobalsAsString();
                $includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString();
            } else {
                $constants     = '';
                $globals       = '';
                $includedFiles = '';
            }

            if ($result->getCollectCodeCoverageInformation()) {
                $coverage = 'TRUE';
            } else {
                $coverage = 'FALSE';
            }

            if ($result->isStrict()) {
                $strict = 'TRUE';
            } else {
                $strict = 'FALSE';
            }

            $data            = addcslashes(serialize($this->data), "'");
            $dependencyInput = addcslashes(
              serialize($this->dependencyInput), "'"
            );
            $includePath     = addslashes(get_include_path());

            $template->setVar(
              array(
                'filename'                       => $class->getFileName(),
                'className'                      => $class->getName(),
                'methodName'                     => $this->name,
                'collectCodeCoverageInformation' => $coverage,
                'data'                           => $data,
                'dataName'                       => $this->dataName,
                'dependencyInput'                => $dependencyInput,
                'constants'                      => $constants,
                'globals'                        => $globals,
                'include_path'                   => $includePath,
                'included_files'                 => $includedFiles,
                'strict'                         => $strict
              )
            );

            $this->prepareTemplate($template);

            PHPUnit_Util_PHP::runJob($template->render(), $this, $result);
        } else {
            $result->run($this);
        }

        if ($this->useErrorHandler !== NULL) {
            $result->convertErrorsToExceptions($oldErrorHandlerSetting);
//.........这里部分代码省略.........
开发者ID:naderman,项目名称:phpunit,代码行数:101,代码来源:TestCase.php


示例18: prepareTemplate

 /**
  * {@inheritdoc}
  */
 protected function prepareTemplate(\Text_Template $template)
 {
     $bootstrap_globals = '';
     // Fix missing bootstrap.php when $preserveGlobalState is FALSE.
     // @see https://github.com/sebastianbergmann/phpunit/pull/797
     $bootstrap_globals .= '$__PHPUNIT_BOOTSTRAP = ' . var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], TRUE) . ";\n";
     // Avoid repetitive test namespace discoveries to improve performance.
     // @see /core/tests/bootstrap.php
     $bootstrap_globals .= '$namespaces = ' . var_export($GLOBALS['namespaces'], TRUE) . ";\n";
     $template->setVar(array('constants' => '', 'included_files' => '', 'globals' => $bootstrap_globals));
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:14,代码来源:KernelTestBase.php


示例19: generateMockedMethodDefinition

 /**
  * @param  string $templateDir
  * @param  string $className
  * @param  string $methodName
  * @param  bool   $cloneArguments
  * @param  string $modifier
  * @param  string $arguments_decl
  * @param  string $arguments_call
  * @param  string $reference
  * @param  bool   $callOriginalMethods
  * @param  bool   $static
  * @return string
  */
 protected function generateMockedMethodDefinition($templateDir, $className, $methodName, $cloneArguments = true, $modifier = 'public', $arguments_decl = '', $arguments_call = '', $reference = '', $callOriginalMethods = false, $static = false)
 {
     if ($static) {
         $templateFile = 'mocked_static_method.tpl';
     } else {
         $templateFile = sprintf('%s_method.tpl', $callOriginalMethods ? 'proxied' : 'mocked');
     }
     $template = new Text_Template($templateDir . $templateFile);
     $template->setVar(array('arguments_decl' => $arguments_decl, 'arguments_call' => $arguments_call, 'arguments_count' => !empty($arguments_call) ? count(explode(',', $arguments_call)) : 0, 'class_name' => $className, 'method_name' => $methodName, 'modifier' => $modifier, 'reference' => $reference, 'clone_arguments' => $cloneArguments ? 'TRUE' : 'FALSE'));
     return $template->render();
 }
开发者ID:azonwan,项目名称:pingju,代码行数:24,代码来源:Generator.php


示例20: generate


//.........这里部分代码省略.........

                            else if ($assertion == 'Equals' &&
                                     strtolower($matches[3]) == 'true') {
                                $assertion = 'True';
                                $template  = 'TestMethodBool';
                            }

                            else if ($assertion == 'NotEquals' &&
                                     strtolower($matches[3]) == 'true') {
                                $assertion = 'False';
                                $template  = 'TestMethodBool';
                            }

                            else if ($assertion == 'Equals' &&
                                     strtolower($matches[3]) == 'false') {
                                $assertion = 'False';
                                $template  = 'TestMethodBool';
                            }

                            else if ($assertion == 'NotEquals' &&
                                     strtolower($matches[3]) == 'false') {
                                $assertion = 'True';
                                $template  = 'TestMethodBool';
                            }

                            else {
                                $template = 'TestMethod';
                            }

                            if ($method->isStatic()) {
                                $template .= 'Static';
                            }

                            $methodTemplate = new Text_Template(
                              sprintf(
                                '%s%sTemplate%s%s.tpl',

                                dirname(__FILE__),
                                DIRECTORY_SEPARATOR,
                                DIRECTORY_SEPARATOR,
                                $template
                              )
                            );

                            $origMethodName = $method->getName();
                            $methodName     = ucfirst($origMethodName);

                            if (isset($this->methodNameCounter[$methodName])) {
                                $this->methodNameCounter[$methodName]++;
                            } else {
                                $this->methodNameCounter[$methodName] = 1;
                            }

                            if ($this->methodNameCounter[$methodName] > 1) {
                                $methodName .= $this->methodNameCounter[$methodName];
                            }

                            $methodTemplate->setVar(
                              array(
                                'annotation'     => trim($annotation),
                                'arguments'      => $matches[1],
                                'assertion'      => isset($assertion) ? $assertion : '',
                                'expected'       => $matches[3],
                                'origMethodName' => $origMethodName,
                                'className'      => $this->inClassName['fullyQualifiedClassName'],
                                'methodName'     => $methodName
开发者ID:schwarer2006,项目名称:wikia,代码行数:67,代码来源:Test.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Textarea类代码示例发布时间:2022-05-23
下一篇:
PHP Text_Diff_Renderer_inline类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap