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


PHP PHPUnit_Framework_TestCase::getAnnotations方法代码示例

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


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

示例1: setUpContext

 /**
  * @param \PHPUnit_Framework_TestCase $testCase
  */
 private function setUpContext(\PHPUnit_Framework_TestCase $testCase)
 {
     $annotations = $testCase->getAnnotations();
     if (isset($annotations['method'][$this->annotationName])) {
         $this->callMethods($testCase, $annotations['method'][$this->annotationName]);
     }
 }
开发者ID:nikoms,项目名称:phpunit-dynamic-fixture,代码行数:10,代码来源:DynamicFixtureListener.php

示例2: registerComponents

 /**
  * Register fixture components
  *
  * @param \PHPUnit_Framework_TestCase $test
  */
 private function registerComponents(\PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     $componentAnnotations = [];
     if (isset($annotations['class'][self::ANNOTATION_NAME])) {
         $componentAnnotations = array_merge($componentAnnotations, $annotations['class'][self::ANNOTATION_NAME]);
     }
     if (isset($annotations['method'][self::ANNOTATION_NAME])) {
         $componentAnnotations = array_merge($componentAnnotations, $annotations['method'][self::ANNOTATION_NAME]);
     }
     if (empty($componentAnnotations)) {
         return;
     }
     $componentAnnotations = array_unique($componentAnnotations);
     $reflection = new \ReflectionClass(self::REGISTRAR_CLASS);
     $paths = $reflection->getProperty(self::PATHS_FIELD);
     $paths->setAccessible(true);
     $this->origComponents = $paths->getValue();
     $paths->setAccessible(false);
     foreach ($componentAnnotations as $fixturePath) {
         $fixturesDir = $this->fixtureBaseDir . '/' . $fixturePath;
         if (!file_exists($fixturesDir)) {
             throw new \InvalidArgumentException(self::ANNOTATION_NAME . " fixture '{$fixturePath}' does not exist");
         }
         $iterator = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir, \FilesystemIterator::SKIP_DOTS)), '/^.+\\/registration\\.php$/');
         /**
          * @var \SplFileInfo $registrationFile
          */
         foreach ($iterator as $registrationFile) {
             require $registrationFile->getRealPath();
         }
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:38,代码来源:ComponentRegistrarFixture.php

