コード例 #1
0
 /**
  * Get Constraint object
  *
  * @param string $class
  * @return ConstraintInterface
  * @throws \UnexpectedValueException
  */
 public function get($class)
 {
     $object = $this->objectManager->get($class);
     if (!$object instanceof ConstraintInterface) {
         throw new \UnexpectedValueException(sprintf('Constraint class "%s" has to implement \\Mtf\\Constraint\\ConstraintInterface interface.', $class));
     }
     return $object;
 }
コード例 #2
0
ファイル: AppState.php プロジェクト: Mohitsahu123/mtf
 /**
  * @param string $class
  * @param string $name
  * @param array $arguments
  * @return void
  */
 public function appStateCallback($class, $name = '', array $arguments = [])
 {
     /** @var $appState StateInterface */
     $appState = $this->appStateFactory->create($class, $arguments);
     $appState->apply();
     /** @var \Mtf\System\Event\EventManager $eventManager */
     $eventManager = $this->objectManager->get('Mtf\\System\\Event\\EventManager');
     $eventManager->dispatchEvent(['app_state_applied'], [$name]);
 }
コード例 #3
0
ファイル: TestSuiteFactory.php プロジェクト: Mohitsahu123/mtf
 /**
  * Get test suite
  *
  * @param string $class
  * @return InjectableTestCase|RegularTestCase
  */
 public function get($class)
 {
     $refClass = new \ReflectionClass($class);
     if ($refClass->isSubclassOf('Mtf\\TestCase\\Injectable')) {
         $object = $this->objectManager->get('Mtf\\TestSuite\\InjectableTestCase');
     } else {
         $object = $this->objectManager->create('Mtf\\TestSuite\\RegularTestCase');
     }
     return $object;
 }
コード例 #4
0
 /**
  * Initialize module filters and related data structures
  *
  * @return void
  */
 protected function init()
 {
     $moduleFilter = getenv(self::MODULE_FILTER);
     if (empty($moduleFilter)) {
         $this->moduleFilters = [];
         return;
     }
     $this->moduleFilters = array_map('trim', explode(',', $moduleFilter));
     if (empty($this->moduleFilters)) {
         return;
     }
     //
     $this->affectedModules = array_flip($this->moduleFilters);
     /** @var $constraintCrossReference \Mtf\Util\CrossModuleReference\Constraint */
     $constraintCrossReference = $this->objectManager->get('\\Mtf\\Util\\CrossModuleReference\\Constraint');
     /** @var $testStepCrossReference \Mtf\Util\CrossModuleReference\TestStep */
     $testStepCrossReference = $this->objectManager->get('\\Mtf\\Util\\CrossModuleReference\\TestStep');
     /** @var $pageCrossReference \Mtf\Util\CrossModuleReference\Page */
     $pageCrossReference = $this->objectManager->create('\\Mtf\\Util\\CrossModuleReference\\Page', ['constraintChecker' => $constraintCrossReference, 'modules' => $this->moduleFilters]);
     $crossModuleReferenceCheckers = [$constraintCrossReference, $testStepCrossReference, $pageCrossReference];
     $this->affectedTestCases = [];
     foreach ($crossModuleReferenceCheckers as $crossModuleReferenceChecker) {
         foreach ($this->moduleFilters as $module) {
             $affectedTestCases = $crossModuleReferenceChecker->getCrossModuleReference($module);
             $this->affectedTestCases = array_merge($this->affectedTestCases, $affectedTestCases);
         }
     }
 }
コード例 #5
0
ファイル: Functional.php プロジェクト: Mohitsahu123/mtf
 /**
  * Run code generator if necessary
  *
  * @return void
  */
 protected function generateCode()
 {
     if (self::$codeGenerationFlag) {
         return;
     }
     self::$codeGenerationFlag = true;
     /** @var $generate \Mtf\Util\Generate\Page */
     $generator = $this->objectManager->get('Mtf\\Util\\Generate\\Page');
     $generator->generateClasses();
     return;
 }
コード例 #6
0
ファイル: TestCase.php プロジェクト: Mohitsahu123/mtf
 /**
  * @constructor
  * @param string $theClass
  * @param string $name
  */
 public function __construct($theClass = '', $name = '')
 {
     $this->initObjectManager();
     $this->testSuiteFactory = $this->objectManager->get('Mtf\\TestSuite\\TestSuiteFactory');
     /** @var $testIterator \Mtf\Util\Iterator\TestCase */
     $testIterator = $this->objectManager->create('Mtf\\Util\\Iterator\\TestCase');
     while ($testIterator->valid()) {
         $arguments = $testIterator->current();
         $class = $arguments['class'];
         $factory = $this->testSuiteFactory;
         $testCallback = $this->objectManager->create('Mtf\\TestSuite\\Callback', ['factory' => $factory, 'arguments' => $arguments, 'theClass' => $class]);
         $rule = $this->objectManager->get('Mtf\\TestRunner\\Rule\\SuiteComposite');
         $testCaseSuite = $this->testSuiteFactory->get($class);
         $allow = $rule->filterSuite($testCaseSuite);
         if ($allow) {
             $this->addTest($testCallback, \PHPUnit_Util_Test::getGroups($class));
         }
         $testIterator->next();
     }
     parent::__construct($name);
 }
コード例 #7
0
ファイル: AbstractFactory.php プロジェクト: Mohitsahu123/mtf
 /**
  * Get class
  *
  * @param string $class
  * @return mixed
  */
 public function get($class)
 {
     $object = $this->objectManager->get($class);
     $this->checkInterface($object, $class);
     return $object;
 }