public function run(PHPUnit_Framework_TestResult $result = NULL) { if (is_array($this->theDependencies) && count($this->theDependencies)) { $className = get_class($this); $passed = $result->passed(); $passedKeys = array_keys($passed); foreach ($this->theDependencies as $dependency) { $dependency = $className . '::' . $dependency; if (in_array($dependency, $passedKeys)) { $this->theDependencyInput[] = $passed[$dependency]; } } } $ret = parent::run($result); $testConfig = $this->config->get('config'); if ($testConfig->reportPath) { $xml = new SimpleXMLElement('<test/>'); $xml->addAttribute('name', $this->getName()); $xml->addAttribute('status', $this->getStatus()); $xml->addAttribute('numAssertions', $this->getNumAssertions()); $xml->addAttribute('statusMessage', $this->getStatusMessage()); $resultElement = $xml->addChild('result'); $resultElement->addAttribute('returnedType', get_class($this->getResult())); if ($result instanceof PHPUnit_Framework_TestResult) { if ($result->errorCount()) { $errorsElemnt = $resultElement->addChild('errors'); $errors = $result->errors(); foreach ($errors as $error) { /* @var $error PHPUnit_Framework_TestFailure */ $errorElemnt = $errorsElemnt->addChild('error', $error->exceptionMessage()); } } if ($result->skippedCount()) { $skippedsElemnt = $resultElement->addChild('skippeds'); $skippeds = $result->skipped(); foreach ($skippeds as $skipped) { /* @var $skipped PHPUnit_Framework_TestFailure */ $skippedElemnt = $skippedsElemnt->addChild('skipped', $skipped->exceptionMessage()); } } if ($result->failureCount()) { $failuresElemnt = $resultElement->addChild('failures'); $failures = $result->failures(); foreach ($failures as $failure) { /* @var $failure PHPUnit_Framework_TestFailure */ $failureElemnt = $failuresElemnt->addChild('failure', $failure->exceptionMessage()); } } } $fileName = $testConfig->reportPath . DIRECTORY_SEPARATOR . get_class($this) . '.' . $this->getName() . '.xml'; $xml->asXML($fileName); } return $ret; }
/** * @return array<array> */ protected function provideTestData($className, $methodName) { KalturaLog::debug("class [{$className}], method [{$methodName}]"); $method = new ReflectionMethod($className, $methodName); $args = $method->getParameters(); $methodConfig = $this->config->get($methodName); if (!$methodConfig) { $default = new Zend_Config(array(), true); foreach ($args as $index => $arg) { $argConfig = new Zend_Config(array(), true); $argName = $arg->getName(); KalturaLog::info("Create default config for attribute [{$argName}] in method [{$methodName}]"); $objectType = $arg->getClass(); if ($objectType) { $objectType = $objectType->getName(); KalturaLog::info("Default config for attribute [{$argName}] of objectType [{$objectType}]"); $argConfig->objectType = $objectType; } elseif ($arg->isArray()) { KalturaLog::info("Default config for attribute [{$argName}] of objectType [array]"); $argConfig->objectType = 'array'; } else { KalturaLog::info("Default config for attribute [{$argName}] of native objectType"); $argConfig->objectType = 'native'; } $default->{$argName} = $argConfig; } $methodConfig = new Zend_Config(array('test1' => $default), true); $this->config->{$methodName} = $methodConfig; $this->config->saveToIniFile(); } $tests = array(); foreach ($methodConfig as $testName => $testConfig) { $test = array(); foreach ($args as $index => $arg) { try { $value = $this->getArgConfig($testConfig, $arg); $test[] = $value; } catch (KalturaTestException $e) { KalturaLog::log($e->getMessage()); } } $tests[] = $test; } KalturaLog::info("Tests data provided [" . print_r($tests, true) . "]"); return $tests; }
/** * * Clears a given name, if name = null clears all the names from the global data file * @param string $name */ public static function clearValue($name = null) { if (KalturaGlobalData::$dataFile == null) { $isInit = KalturaGlobalData::initDataFile(); if (!$isInit) { return null; } } if ($name) { if (is_string($name) || is_integer($name)) { $value = KalturaGlobalData::setData($name, null); KalturaLog::debug("Setting name [{$name}] to null"); } } else { self::$dataFile->clear($name); } }
/** * (non-PHPdoc) * @see Zend_Config::get() */ public function get($name, $default = null) { $value = parent::get($name, $default); $isGlobal = KalturaGlobalData::isGlobalData($value); if ($isGlobal) { $value = KalturaGlobalData::getData($value); } else { if ($value instanceof Zend_Config) { //We transform it to be a test configuration object so we can take global data from it $value = KalturaTestConfig::fromZendConfig($value); } } return $value; }