/** * * Generates a new KalturaTestsFailures object from a given failure file path * @param string $failureFilePath */ public function fromXml($failureFilePath) { $simpleXML = kXml::openXmlFile($failureFilePath); foreach ($simpleXML->Failures->UnitTestFailures as $unitTestFailureXml) { $this->testCaseFailures[] = KalturaTestCaseFailure::generateFromXml($unitTestFailureXml); } }
/** * * The test data provider (gets the data for the different tests) * @param string $className - The class name * @param string $procedureName - The current method (test) name * @return array<array>(); */ public function provider($className, $procedureName) { //print("In provider for $className, $procedureName \n"); //Gets from the given class the class data file $class = get_class($this); $classFilePath = KAutoloader::getClassFilePath($class); $testClassDir = dirname($classFilePath); $dataFilePath = $testClassDir . DIRECTORY_SEPARATOR . "testsData/{$className}.data"; KalturaLog::debug("The data file path [" . $dataFilePath . "]"); if (file_exists($dataFilePath)) { $simpleXML = kXml::openXmlFile($dataFilePath); } else { //TODO: Give notice or create the file don't throw an exception throw new Exception("Data file [{$dataFilePath}] not found"); } $inputsForTestProcedure = array(); foreach ($simpleXML->TestProcedureData as $xmlTestProcedureData) { if ($xmlTestProcedureData["testProcedureName"] != $procedureName) { continue; } foreach ($xmlTestProcedureData->TestCaseData as $xmlTestCaseData) { $testCaseInstanceInputs = array(); foreach ($xmlTestCaseData->Input as $input) { $object = KalturaTestDataObject::generatefromXml($input); //Add the new input to the test case instance data $testCaseInstanceInputs[] = $object; } foreach ($xmlTestCaseData->OutputReference as $output) { $object = KalturaTestDataObject::generatefromXml($output); //Add the new output reference to the test case instance data $testCaseInstanceInputs[] = $object; } //Add the test case into the test procedure data $inputsForTestProcedure[] = $testCaseInstanceInputs; } } KalturaLog::info("Tests data provided Before transformation to objects: \n[" . print_r($inputsForTestProcedure, true) . "]"); $inputsForTestProcedure = $this->transformToObjects($inputsForTestProcedure); KalturaLog::info("Tests data provided [" . print_r($inputsForTestProcedure, true) . "]"); return $inputsForTestProcedure; }
/** * Creates a new Kaltura objects DataGenerator * Gets The file path to it's configuration file * * @param string $dataGeneratorConfigFilePath the config file path */ public function __construct($dataGeneratorConfigFilePath) { $simpleXMLElement = kXml::openXmlFile($dataGeneratorConfigFilePath); $this->dataSourceFile = KalturaTestDataSourceFile::generateFromXML($simpleXMLElement); $this->dataSourceFile->setFilePath($dataGeneratorConfigFilePath); }
/** * Creates a new Kaltura objects DataGenerator * Gets The file path to it's configuration file * * @param string $dataGeneratorConfigFilePath the config file path */ public function __construct($dataGeneratorConfigFilePath) { $simpleXMLElement = kXml::openXmlFile($dataGeneratorConfigFilePath); $this->generatorConfigFile = KalturaDataGeneratorConfigFile::generateFromXML($simpleXMLElement); $this->generatorConfigFile->filePath = $dataGeneratorConfigFilePath; }
/** * * Generates a new KalturaTestsFailures object from a given failure file path * @param string $failureFilePath */ public function fromXml($failureFilePath) { $simpleXML = kXml::openXmlFile($failureFilePath); $this->testCaseName = $simpleXML["TestCaseName"]; foreach ($simpleXML->TestProcedureFailures as $testProcedureFailureXml) { $testProcedureFailure = KalturaTestProcedureFailure::generateFromXml($testProcedureFailureXml); $this->testProceduresFailures[$testProcedureFailure->getTestProcedureName()] = $testProcedureFailure; } }
/** * * Sets the object from a given data xml */ public function fromDataXml($dataFilePath) { KalturaLog::debug("Data file path [" . $dataFilePath . "]\n"); $simpleXmlElement = kXml::openXmlFile($dataFilePath); $this->testCaseName = (string) $simpleXmlElement["testCaseName"]; KalturaLog::debug("data file [" . $simpleXmlElement->asXML() . "]\n"); foreach ($simpleXmlElement->TestProcedureData as $xmlTestProcedureData) { $testProcedureData = KalturaTestProcedureData::generateFromDataXml($xmlTestProcedureData); $this->testProceduresData[$testProcedureData->getProcedureName()] = $testProcedureData; } }
/** * * Sets the object from a given data xml */ public function fromDataXml($dataFilePath) { $simpleXmlElement = kXml::openXmlFile($dataFilePath); $this->fileName = $dataFilePath; foreach ($simpleXmlElement->UnitTestsData->UnitTestData as $unitTestDataXml) { $unitTestData = KalturaUnitTestData::generateFromDataXml($unitTestDataXml); $this->unitTestsData[] = $unitTestData; } }