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


PHP core_kernel_classes_Class::createSubClass方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     TaoPhpUnitTestRunner::initTest();
     $rdfClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $this->class = $rdfClass->createSubClass('test class');
     $this->property = $this->class->createProperty('test property');
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:8,代码来源:SearchTest.php

示例2: testDeepCloneTriplesSimple

 public function testDeepCloneTriplesSimple()
 {
     $object = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAO.rdf#TAOObject');
     $subClass = $object->createSubClass("My sub Class test");
     //see if clone works
     $return = CloneHelper::deepCloneTriples($subClass->getRdfTriples());
     $this->assertEquals($subClass->getRdfTriples()->sequence, $return);
     $subClass->delete(true);
 }
开发者ID:kendaop,项目名称:extension-tao-revision,代码行数:9,代码来源:CloneHelperTest.php

示例3: setUp

 public function setUp()
 {
     GenerisPhpUnitTestRunner::initTest();
     $class = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $this->topClass = $class->createSubClass('test class 1');
     $this->emptyClass = $class->createSubClass('test class 2');
     $class1a = $this->topClass->createSubClass('test class 1a');
     $class1b = $this->topClass->createSubClass('test class 1b');
     $class1c = $this->topClass->createSubClass('test class 1c');
     $class1c1 = $class1c->createSubClass('test class 1c1');
     $instance1_1 = $this->topClass->createInstance('test instance 1.1');
     $instance1_2 = $this->topClass->createInstance('test instance 1.2');
     $instance1_3 = $this->topClass->createInstance('test instance 1.3');
     $instance1b_1 = $class1b->createInstance('test instance 1b.1');
     $instance1b_2 = $class1b->createInstance('test instance 1b.2');
     $instance1c1_1 = $class1c1->createInstance('test instance 1c1.1');
     $instance1c1_2 = $class1c1->createInstance('test instance 1c1.2');
 }
开发者ID:nagyist,项目名称:generis,代码行数:18,代码来源:GenerisIteratorTest.php

示例4: testGetDirectory

 public function testGetDirectory()
 {
     $root = new \core_kernel_classes_Class($this->rootClass);
     //Remove what has been done
     $subclasses = $root->getSubClasses();
     foreach ($subclasses as $subclass) {
         $subclass->delete(true);
     }
     $root->delete();
     $root->setLabel('myRootClass');
     $acceptableMime = array();
     $depth = 1;
     $directory = $this->mediaManagerManagement->getDirectory($this->rootClass, $acceptableMime, $depth);
     $this->assertInternalType('array', $directory, 'The result should be an array');
     $this->assertArrayHasKey('label', $directory, 'The result should contain "label"');
     $this->assertArrayHasKey('path', $directory, 'The result should contain "path"');
     $this->assertArrayHasKey('children', $directory, 'The result should contain "children"');
     $this->assertInternalType('array', $directory['children'], 'Children should be an array');
     $this->assertEmpty($directory['children'], 'Children should be empty');
     $this->assertEquals('myRootClass', $directory['label'], 'The label is not correct');
     $this->assertEquals('taomedia://mediamanager/' . \tao_helpers_Uri::encode($this->rootClass), $directory['path'], 'The path is not correct');
     $root->createSubClass('mySubClass1');
     $root->createSubClass('mySubClass0');
     $newDirectory = $this->mediaManagerManagement->getDirectory($this->rootClass, $acceptableMime, $depth);
     $this->assertInternalType('array', $newDirectory['children'], 'Children should be an array');
     $this->assertNotEmpty($newDirectory['children'], 'Children should not be empty');
     $labels = array();
     foreach ($newDirectory['children'] as $i => $child) {
         $this->assertInternalType('array', $child, 'The result should be an array');
         $this->assertArrayHasKey('label', $child, 'The result should contain "label"');
         $this->assertArrayHasKey('path', $child, 'The result should contain "path"');
         $labels[] = $child['label'];
     }
     $this->assertEquals(2, count($labels));
     $this->assertContains('mySubClass0', $labels);
     $this->assertContains('mySubClass1', $labels);
     //Remove what has been done
     $subclasses = $root->getSubClasses();
     foreach ($subclasses as $subclass) {
         $subclass->delete();
     }
     $root->delete();
 }
开发者ID:nagyist,项目名称:extension-tao-mediamanager,代码行数:43,代码来源:MediaManagerBrowserTest.php