示例3: startTest

 /**
  * Start test case event observer
  *
  * @param \PHPUnit_Framework_TestCase $test
  */
 public function startTest(\PHPUnit_Framework_TestCase $test)
 {
     $area = $this->_getTestAppArea($test->getAnnotations());
     if ($this->_application->getArea() !== $area) {
         $this->_application->reinitialize();
         if ($this->_application->getArea() !== $area) {
             $this->_application->loadArea($area);
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:AppArea.php

示例4: startTest

 /**
  * Handler for 'startTest' event
  *
  * @param \PHPUnit_Framework_TestCase $test
  * @return void
  */
 public function startTest(\PHPUnit_Framework_TestCase $test)
 {
     $source = $test->getAnnotations();
     if (isset($source['method']['magentoCache'])) {
         $annotations = $source['method']['magentoCache'];
     } elseif (isset($source['class']['magentoCache'])) {
         $annotations = $source['class']['magentoCache'];
     } else {
         return;
     }
     $this->setValues($this->parseValues($annotations, $test), $test);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Cache.php

示例5: _assignConfigData

 /**
  * Assign required config values and save original ones
  *
  * @param \PHPUnit_Framework_TestCase $test
  */
 protected function _assignConfigData(\PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     if (!isset($annotations['method']['magentoAdminConfigFixture'])) {
         return;
     }
     foreach ($annotations['method']['magentoAdminConfigFixture'] as $configPathAndValue) {
         list($configPath, $requiredValue) = preg_split('/\\s+/', $configPathAndValue, 2);
         $originalValue = $this->_getConfigValue($configPath);
         $this->_configValues[$configPath] = $originalValue;
         $this->_setConfigValue($configPath, $requiredValue);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:AdminConfigFixture.php

示例6: endTest

 /**
  * Handler for 'endTest' event
  *
  * @param \PHPUnit_Framework_TestCase $test
  * @throws \Magento\Framework\Exception
  */
 public function endTest(\PHPUnit_Framework_TestCase $test)
 {
     $this->_hasNonIsolatedTests = true;
     /* Determine an isolation from doc comment */
     $annotations = $test->getAnnotations();
     if (isset($annotations['method']['magentoAppIsolation'])) {
         $isolation = $annotations['method']['magentoAppIsolation'];
         if ($isolation !== array('enabled') && $isolation !== array('disabled')) {
             throw new \Magento\Framework\Exception('Invalid "@magentoAppIsolation" annotation, can be "enabled" or "disabled" only.');
         }
         $isIsolationEnabled = $isolation === array('enabled');
     } else {
         /* Controller tests should be isolated by default */
         $isIsolationEnabled = $test instanceof \Magento\TestFramework\TestCase\AbstractController;
     }
     if ($isIsolationEnabled) {
         $this->_isolateApp();
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:25,代码来源:AppIsolation.php

示例7: _getFixtures

 /**
  * Retrieve fixtures from annotation
  *
  * @param string $scope 'class' or 'method'
  * @param \PHPUnit_Framework_TestCase $test
  * @return array
  * @throws \Magento\Framework\Exception
  */
 protected function _getFixtures($scope, \PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     $result = [];
     if (!empty($annotations[$scope]['magentoApiDataFixture'])) {
         foreach ($annotations[$scope]['magentoApiDataFixture'] as $fixture) {
             if (strpos($fixture, '\\') !== false) {
                 // usage of a single directory separator symbol streamlines search across the source code
                 throw new \Magento\Framework\Exception('Directory separator "\\" is prohibited in fixture declaration.');
             }
             $fixtureMethod = [get_class($test), $fixture];
             if (is_callable($fixtureMethod)) {
                 $result[] = $fixtureMethod;
             } else {
                 $result[] = $this->_fixtureBaseDir . '/' . $fixture;
             }
         }
     }
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:ApiDataFixture.php

示例8: endTest

 /**
  * Handler for 'endTest' event
  *
  * @param PHPUnit_Framework_TestCase $test
  * @throws Magento_Exception
  */
 public function endTest(PHPUnit_Framework_TestCase $test)
 {
     $this->_hasNonIsolatedTests = true;
     /* Determine an isolation from doc comment */
     $annotations = $test->getAnnotations();
     if (isset($annotations['method']['magentoAppIsolation'])) {
         $isolation = $annotations['method']['magentoAppIsolation'];
         if ($isolation !== array('enabled') && $isolation !== array('disabled')) {
             throw new Magento_Exception('Invalid "@magentoAppIsolation" annotation, can be "enabled" or "disabled" only.');
         }
         $isIsolationEnabled = $isolation === array('enabled');
     } else {
         /* Controller tests should be isolated by default */
         $isIsolationEnabled = $test instanceof Magento_Test_TestCase_ControllerAbstract;
     }
     if ($isIsolationEnabled) {
         $this->_isolateApp();
     }
     /* Forced garbage collection to avoid process non-zero exit code (exec returned: 139) caused by PHP bug  */
     gc_collect_cycles();
 }
开发者ID:nayanchamp,项目名称:magento2,代码行数:27,代码来源:AppIsolation.php

示例9: _assignConfigData

 /**
  * Assign required config values and save original ones
  *
  * @param \PHPUnit_Framework_TestCase $test
  */
 protected function _assignConfigData(\PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     if (!isset($annotations['method']['magentoConfigFixture'])) {
         return;
     }
     foreach ($annotations['method']['magentoConfigFixture'] as $configPathAndValue) {
         if (preg_match('/^.+?(?=_store\\s)/', $configPathAndValue, $matches)) {
             /* Store-scoped config value */
             $storeCode = $matches[0] != 'current' ? $matches[0] : null;
             $parts = preg_split('/\\s+/', $configPathAndValue, 3);
             list(, $configPath, $requiredValue) = $parts + ['', '', ''];
             $originalValue = $this->_getConfigValue($configPath, $storeCode);
             $this->_storeConfigValues[$storeCode][$configPath] = $originalValue;
             $this->_setConfigValue($configPath, $requiredValue, $storeCode);
         } else {
             /* Global config value */
             list($configPath, $requiredValue) = preg_split('/\\s+/', $configPathAndValue, 2);
             $originalValue = $this->_getConfigValue($configPath);
             $this->_globalConfigValues[$configPath] = $originalValue;
             $this->_setConfigValue($configPath, $requiredValue);
         }
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:29,代码来源:ConfigFixture.php

示例10: getSlowThreshold

 /**
  * Get slow test threshold for given test. A TestCase can override the
  * suite-wide slow threshold by using the annotation @slowThreshold with
  * the threshold value in milliseconds.
  *
  * The following test will only be considered slow when its execution time
  * reaches 5000ms (5 seconds):
  *
  * <code>
  * @slowThreshold 5000
  * public function testLongRunningProcess() {}
  * </code>
  *
  * @param PHPUnit_Framework_TestCase $test
  * @return int
  */
 protected function getSlowThreshold(PHPUnit_Framework_TestCase $test)
 {
     $ann = $test->getAnnotations();
     return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
 }
开发者ID:ekandreas,项目名称:extended-cpts,代码行数:21,代码来源:SpeedTrapListener.php

示例11: checkValidCoversForTest

 /**
  * Check an individual test run for valid @covers annotation.
  *
  * This method is called from $this::endTest().
  *
  * @param \PHPUnit_Framework_TestCase $test
  *   The test to examine.
  */
 public function checkValidCoversForTest(\PHPUnit_Framework_TestCase $test)
 {
     // If we're generating a coverage report already, don't do anything here.
     if ($test->getTestResultObject() && $test->getTestResultObject()->getCollectCodeCoverageInformation()) {
         return;
     }
     // Gather our annotations.
     $annotations = $test->getAnnotations();
     // Glean the @coversDefaultClass annotation.
     $default_class = '';
     $valid_default_class = FALSE;
     if (isset($annotations['class']['coversDefaultClass'])) {
         if (count($annotations['class']['coversDefaultClass']) > 1) {
             $this->fail($test, '@coversDefaultClass has too many values');
         }
         // Grab the first one.
         $default_class = reset($annotations['class']['coversDefaultClass']);
         // Check whether the default class exists.
         $valid_default_class = $this->classExists($default_class);
         if (!$valid_default_class) {
             $this->fail($test, "@coversDefaultClass does not exist '{$default_class}'");
         }
     }
     // Glean @covers annotation.
     if (isset($annotations['method']['covers'])) {
         // Drupal allows multiple @covers per test method, so we have to check
         // them all.
         foreach ($annotations['method']['covers'] as $covers) {
             // Ensure the annotation isn't empty.
             if (trim($covers) === '') {
                 $this->fail($test, '@covers should not be empty');
                 // If @covers is empty, we can't proceed.
                 return;
             }
             // Ensure we don't have ().
             if (strpos($covers, '()') !== FALSE) {
                 $this->fail($test, "@covers invalid syntax: Do not use '()'");
             }
             // Glean the class and method from @covers.
             $class = $covers;
             $method = '';
             if (strpos($covers, '::') !== FALSE) {
                 list($class, $method) = explode('::', $covers);
             }
             // Check for the existence of the class if it's specified by @covers.
             if (!empty($class)) {
                 // If the class doesn't exist we have either a bad classname or
                 // are missing the :: for a method. Either way we can't proceed.
                 if (!$this->classExists($class)) {
                     if (empty($method)) {
                         $this->fail($test, "@covers invalid syntax: Needs '::' or class does not exist in {$covers}");
                         return;
                     } else {
                         $this->fail($test, '@covers class does not exist ' . $class);
                         return;
                     }
                 }
             } else {
                 // The class isn't specified and we have the ::, so therefore this
                 // test either covers a function, or relies on a default class.
                 if (empty($default_class)) {
                     // If there's no default class, then we need to check if the global
                     // function exists. Since this listener should always be listening
                     // for endTest(), the function should have already been loaded from
                     // its .module or .inc file.
                     if (!function_exists($method)) {
                         $this->fail($test, '@covers global method does not exist ' . $method);
                     }
                 } else {
                     // We have a default class and this annotation doesn't act like a
                     // global function, so we should use the default class if it's
                     // valid.
                     if ($valid_default_class) {
                         $class = $default_class;
                     }
                 }
             }
             // Finally, after all that, let's see if the method exists.
             if (!empty($class) && !empty($method)) {
                 $ref_class = new \ReflectionClass($class);
                 if (!$ref_class->hasMethod($method)) {
                     $this->fail($test, '@covers method does not exist ' . $class . '::' . $method);
                 }
             }
         }
     }
 }
开发者ID:dev981,项目名称:gaptest,代码行数:95,代码来源:DrupalStandardsListener.php

示例12: getAnnotations

 /**
  * @param \PHPUnit_Framework_TestCase $test
  * @return array
  */
 private function getAnnotations(\PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     return array_replace($annotations['class'], $annotations['method']);
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:9,代码来源:DataFixtureBeforeTransaction.php

示例13: _getIsolation

 /**
  * Retrieve database isolation annotation value for the current scope.
  * Possible results:
  *   NULL  - annotation is not defined
  *   TRUE  - annotation is defined as 'enabled'
  *   FALSE - annotation is defined as 'disabled'
  *
  * @param string $scope 'class' or 'method'
  * @param PHPUnit_Framework_TestCase $test
  * @return bool|null Returns NULL, if isolation is not defined for the current scope
  * @throws Magento_Exception
  */
 protected function _getIsolation($scope, PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     if (isset($annotations[$scope]['magentoDbIsolation'])) {
         $isolation = $annotations[$scope]['magentoDbIsolation'];
         if ($isolation !== array('enabled') && $isolation !== array('disabled')) {
             throw new Magento_Exception('Invalid "@magentoDbIsolation" annotation, can be "enabled" or "disabled" only.');
         }
         return $isolation === array('enabled');
     }
     return null;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:24,代码来源:DbIsolation.php

示例14: hasDataprovider

 /**
  * Determines, if there is a data provider defined for the current test case.
  *
  * @param \PHPUnit_Framework_Test $test
  *
  * @return boolean
  */
 protected function hasDataprovider(\PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     return !empty($annotations['method']['dataProvider']);
 }
开发者ID:lapistano,项目名称:wsunit,代码行数:12,代码来源:WebServiceListener.php


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