/** * * Gets an object from propel or from API by given type, id and additionalData * @param unknown_type $objectType - The object Type * @param unknown_type $objectId - The objetc Id * @param array<key=>value> $additionalData - Additional data is needed for api objects * @return $objectType - The object (or null if no object exists) */ private static function getObjectByTypeAndId($objectType, $objectId, array $additionalData = null) { $dataObject = null; //if the class exists if (class_exists($objectType)) { //we create new object and by his type decide from where to get it (DB or API) $objectInstance = new $objectType(); if ($objectInstance instanceof BaseObject) { $dataObject = KalturaUnitTestDataGenerator::getPropelObject($objectInstance, $objectId); } else { if ($objectInstance instanceof KalturaObject || $objectInstance instanceof KalturaObjectBase) { $partnerId = $additionalData["partnerId"]; $secret = $additionalData["secret"]; $serviceUrl = $additionalData["serviceUrl"]; $service = $additionalData["service"]; $dataObject = KalturaUnitTestDataGenerator::getAPIObject($objectInstance, $objectId, $partnerId, $secret, $serviceUrl, $service); } else { throw new Exception("What type am i? \n", var_dump($objectInstance)); } } } else { //For unknown types we just copy the xml row as is //TODO: add support for fileData object... create it from the file path given... } return $dataObject; }
<?php /** * This script is used in order to generate the different data files for the test. * Input: you should change the configFileName. * Output: the data generator wll go through the config file and will create the needed dat files. * */ require_once dirname(__FILE__) . '/../bootstrap/bootstrapServer.php'; if (count($argv) > 1) { $configFileName = $argv[1]; } else { //R&P tests $configFileName = "C:/opt/kaltura/app/tests/roles_and_permissions/testsData/testPermissionServiceTest.config"; } $testsDataGenerator = new KalturaUnitTestDataGenerator($configFileName); $testsDataGenerator->createTestFiles();