示例5: testInject

 public function testInject()
 {
     $generisClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $testClass = $generisClass->createSubClass();
     try {
         $testInstance = $testClass->createInstanceWithProperties(array(RDFS_LABEL => '"hi"'));
         $testInstance->setPropertiesValues(array(RDFS_COMMENT => '"hi"'));
         $this->assertEquals($testInstance->getUniquePropertyValue(new core_kernel_classes_Property(RDFS_LABEL)), "\"hi\"");
     } catch (PDOException $e) {
         $this->fail('SQL Error: ' . $e->getMessage());
     }
     $testInstance->delete();
     $generisClass->delete();
 }
开发者ID:nagyist,项目名称:generis,代码行数:14,代码来源:SqlInjectionTest.php

示例6: generateItems

 public static function generateItems($count = 100)
 {
     // load QTI constants
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
     $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDevTools');
     $generationId = NameGenerator::generateRandomString(4);
     $topClass = new \core_kernel_classes_Class(TAO_ITEM_CLASS);
     $class = $topClass->createSubClass('Generation ' . $generationId);
     $fileClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/generis.rdf#File');
     $sampleFile = $ext->getDir() . 'data/items/sampleItem.xml';
     helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG);
     for ($i = 0; $i < $count; $i++) {
         $report = ImportService::singleton()->importQTIFile($sampleFile, $class, false);
         $item = $report->getData();
         $item->setLabel(NameGenerator::generateTitle());
     }
     helpers_TimeOutHelper::reset();
     return $class;
 }
开发者ID:nagyist,项目名称:extension-tao-devtools,代码行数:19,代码来源:DataGenerator.php

示例7: createContextOfThetest

 public function createContextOfThetest()
 {
     // Top Class : TaoSubject
     $subjectClass = new core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject');
     // Create a new subject class for the unit test
     $this->targetSubjectClass = $subjectClass->createSubClass("Sub Subject Class (Unit Test)");
     // Add an instance to this subject class
     $subject1 = $this->targetSubjectClass->createInstance("Sub Subject (Unit Test)");
     $this->assertEquals(count($this->targetSubjectClass->getInstances()), 1);
     // Create a new subject sub class to the previous sub class
     $this->targetSubjectSubClass = $this->targetSubjectClass->createSubClass("Sub Sub Subject Class (Unit Test)");
     // Add an instance to this sub subject class
     $subject2 = $this->targetSubjectSubClass->createInstance("Sub Sub Subject (Unit Test)");
     $this->assertEquals(count($this->targetSubjectSubClass->getInstances()), 1);
     $this->assertEquals(count($this->targetSubjectClass->getInstances()), 1);
     // If get instances in the sub classes of the targetSubjectClass, we should get 2 instances
     $this->assertEquals(count($this->targetSubjectClass->getInstances(true)), 2);
     $this->dataIntegrity['statements0'] = $this->countStatements();
     $this->dataIntegrity['subSubjectClassCount0'] = $this->targetSubjectClass->countInstances();
     $this->dataIntegrity['subSubSubjectClassCount0'] = $this->targetSubjectSubClass->countInstances();
 }
开发者ID:nagyist,项目名称:extension-generis-hard,代码行数:21,代码来源:UnhardifyTest.php

示例8: setUp

 /**
  * tests initialization
  * load qti service
  */
 public function setUp()
 {
     TaoPhpUnitTestRunner::initTest();
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoItems');
     $itemTopClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAOItem.rdf#Item');
     $this->itemClass = $itemTopClass->createSubClass('style service unit test', 'create for unit test ' . time());
     $itemService = \taoItems_models_classes_ItemsService::singleton();
     $qtiItemModel = new \core_kernel_classes_Resource(ItemModel::MODEL_URI);
     $itemA = $this->itemClass->createInstance('itemA');
     $itemService->setItemModel($itemA, $qtiItemModel);
     $itemService->setItemContent($itemA, file_get_contents(dirname(__FILE__) . '/samples/itemA.xml'));
     $this->items[] = $itemA;
     $itemB = $this->itemClass->createInstance('itemB');
     $itemService->setItemModel($itemB, $qtiItemModel);
     $itemService->setItemContent($itemB, file_get_contents(dirname(__FILE__) . '/samples/itemB.xml'));
     $this->items[] = $itemB;
     $itemC = $this->itemClass->createInstance('itemC');
     $itemService->setItemModel($itemC, $qtiItemModel);
     $itemService->setItemContent($itemC, file_get_contents(dirname(__FILE__) . '/samples/itemC.xml'));
     $this->items[] = $itemC;
 }
开发者ID:oat-sa,项目名称:extension-tao-itemqti,代码行数:25,代码来源:StyleServiceTest.php

示例9: import

 /**
  * Main method: run the import
  */
 public function import()
 {
     $this->log();
     foreach ($this->getSasFiles() as $extension => $sasFile) {
         $this->parseSasFile($extension, $sasFile);
     }
     //insert process vars
     $processVarNum = count($this->processVars);
     $processVarInserted = 0;
     foreach ($this->processVars as $processVar) {
         if ($this->addProcessVariable($processVar)) {
             $processVarInserted++;
             if (!$this->outputModeWeb) {
                 echo "\r{$processVarInserted} / {$processVarNum}  process variable inserted";
             }
         }
     }
     if ($this->outputModeWeb) {
         $this->log("{$processVarInserted} / {$processVarNum}  process variable inserted");
     } else {
         echo "\n";
     }
     //insert formal params
     $formaParamNum = count($this->formalParams);
     $formaParamInserted = 0;
     foreach ($this->formalParams as $formalParam) {
         if ($this->addFormalParameter($formalParam)) {
             $formaParamInserted++;
             if (!$this->outputModeWeb) {
                 echo "\r{$formaParamInserted} / {$formaParamNum}  formal parameters inserted";
             }
         }
     }
     if ($this->outputModeWeb) {
         $this->log("{$formaParamInserted} / {$formaParamNum}  formal parameters inserted");
     } else {
         echo "\n";
     }
     //insert service definitions
     $serviceNum = count($this->services);
     $serviceInserted = 0;
     foreach ($this->services as $extensionName => $services) {
         $extensionServiceClass = $this->serviceDefClass->createSubClass($extensionName, "{$extensionName} related services");
         foreach ($services as $service) {
             if ($this->addService($extensionServiceClass, $service['name'], $service['url'], $service['description'], $service['params'])) {
                 $serviceInserted++;
                 if (!$this->outputModeWeb) {
                     echo "\r{$serviceInserted} / {$serviceNum}  services definition inserted";
                 }
             }
         }
     }
     if ($this->outputModeWeb) {
         $this->log("{$serviceInserted} / {$serviceNum}  services definition inserted");
     } else {
         echo "\n";
     }
     // @todo remove temporary solution and improve the way AccessControl and workflows interact
     $missingRights = array(array('ext' => 'taoItems', 'mod' => 'SaSItems'), array('ext' => 'taoTestTaker', 'mod' => 'SasTestTaker'), array('ext' => 'taoTestTaker', 'mod' => 'SasImport'), array('ext' => 'taoTests', 'mod' => 'SaSTests'), array('ext' => 'taoGroups', 'mod' => 'SaSGroups'), array('ext' => 'taoDelivery', 'mod' => 'SaSResultServer'), array('ext' => 'taoDelivery', 'mod' => 'SaSDelivery'), array('ext' => 'tao', 'mod' => 'WebService'), array('ext' => 'taoResults', 'mod' => 'SaSResults'), array('ext' => 'tao', 'mod' => 'SaSUsers'), array('ext' => 'tao', 'mod' => 'File'));
     foreach ($missingRights as $filter) {
         $rule = new AccessRule(AccessRule::GRANT, INSTANCE_ROLE_WORKFLOW, $filter);
         AclProxy::applyRule($rule);
     }
     $this->log("import finished");
 }
开发者ID:nagyist,项目名称:extension-tao-wfengine,代码行数:68,代码来源:importSas.php

示例10: importTest

 /**
  * Import a QTI Test and its dependent Items into the TAO Platform.
  *
  * @param core_kernel_classes_Class $targetClass The RDFS Class where Ontology resources must be created.
  * @param oat\taoQtiItem\model\qti\Resource $qtiTestResource The QTI Test Resource representing the IMS QTI Test to be imported.
  * @param taoQtiTest_models_classes_ManifestParser $manifestParser The parser used to retrieve the IMS Manifest.
  * @param string $folder The absolute path to the folder where the IMS archive containing the test content
  * @return common_report_Report A report about how the importation behaved.
  */
 protected function importTest(core_kernel_classes_Class $targetClass, Resource $qtiTestResource, taoQtiTest_models_classes_ManifestParser $manifestParser, $folder)
 {
     $itemImportService = ImportService::singleton();
     $itemService = taoItems_models_classes_ItemsService::singleton();
     $testClass = $targetClass;
     // Create an RDFS resource in the knowledge base that will hold
     // the information about the imported QTI Test.
     $testResource = $this->createInstance($testClass);
     $qtiTestModelResource = new core_kernel_classes_Resource(INSTANCE_TEST_MODEL_QTI);
     $modelProperty = new core_kernel_classes_Property(PROPERTY_TEST_TESTMODEL);
     $testResource->editPropertyValues($modelProperty, $qtiTestModelResource);
     // Create the report that will hold information about the import
     // of $qtiTestResource in TAO.
     $report = new common_report_Report(common_report_Report::TYPE_INFO);
     // The class where the items that belong to the test will be imported.
     $itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS);
     $targetClass = $itemClass->createSubClass($testResource->getLabel());
     // Load and validate the manifest
     $qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($folder . 'imsmanifest.xml');
     $qtiManifestParser->validate();
     // Prepare Metadata mechanisms.
     $metadataMapping = oat\taoQtiItem\model\qti\Service::singleton()->getMetadataRegistry()->getMapping();
     $metadataInjectors = array();
     $metadataGuardians = array();
     $metadataClassLookups = array();
     $metadataValues = array();
     $domManifest = new DOMDocument('1.0', 'UTF-8');
     $domManifest->load($folder . 'imsmanifest.xml');
     foreach ($metadataMapping['injectors'] as $injector) {
         $metadataInjectors[] = new $injector();
     }
     foreach ($metadataMapping['guardians'] as $guardian) {
         $metadataGuardians[] = new $guardian();
     }
     foreach ($metadataMapping['classLookups'] as $classLookup) {
         $metadataClassLookups[] = new $classLookup();
     }
     foreach ($metadataMapping['extractors'] as $extractor) {
         $metadataExtractor = new $extractor();
         $metadataValues = array_merge($metadataValues, $metadataExtractor->extract($domManifest));
     }
     // Set up $report with useful information for client code (especially for rollback).
     $reportCtx = new stdClass();
     $reportCtx->manifestResource = $qtiTestResource;
     $reportCtx->rdfsResource = $testResource;
     $reportCtx->itemClass = $targetClass;
     $reportCtx->items = array();
     $report->setData($reportCtx);
     // Expected test.xml file location.
     $expectedTestFile = $folder . str_replace('/', DIRECTORY_SEPARATOR, $qtiTestResource->getFile());
     // Already imported test items (qti xml file paths).
     $alreadyImportedTestItemFiles = array();
     // -- Check if the file referenced by the test QTI resource exists.
     if (is_readable($expectedTestFile) === false) {
         $report->add(common_report_Report::createFailure(__('No file found at location "%s".', $qtiTestResource->getFile())));
     } else {
         // -- Load the test in a QTISM flavour.
         $testDefinition = new XmlDocument();
         try {
             $testDefinition->load($expectedTestFile, true);
             // -- Load all items related to test.
             $itemError = false;
             // discover test's base path.
             $dependencies = taoQtiTest_helpers_Utils::buildAssessmentItemRefsTestMap($testDefinition, $manifestParser, $folder);
             if (count($dependencies['items']) > 0) {
                 foreach ($dependencies['items'] as $assessmentItemRefId => $qtiDependency) {
                     if ($qtiDependency !== false) {
                         if (Resource::isAssessmentItem($qtiDependency->getType())) {
                             $resourceIdentifier = $qtiDependency->getIdentifier();
                             // Check if the item is already stored in the bank.
                             foreach ($metadataGuardians as $guardian) {
                                 if (isset($metadataValues[$resourceIdentifier]) === true) {
                                     if (($guard = $guardian->guard($metadataValues[$resourceIdentifier])) !== false) {
                                         common_Logger::i("Item with identifier '{$resourceIdentifier}' already in Item Bank.");
                                         $msg = __('The IMS QTI Item referenced as "%s" in the IMS Manifest file was already stored in the Item Bank.', $resourceIdentifier);
                                         $report->add(common_report_Report::createInfo($msg, $guard));
                                         $reportCtx->items[$assessmentItemRefId] = $guard;
                                         // Simply do not import again.
                                         continue 2;
                                     }
                                 }
                             }
                             // Determine target class from metadata, if possible.
                             // This is applied to items, not for test definitions.
                             // The test definitions' target class will not be affected
                             // by class lookups.
                             $lookupTargetClass = false;
                             foreach ($metadataClassLookups as $classLookup) {
                                 if (isset($metadataValues[$resourceIdentifier]) === true) {
                                     if (($lookupTargetClass = $classLookup->lookup($metadataValues[$resourceIdentifier])) !== false) {
                                         break;
//.........这里部分代码省略.........
开发者ID:nagyist,项目名称:extension-tao-testqti,代码行数:101,代码来源:class.QtiTestService.php

示例11: importTest

 /**
  * Import a QTI Test and its dependent Items into the TAO Platform.
  *
  * @param core_kernel_classes_Class $targetClass The RDFS Class where Ontology resources must be created.
  * @param oat\taoQtiItem\model\qti\Resource $qtiTestResource The QTI Test Resource representing the IMS QTI Test to be imported.
  * @param taoQtiTest_models_classes_ManifestParser $manifestParser The parser used to retrieve the IMS Manifest.
  * @param string $folder The absolute path to the folder where the IMS archive containing the test content
  * @return common_report_Report A report about how the importation behaved.
  */
 protected function importTest(core_kernel_classes_Class $targetClass, Resource $qtiTestResource, taoQtiTest_models_classes_ManifestParser $manifestParser, $folder)
 {
     $itemImportService = ImportService::singleton();
     $itemService = taoItems_models_classes_ItemsService::singleton();
     $testClass = $targetClass;
     // Create an RDFS resource in the knowledge base that will hold
     // the information about the imported QTI Test.
     $testResource = $this->createInstance($testClass);
     $qtiTestModelResource = new core_kernel_classes_Resource(INSTANCE_TEST_MODEL_QTI);
     $modelProperty = new core_kernel_classes_Property(PROPERTY_TEST_TESTMODEL);
     $testResource->editPropertyValues($modelProperty, $qtiTestModelResource);
     // Create the report that will hold information about the import
     // of $qtiTestResource in TAO.
     $report = new common_report_Report(common_report_Report::TYPE_INFO);
     // The class where the items that belong to the test will be imported.
     $itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS);
     $targetClass = $itemClass->createSubClass($testResource->getLabel());
     // Load and validate the manifest
     $qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($folder . 'imsmanifest.xml');
     $qtiManifestParser->validate();
     // Set up $report with useful information for client code (especially for rollback).
     $reportCtx = new stdClass();
     $reportCtx->manifestResource = $qtiTestResource;
     $reportCtx->rdfsResource = $testResource;
     $reportCtx->itemClass = $targetClass;
     $reportCtx->items = array();
     $report->setData($reportCtx);
     // Expected test.xml file location.
     $expectedTestFile = $folder . str_replace('/', DIRECTORY_SEPARATOR, $qtiTestResource->getFile());
     // Already imported test items (qti xml file paths).
     $alreadyImportedTestItemFiles = array();
     // -- Check if the file referenced by the test QTI resource exists.
     if (is_readable($expectedTestFile) === false) {
         $report->add(common_report_Report::createFailure(__('No file found at location "%s".', $qtiTestResource->getFile())));
     } else {
         // -- Load the test in a QTISM flavour.
         $testDefinition = new XmlDocument();
         try {
             $testDefinition->load($expectedTestFile, true);
             // -- Load all items related to test.
             $itemError = false;
             // discover test's base path.
             $dependencies = taoQtiTest_helpers_Utils::buildAssessmentItemRefsTestMap($testDefinition, $manifestParser, $folder);
             if (count($dependencies) > 0) {
                 foreach ($dependencies as $assessmentItemRefId => $qtiDependency) {
                     if ($qtiDependency !== false) {
                         if (Resource::isAssessmentItem($qtiDependency->getType())) {
                             $qtiFile = $folder . str_replace('/', DIRECTORY_SEPARATOR, $qtiDependency->getFile());
                             // Skip if $qtiFile already imported (multiple assessmentItemRef "hrefing" the same file).
                             if (array_key_exists($qtiFile, $alreadyImportedTestItemFiles) === false) {
                                 $itemReport = $itemImportService->importQTIFile($qtiFile, $targetClass);
                                 $rdfItem = $itemReport->getData();
                                 if ($rdfItem) {
                                     $itemPath = taoItems_models_classes_ItemsService::singleton()->getItemFolder($rdfItem);
                                     foreach ($qtiDependency->getAuxiliaryFiles() as $auxResource) {
                                         // $auxResource is a relativ URL, so we need to replace the slashes with directory separators
                                         $auxPath = $folder . str_replace('/', DIRECTORY_SEPARATOR, $auxResource);
                                         // does the file referenced by $auxPath exist?
                                         if (is_readable($auxPath) === true) {
                                             $relPath = helpers_File::getRelPath($qtiFile, $auxPath);
                                             $destPath = $itemPath . $relPath;
                                             tao_helpers_File::copy($auxPath, $destPath, true);
                                         } else {
                                             $msg = __('Auxiliary file not found at location "%s".', $auxResource);
                                             $itemReport->add(new common_report_Report(common_report_Report::TYPE_WARNING, $msg));
                                         }
                                     }
                                     $reportCtx->items[$assessmentItemRefId] = $rdfItem;
                                     $alreadyImportedTestItemFiles[$qtiFile] = $rdfItem;
                                     $itemReport->setMessage(__('IMS QTI Item referenced as "%s" in the IMS Manifest file successfully imported.', $qtiDependency->getIdentifier()));
                                 } else {
                                     $itemReport->setType(common_report_Report::TYPE_ERROR);
                                     $itemReport->setMessage(__('IMS QTI Item referenced as "%s" in the IMS Manifest file could not be imported.', $qtiDependency->getIdentifier()));
                                     $itemError = $itemError === false ? true : $itemError;
                                 }
                                 $report->add($itemReport);
                             } else {
                                 $reportCtx->items[$assessmentItemRefId] = $alreadyImportedTestItemFiles[$qtiFile];
                             }
                         }
                     } else {
                         $msg = __('The dependency to the IMS QTI AssessmentItemRef "%s" in the IMS Manifest file could not be resolved.', $assessmentItemRefId);
                         $report->add(common_report_Report::createFailure($msg));
                         $itemError = $itemError === false ? true : $itemError;
                     }
                 }
                 // If items did not produce errors, we import the test definition.
                 if ($itemError === false) {
                     common_Logger::i('Importing test...');
                     // Second step is to take care of the test definition and the related media (auxiliary files).
                     // 1. Import test definition (i.e. the QTI-XML Test file).
//.........这里部分代码省略.........
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:101,代码来源:class.QtiTestService.php

示例12: testCreateUnits

 public function testCreateUnits()
 {
     set_time_limit(300);
     $this->itemClass = null;
     $this->units = array();
     $this->properties = array();
     $this->files = array();
     $classUri = LOCAL_NAMESPACE . '#TranslationItemsClass';
     $translationClass = new core_kernel_classes_Class($classUri);
     if (!$translationClass->exists()) {
         $itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS);
         $translationClass = $itemClass->createSubClass('Translation Items', 'created for translation process execution test case', $classUri);
         $this->assertIsA($translationClass, 'core_kernel_classes_Class');
     }
     $this->itemClass = $translationClass;
     foreach ($this->unitNames as $unitName) {
         //create unit:
         $this->units[$unitName] = $translationClass->createInstance($unitName, 'created for translation process execution test case');
         $this->assertNotNull($this->units[$unitName]);
     }
     //		var_dump($this->units, $this->properties, $this->files);
 }
开发者ID:nagyist,项目名称:extension-tao-wfengine,代码行数:22,代码来源:TranslationProcessExecutionTestCase.php

示例13: testSetType

 public function testSetType()
 {
     $this->hardify();
     $this->setProperties();
     $this->targetSongClass = $this->targetWorkClass->createSubClass('Song', 'The Song Class');
     $instance = $this->targetWorkClass->createInstance('setType test instance');
     $sanityCheckInstance = $this->targetWorkClass->createInstance('sanityCheck setType test');
     // verify everything is sane to begin with
     $this->assertIsA($instance, 'core_kernel_classes_resource');
     $this->assertTrue($instance->exists());
     $this->assertIsA($sanityCheckInstance, 'core_kernel_classes_resource');
     $this->assertTrue($sanityCheckInstance->exists());
     $instfound = 0;
     $sanityfound = 0;
     foreach ($this->targetWorkClass->getInstances() as $workInst) {
         if ($workInst->equals($instance)) {
             $instfound++;
         }
         if ($workInst->equals($sanityCheckInstance)) {
             $sanityfound++;
         }
     }
     $this->assertEquals($instfound, 1);
     $this->assertEquals($sanityfound, 1);
     foreach ($this->targetSongClass->getInstances() as $songInst) {
         $this->assertFalse($songInst->equals($instance), 'instance in getInstances of targetSongclass');
         $this->assertFalse($songInst->equals($sanityCheckInstance), 'sanity check instance in getInstances of targetSongclass');
     }
     $types = $instance->getTypes();
     $this->assertEquals(count($types), 1);
     $this->assertTrue($this->targetWorkClass->equals(current($types)));
     // remove the old type (targetWorkClass)
     $this->assertTrue($instance->removeType($this->targetWorkClass));
     $types = $instance->getTypes();
     $this->assertEquals(count($types), 0);
     $sanityfound = 0;
     foreach ($this->targetWorkClass->getInstances() as $workInst) {
         if ($workInst->equals($sanityCheckInstance)) {
             $sanityfound++;
         }
         $this->assertFalse($workInst->equals($instance), 'instance still in getInstances() of class after removeType()');
     }
     $this->assertEquals($sanityfound, 1);
     foreach ($this->targetSongClass->getInstances() as $songInst) {
         $this->assertFalse($songInst->equals($instance), 'instance in getInstances of targetSongclass');
         $this->assertFalse($songInst->equals($sanityCheckInstance), 'sanity check instance in getInstances of targetSongclass');
     }
     // set the new type (targetSongClass)
     $this->assertTrue($instance->setType($this->targetSongClass));
     $types = $instance->getTypes();
     $this->assertEquals(count($types), 1);
     $this->assertTrue($this->targetSongClass->equals(current($types)));
     $sanityfound = 0;
     foreach ($this->targetWorkClass->getInstances() as $workInst) {
         if ($workInst->equals($sanityCheckInstance)) {
             $sanityfound++;
         }
         $this->assertFalse($workInst->equals($instance), 'instance still in getInstances() of class after removeType()');
     }
     $this->assertEquals($sanityfound, 1);
     $instfound = 0;
     foreach ($this->targetSongClass->getInstances() as $songInst) {
         if ($songInst->equals($instance)) {
             $instfound++;
         }
         $this->assertFalse($songInst->equals($sanityCheckInstance), 'sanity check instance in getInstances of targetSongclass');
     }
     $this->assertEquals($instfound, 1);
     // cleanup and check cleanup
     $this->assertTrue($instance->delete());
     $this->assertFalse($instance->exists());
     $this->assertTrue($sanityCheckInstance->delete());
     $this->assertFalse($sanityCheckInstance->exists());
     foreach ($this->targetWorkClass->getInstances() as $workInst) {
         $this->assertFalse($workInst->equals($instance), 'instance still in getInstances() of class targetWorkClass after delete()');
         $this->assertFalse($workInst->equals($sanityCheckInstance), 'instance still in getInstances() of class targetWorkClass after delete()');
     }
     foreach ($this->targetSongClass->getInstances() as $songInst) {
         $this->assertFalse($songInst->equals($instance), 'instance still in getInstances() of class targetSongClass after delete()');
         $this->assertFalse($songInst->equals($sanityCheckInstance), 'instance still in getInstances() of class targetSongClass after delete()');
     }
 }
开发者ID:nagyist,项目名称:extension-generis-hard,代码行数:82,代码来源:HardImplTest.php

示例14: testDeleteInstances

 public function testDeleteInstances()
 {
     $taoClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $creativeWorkClass = $taoClass->createSubClass('Creative Work');
     $authorProperty = $taoClass->createProperty('Author');
     $relatedWorksProperty = $creativeWorkClass->createProperty('Related Works');
     $bookLotr = $creativeWorkClass->createInstance('The Lord of The Rings (book)');
     $bookLotr->setPropertyValue($authorProperty, 'J.R.R. Tolkien');
     $movieLotr = $creativeWorkClass->createInstance('The Lord of The Rings (movie)');
     $movieLotr->setPropertyValue($authorProperty, 'Peter Jackson');
     $movieLotr->setPropertyValue($relatedWorksProperty, $bookLotr);
     $bookLotr->setPropertyValue($relatedWorksProperty, $movieLotr);
     $movieMinorityReport = $creativeWorkClass->createInstance('Minority Report');
     $movieMinorityReport->setPropertyValue($authorProperty, 'Steven Spielberg');
     $this->assertEquals(count($creativeWorkClass->getInstances()), 3);
     // delete the LOTR movie with its references.
     $relatedWorks = $bookLotr->getPropertyValuesCollection($relatedWorksProperty);
     $this->assertEquals($relatedWorks->sequence[0]->getLabel(), 'The Lord of The Rings (movie)');
     $creativeWorkClass->deleteInstances(array($movieLotr), true);
     $relatedWorks = $bookLotr->getPropertyValues($relatedWorksProperty);
     $this->assertEquals(count($relatedWorks), 0);
     // Only 1 resource deleted ?
     $this->assertFalse($movieLotr->exists());
     $this->assertTrue($bookLotr->exists());
     $this->assertTrue($movieMinorityReport->exists());
     // Remove the rest.
     $creativeWorkClass->deleteInstances(array($bookLotr, $movieMinorityReport));
     $this->assertEquals(count($creativeWorkClass->getInstances()), 0);
     $this->assertFalse($bookLotr->exists());
     $this->assertFalse($movieMinorityReport->exists());
     $this->assertTrue($authorProperty->delete());
     $this->assertTrue($relatedWorksProperty->delete());
     $creativeWorkClass->delete(true);
 }
开发者ID:oat-sa,项目名称:generis,代码行数:34,代码来源:ClassTest.php

示例15: testSearchInstancesMultipleImpl

 public function testSearchInstancesMultipleImpl()
 {
     $clazz = new core_kernel_classes_Class(RDFS_CLASS);
     $sub1Clazz = $clazz->createSubClass();
     $sub1ClazzInstance = $sub1Clazz->createInstance('test case instance');
     $sub2Clazz = $sub1Clazz->createSubClass();
     $sub2ClazzInstance = $sub2Clazz->createInstance('test case instance');
     $sub3Clazz = $sub2Clazz->createSubClass();
     $sub3ClazzInstance = $sub3Clazz->createInstance('test case instance');
     $options = array('recursive' => true, 'append' => true, 'createForeigns' => true, 'referencesAllTypes' => true, 'rmSources' => true);
     //Test the search instances on the smooth impl
     $propertyFilter = array(RDFS_LABEL => 'test case instance');
     $instances = $clazz->searchInstances($propertyFilter, array('recursive' => true));
     $this->assertTrue(array_key_exists($sub1ClazzInstance->getUri(), $instances));
     $this->assertTrue(array_key_exists($sub2ClazzInstance->getUri(), $instances));
     $this->assertTrue(array_key_exists($sub3ClazzInstance->getUri(), $instances));
     common_Logger::d('starting hardify');
     //Test the search instances on the hard impl
     $switcher = new Switcher();
     $switcher->hardify($sub1Clazz, $options);
     unset($switcher);
     //Required to update cache data
     common_Logger::d('done hardify');
     $propertyFilter = array(RDFS_LABEL => 'test case instance');
     $instances = $sub1Clazz->searchInstances($propertyFilter, array('recursive' => true));
     $this->assertTrue(array_key_exists($sub1ClazzInstance->getUri(), $instances));
     $this->assertTrue(array_key_exists($sub2ClazzInstance->getUri(), $instances));
     $this->assertTrue(array_key_exists($sub3ClazzInstance->getUri(), $instances));
     $switcher = new Switcher();
     $switcher->unhardify($sub1Clazz, $options);
     unset($switcher);
     //Required to update cache data
     //Test the search instances on a shared model (smooth + hard)
     //Disable recursivity on hardify, and hardify the sub2Clazz
     $switcher = new Switcher();
     $options['recursive'] = false;
     $switcher->hardify($sub2Clazz, $options);
     unset($switcher);
     //Required to update cache data
     $instances = $sub1Clazz->searchInstances($propertyFilter, array('recursive' => true));
     $this->assertTrue(array_key_exists($sub1ClazzInstance->getUri(), $instances));
     $this->assertTrue(array_key_exists($sub2ClazzInstance->getUri(), $instances));
     $this->assertTrue(array_key_exists($sub3ClazzInstance->getUri(), $instances));
     try {
         $instances = $sub1Clazz->searchInstances($propertyFilter, array('recursive' => true, 'offset' => 1));
         $this->assertTrue(false);
     } catch (common_Exception $e) {
         $this->assertTrue(true);
     }
     $switcher = new Switcher();
     $switcher->unhardify($sub2Clazz, $options);
     unset($switcher);
     //Required to update cache data
     //clean data test
     foreach ($sub1Clazz->getInstances(true) as $instance) {
         $instance->delete();
     }
     $sub1Clazz->delete(true);
     $sub2Clazz->delete(true);
     $sub3Clazz->delete(true);
 }
开发者ID:nagyist,项目名称:extension-generis-hard,代码行数:61,代码来源:HardClassTest.php


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