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


PHP core_kernel_classes_Resource::exists方法代码示例

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


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

示例1: testImport

 public function testImport()
 {
     $endpoint = ROOT_URL . 'taoQtiTest/RestQtiTests/import';
     $file = __DIR__ . '/samples/archives/QTI 2.1/basic/Basic.zip';
     $this->assertFileExists($file);
     $post_data = array('qtiPackage' => new \CURLFile($file));
     $options = array(CURLOPT_POSTFIELDS => $post_data);
     $content = $this->curl($endpoint, CURLOPT_POST, "data", $options);
     $data = json_decode($content, true);
     $this->assertTrue(is_array($data), 'Should return json encoded array');
     $this->assertTrue($data['success']);
     $this->assertTrue(isset($data['data']));
     $this->assertTrue(is_array($data['data']));
     $this->assertCount(1, $data['data']);
     $testData = reset($data['data']);
     $this->assertTrue(isset($testData['testId']));
     $uri = $testData['testId'];
     $test = new \core_kernel_classes_Resource($uri);
     $this->assertTrue($test->exists());
     $deletionCall = ROOT_URL . 'taoTests/RestTests?uri=' . urlencode($uri);
     $content = $this->curl($deletionCall, 'DELETE', "data");
     $data = json_decode($content, true);
     $this->assertTrue(is_array($data), 'Should return json encoded array');
     $this->assertTrue($data['success']);
     $this->assertFalse($test->exists());
     // should return an error, instance no longer exists
     $content = $this->curl($deletionCall, 'DELETE', "data");
     $data = json_decode($content, true);
     $this->assertTrue(is_array($data), 'Should return json encoded array');
     $this->assertFalse($data['success']);
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:31,代码来源:RestTestImportTest.php

示例2: testAddUtf8User

 /**
  * Test user insertion with special chars
  */
 public function testAddUtf8User()
 {
     $this->assertTrue($this->userService->loginAvailable($this->testUserUtf8Data[PROPERTY_USER_LOGIN]));
     $tmclass = new core_kernel_classes_Class(CLASS_TAO_USER);
     $this->testUserUtf8 = $tmclass->createInstance();
     $this->assertNotNull($this->testUserUtf8);
     $this->assertTrue($this->testUserUtf8->exists());
     $result = $this->userService->bindProperties($this->testUserUtf8, $this->testUserUtf8Data);
     $this->assertNotNull($result);
     $this->assertNotEquals($result, false);
     $this->assertFalse($this->userService->loginAvailable($this->testUserUtf8Data[PROPERTY_USER_LOGIN]));
     //check inserted data
     $this->testUserUtf8 = $this->getUserByLogin($this->testUserUtf8Data[PROPERTY_USER_LOGIN]);
     $this->assertInstanceOf('core_kernel_classes_Resource', $this->testUserUtf8);
     foreach ($this->testUserUtf8Data as $prop => $value) {
         try {
             $p = new core_kernel_classes_Property($prop);
             $v = $this->testUserUtf8->getUniquePropertyValue($p);
             $v = $v instanceof core_kernel_classes_Literal ? $v->literal : $v->getUri();
             $this->assertEquals($value, $v);
         } catch (common_Exception $ce) {
             $this->fail($ce);
         }
     }
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:28,代码来源:UserTest.php

示例3: installManagementRole

 /**
  * Will make the Global Manager include the Management Role of the extension
  * to install (if it exists).
  *
  * @access public
  * @author Jerome Bogaerts <jerome@taotesting.com>
  * @return void
  * @since 2.4
  */
 public function installManagementRole()
 {
     // Try to get a Management Role described by the extension itself.
     // (this information comes actually from the Manifest of the extension)
     $roleUri = $this->extension->getManifest()->getManagementRoleUri();
     if (!empty($roleUri)) {
         $role = new core_kernel_classes_Resource($roleUri);
         $roleService = tao_models_classes_RoleService::singleton();
         if (!$role->exists()) {
             // Management role does not exist yet, so we create it
             $roleClass = new core_kernel_classes_Class(CLASS_MANAGEMENTROLE);
             $roleLabel = $this->extension->getId() . ' Manager';
             $role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri());
             $roleService->includeRole($role, new core_kernel_classes_Resource(INSTANCE_ROLE_BACKOFFICE));
         }
         // Take the Global Manager role and make it include
         // the Management role of the currently installed extension.
         if ($role->getUri() !== INSTANCE_ROLE_GLOBALMANAGER) {
             $globalManagerRole = new core_kernel_classes_Resource(INSTANCE_ROLE_GLOBALMANAGER);
             $roleService->includeRole($globalManagerRole, $role);
         }
         common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'.");
     } else {
         // There is no Management role described by the Extension Manifest.
         common_Logger::i("No management role for extension '" . $this->extension->getId() . "'.");
     }
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:36,代码来源:class.ExtensionInstaller.php

示例4: testLanguagesExistence

 /**
  * Test the existence of language definition resources in the knowledge base
  * regarding what we found in the tao/locales directory.
  * 
  * @author Jerome Bogaerts, <taosupport@tudor.lu>
  */
 public function testLanguagesExistence()
 {
     // Check for lang.rdf in /tao locales and query the KB to see if it exists or not.
     $languageClass = new core_kernel_classes_Class(CLASS_LANGUAGES);
     $taoLocalesDir = ROOT_PATH . '/tao/locales';
     $expectedUriPrefix = 'http://www.tao.lu/Ontologies/TAO.rdf#Lang';
     if (false !== ($locales = scandir($taoLocalesDir))) {
         foreach ($locales as $l) {
             $localePath = $taoLocalesDir . '/' . $l;
             if ($l[0] !== '.' && is_dir($localePath) && is_readable($localePath)) {
                 $langPath = $localePath . '/lang.rdf';
                 if (file_exists($langPath)) {
                     $lgResource = new core_kernel_classes_Resource($expectedUriPrefix . $l);
                     $this->assertTrue($lgResource->exists(), '$lgResource Resource does not exist (' . $expectedUriPrefix . $l . ').');
                     // Check for this language in Ontology.
                     $kbLangs = $lgResource->getPropertyValues(new core_kernel_classes_Property(RDF_VALUE));
                     if (is_array($kbLangs)) {
                         $this->assertEquals(count($kbLangs), 1, "Number of languages retrieved for language '{$l}' is '" . count($kbLangs) . "'.");
                         // Check if the language has the correct URI.
                         if ($kbLangs[0] instanceof core_kernel_classes_Resource) {
                             $this->assertTrue($kbLangs[0]->getUri() == $expectedUriPrefix . $l, "Malformed URI scheme for language resource '{$l}'.");
                         }
                     } else {
                         $this->fail('the $kbLangs variable should be an array. "' . gettype($kbLangs) . '" found instead.');
                     }
                 }
             }
         }
     }
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:36,代码来源:LanguagesTest.php

示例5: resolve

 /**
  * Resolve the given TAO Item URI in the path to
  * the related QTI-XML file.
  * 
  * @param string $url The URI of the TAO Item to resolve.
  * @return string The path to the related QTI-XML file.
  * @throws ResolutionException If an error occurs during the resolution of $url.
  */
 public function resolve($url)
 {
     $taoItem = new core_kernel_classes_Resource($url);
     if ($taoItem->exists() === false) {
         $msg = "The QTI Item with URI '{$url}' cannot be found.";
         throw new ResolutionException($msg);
     }
     // The item is retrieved from the database.
     // We can try to reach the QTI-XML file by detecting
     // where it is supposed to be located.
     return QtiFile::getQtiFilePath(new core_kernel_classes_Resource($url));
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:20,代码来源:class.ItemResolver.php

示例6: __invoke

 /**
  *
  * @param unknown $params
  */
 public function __invoke($params)
 {
     if (count($params) != 2) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s DELIVERY_URI OUTPUT_FILE', __CLASS__));
     }
     $deliveryUri = array_shift($params);
     $delivery = new \core_kernel_classes_Resource($deliveryUri);
     if (!$delivery->exists()) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Delivery \'%s\' not found', $deliveryUri));
     }
     $file = array_shift($params);
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf');
     $tmpFile = Assembler::exportCompiledDelivery($delivery);
     \tao_helpers_File::move($tmpFile, $file);
     return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exported %1$s to %2$s', $delivery->getLabel(), $file));
 }
开发者ID:oat-sa,项目名称:extension-tao-delivery-rdf,代码行数:20,代码来源:ExportAssembly.php

示例7: resolve

 /**
  * Resolve the given TAO Item URI in the path to
  * the related QTI-XML file.
  * 
  * @param string $url The URI of the TAO Item to resolve.
  * @return string The path to the related QTI-XML file.
  * @throws ResolutionException If an error occurs during the resolution of $url.
  */
 public function resolve($url)
 {
     $taoItem = new core_kernel_classes_Resource($url);
     if ($taoItem->exists() === false) {
         $msg = "The QTI Item with URI '{$url}' cannot be found.";
         throw new ResolutionException($msg);
     }
     // The item is retrieved from the database.
     // We can try to reach the QTI-XML file by detecting
     // where it is supposed to be located.
     // strip xinclude, we don't need that at the moment.
     $raw = $this->service->getXmlByRdfItem($this->getResource($url));
     $tmpfile = sys_get_temp_dir() . '/' . md5($url) . '.xml';
     $raw = preg_replace("/<xi:include(?:.*)>/u", '', $raw);
     file_put_contents($tmpfile, $raw);
     return $tmpfile;
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:25,代码来源:class.ItemResolver.php

示例8: __invoke

 public function __invoke($params)
 {
     // load constants...
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->load();
     if (empty($params[0]) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Test URI not provided as parameter 1.');
     }
     if (empty($params[1]) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'AssessmentItemRefIdentifier not provided as parameter 2.');
     }
     $testResource = new \core_kernel_classes_Resource($params[0]);
     if ($testResource->exists() === false) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No RDFS Resource found for URI ' . $params[0] . '.');
     }
     $qtiService = \taoQtiTest_models_classes_QtiTestService::singleton();
     $testDoc = $qtiService->getDoc($testResource);
     $test = $testDoc->getDocumentComponent();
     $assessmentItemRef = $test->getComponentByIdentifier($params[1]);
     if (!$assessmentItemRef) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI assessmentItemRef with identifier ' . $params[1] . ' found in the QTI Test definition.');
     }
     $input = file_get_contents('php://stdin');
     if (empty($input) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI-XML input provided in stdin.');
     } else {
         $dom = new \DOMDocument('1.0', 'UTF-8');
         if (@$dom->loadXML($input)) {
             $element = $dom->documentElement;
             $marshallerFactory = new MarshallerFactory();
             $marshaller = $marshallerFactory->createMarshaller($element);
             $component = $marshaller->unmarshall($element);
             if (!$component instanceof BranchRule) {
                 return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI branchRule component found in stdin.');
             }
             $assessmentItemRef->setBranchRules(new BranchRuleCollection(array($component)));
             $qtiService->getQtiTestFile($testResource)->update($testDoc->saveToString());
         } else {
             return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Invalid QTI-XML input provided in stdin.');
         }
     }
     return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, "BranchRule found in stdin successfully appended to assessmentItemRef '" . $params[1] . "' part of QTI Test with URI '" . $params[0] . "'.");
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:42,代码来源:InjectBranchRule.php

示例9: generate

 /**
  * Generate a delivery from test uri
  * Test uri has to be set and existing
  */
 public function generate()
 {
     try {
         if (!$this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) {
             throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI());
         }
         $test = new \core_kernel_classes_Resource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID));
         if (!$test->exists()) {
             throw new \common_exception_NotFound('Unable to find a test associated to the given uri.');
         }
         $label = 'Delivery of ' . $test->getLabel();
         $deliveryClass = new \core_kernel_classes_Class(CLASS_COMPILEDDELIVERY);
         /** @var \common_report_Report $report */
         $report = SimpleDeliveryFactory::create($deliveryClass, $test, $label);
         if ($report->getType() == \common_report_Report::TYPE_ERROR) {
             \common_Logger::i('Unable to generate delivery execution ' . 'into taoDeliveryRdf::RestDelivery for test uri ' . $test->getUri());
             throw new \common_Exception('Unable to generate delivery execution.');
         }
         $delivery = $report->getData();
         $this->returnSuccess(array('delivery' => $delivery->getUri()));
     } catch (\Exception $e) {
         $this->returnFailure($e);
     }
 }
开发者ID:oat-sa,项目名称:extension-tao-delivery-rdf,代码行数:28,代码来源:RestDelivery.php

示例10: attachResource

 /**
  * Short description of method attachResource
  *
  * @access public
  * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
  * @param  core_kernel_classes_Property $targetProperty
  * @param  core_kernel_classes_Resource $targetResource
  * @param  string $value
  * @return mixed
  */
 public function attachResource(core_kernel_classes_Property $targetProperty, core_kernel_classes_Resource $targetResource, $value)
 {
     // We have to check if the resource identified by value exists in the Ontology.
     $resource = new core_kernel_classes_Resource($value);
     if ($resource->exists()) {
         // Is the range correct ?
         $targetPropertyRanges = $targetProperty->getPropertyValuesCollection(new core_kernel_classes_Property(RDFS_RANGE));
         $rangeCompliance = true;
         // If $targetPropertyRange->count = 0, we consider that the resouce
         // may be attached because $rangeCompliance = true.
         foreach ($targetPropertyRanges->getIterator() as $range) {
             // Check all classes in target property's range.
             if ($resource->hasType(new core_kernel_classes_Class($range))) {
                 $rangeCompliance = false;
                 break;
             }
         }
         if (true == $rangeCompliance) {
             $targetResource->setPropertyValue($targetProperty, $resource->getUri());
         }
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:32,代码来源:class.GenerisAdapterCsv.php

示例11: testDeleteTest

 /**
  * test deleteTest
  * @depends testInstanceCreate
  * @param \core_kernel_classes_Resource $testInstance
  * @return void
  */
 public function testDeleteTest($testInstance)
 {
     $this->assertTrue($testInstance->exists());
     $this->wftService->deleteTest($testInstance);
     $this->assertFalse($testInstance->exists());
 }
开发者ID:nagyist,项目名称:extension-tao-testwf,代码行数:12,代码来源:ServiceTest.php

示例12: die

    die(1);
}
require_once $rawStart;
if (!file_exists($csvfile)) {
    echo 'Csv file not found at "' . $csvfile . '"' . PHP_EOL;
    die(1);
}
if (is_null($groupUri)) {
    $label = 'Group ' . uniqid();
    $groupClass = new \core_kernel_classes_Class(TAO_GROUP_CLASS);
    $group = $groupClass->createInstanceWithProperties(array(RDFS_LABEL => $label));
    echo 'Group "' . $label . '" created.' . PHP_EOL;
    $groupUri = $group->getUri();
} else {
    $group = new core_kernel_classes_Resource($groupUri);
    if (!$group->exists()) {
        echo 'Group "' . $groupUri . '" not found.' . PHP_EOL;
        die(1);
    }
}
$persistence = \common_persistence_Manager::getPersistence('default');
try {
    $schemaManager = $persistence->getDriver()->getSchemaManager();
    $schema = $schemaManager->createSchema();
    if (!$schema->hastable('redis')) {
        $fromSchema = clone $schema;
        $tableResults = $schema->createtable('redis');
        $tableResults->addOption('engine', 'MyISAM');
        $tableResults->addColumn('subject', 'string', ['length' => 255]);
        $tableResults->addColumn('predicate', 'string', ['length' => 255]);
        $tableResults->addColumn('object', 'string', ['length' => 255]);
开发者ID:oat-sa,项目名称:generis-auth-keyvalue,代码行数:31,代码来源:importCsvTestTaker.php

示例13: testGenerate

 /**
  * Test correct response
  */
 public function testGenerate()
 {
     $testUri = $this->initDeliveryGeneration();
     $data = $this->curlDeliveryGenerate($testUri);
     $this->assertTrue(is_array($data));
     $this->assertTrue(isset($data['success']));
     $this->assertTrue($data['success']);
     $this->assertTrue(isset($data['data']['delivery']));
     $delivery = new \core_kernel_classes_Resource($data['data']['delivery']);
     $this->assertTrue($delivery->exists());
     $this->removeDeliveryTest($delivery, $testUri);
 }
开发者ID:oat-sa,项目名称:extension-tao-delivery-rdf,代码行数:15,代码来源:RestDeliveryTest.php

示例14: performTransition

 /**
  * Short description of method performTransition
  *
  * @access public
  * @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
  * @param  Resource processExecution
  * @param  Resource activityExecution
  * @return mixed
  */
 public function performTransition(core_kernel_classes_Resource $processExecution, core_kernel_classes_Resource $activityExecution)
 {
     $returnValue = null;
     $session = PHPSession::singleton();
     $session->setAttribute("activityExecutionUri", $activityExecution->getUri());
     //check if the transition is possible, e.g. process is not finished
     if ($this->isFinished($processExecution)) {
         return false;
     }
     //init the services
     $activityDefinitionService = wfEngine_models_classes_ActivityService::singleton();
     $connectorService = wfEngine_models_classes_ConnectorService::singleton();
     $userService = wfEngine_models_classes_UserService::singleton();
     $notificationService = wfEngine_models_classes_NotificationService::singleton();
     $currentUser = $userService->getCurrentUser();
     //set the activity execution of the current user as finished:
     if ($activityExecution->exists()) {
         $this->activityExecutionService->finish($activityExecution);
     } else {
         throw new Exception("cannot find the activity execution of the current activity {$activityBeforeTransition->getUri()} in perform transition");
     }
     $activityBeforeTransition = $this->activityExecutionService->getExecutionOf($activityExecution);
     $nextConnector = $activityDefinitionService->getUniqueNextConnector($activityBeforeTransition);
     if (wfEngine_models_classes_ActivityCardinalityService::singleton()->isCardinality($nextConnector)) {
         $nextConnector = wfEngine_models_classes_ActivityCardinalityService::singleton()->getDestination($nextConnector);
     }
     $newActivities = array();
     if (!is_null($nextConnector)) {
         $newActivities = $this->getNewActivities($processExecution, $activityExecution, $nextConnector);
     } else {
         //final activity:
         $this->finish($processExecution);
         return array();
     }
     if ($newActivities === false) {
         //means that the process must be paused before transition: transition condition not fullfilled
         $this->pause($processExecution);
         return false;
     }
     // The actual transition starts here:
     $newActivityExecutions = array();
     if (!is_null($nextConnector)) {
         //trigger the forward transition:
         $newActivityExecutions = $this->activityExecutionService->moveForward($activityExecution, $nextConnector, $newActivities, $processExecution);
         //trigger the notifications
         $notificationService->trigger($nextConnector, $activityExecution, $processExecution);
     }
     //transition done from here: now get the following activities:
     //if the connector is not a parallel one, let the user continue in his current branch and prevent the pause:
     $uniqueNextActivityExecution = null;
     if (!is_null($nextConnector)) {
         if ($connectorService->getType($nextConnector)->getUri() != INSTANCE_TYPEOFCONNECTORS_PARALLEL) {
             if (count($newActivityExecutions) == 1) {
                 //TODO: could do a double check here: if($newActivities[0] is one of the activty found in the current tokens):
                 if ($this->activityExecutionService->checkAcl(reset($newActivityExecutions), $currentUser, $processExecution)) {
                     $uniqueNextActivityExecution = reset($newActivityExecutions);
                 }
             }
         }
     }
     $setPause = true;
     $authorizedActivityExecutions = array();
     if (!count($newActivities) || $activityDefinitionService->isFinal($activityBeforeTransition)) {
         //there is no following activity so the process ends here:
         $this->finish($processExecution);
         return array();
     } elseif (!is_null($uniqueNextActivityExecution)) {
         //we are certain that the next activity would be for the user so return it:
         $authorizedActivityExecutions[$uniqueNextActivityExecution->getUri()] = $uniqueNextActivityExecution;
         $setPause = false;
     } else {
         foreach ($newActivityExecutions as $activityExecutionAfterTransition) {
             //check if the current user is allowed to execute the activity
             if ($this->activityExecutionService->checkAcl($activityExecutionAfterTransition, $currentUser, $processExecution)) {
                 $authorizedActivityExecutions[$activityExecutionAfterTransition->getUri()] = $activityExecutionAfterTransition;
                 $setPause = false;
             } else {
                 continue;
             }
         }
     }
     $returnValue = array();
     //finish actions on the authorized acitivty definitions
     foreach ($authorizedActivityExecutions as $uri => $activityExecutionAfterTransition) {
         // Last but not least ... is the next activity a machine activity ?
         // if yes, we perform the transition.
         /*
          * @todo to be tested
          */
         $activityAfterTransition = $this->activityExecutionService->getExecutionOf($activityExecutionAfterTransition);
         if ($activityDefinitionService->isHidden($activityAfterTransition)) {
//.........这里部分代码省略.........
开发者ID:nagyist,项目名称:extension-tao-wfengine,代码行数:101,代码来源:class.ProcessExecutionService.php

示例15: testUserHasRoles

 public function testUserHasRoles()
 {
     $prefix = LOCAL_NAMESPACE . '#';
     $baseRole = new core_kernel_classes_Resource($prefix . 'baseRole');
     $subRole1 = new core_kernel_classes_Resource($prefix . 'subRole1');
     $subRole2 = new core_kernel_classes_Resource($prefix . 'subRole2');
     $subRole3 = new core_kernel_classes_Resource($prefix . 'subRole3');
     $subRole11 = new core_kernel_classes_Resource($prefix . 'subRole11');
     $subRole12 = new core_kernel_classes_Resource($prefix . 'subRole12');
     $subRole13 = new core_kernel_classes_Resource($prefix . 'subRole13');
     $allRolesOf13 = array($baseRole, $subRole1, $subRole11, $subRole12, $subRole13);
     $this->assertTrue($baseRole->exists());
     $this->assertTrue($subRole1->exists());
     $user = $this->service->addUser('user', 'password', $baseRole);
     $this->assertTrue($this->service->userHasRoles($user, $baseRole));
     $this->assertFalse($this->service->userHasRoles($user, array($baseRole, $subRole1)));
     $user->delete();
     $user = $this->service->addUser('user', 'password', $subRole1);
     $this->assertTrue($this->service->userHasRoles($user, $baseRole));
     $this->assertTrue($this->service->userHasRoles($user, $subRole1));
     $this->assertFalse($this->service->userHasRoles($user, $subRole2));
     $this->assertTrue($this->service->userHasRoles($user, array($baseRole, $subRole1)));
     $this->assertFalse($this->service->userHasRoles($user, array($baseRole, $subRole1, $subRole2)));
     $user->delete();
     $user = $this->service->addUser('user', 'password', $subRole13);
     $this->assertTrue($this->service->userHasRoles($user, $subRole13));
     $this->assertTrue($this->service->userHasRoles($user, $baseRole));
     $this->assertTrue($this->service->userHasRoles($user, $allRolesOf13));
     $user->delete();
 }
开发者ID:nagyist,项目名称:generis,代码行数:30,代码来源:UserServiceTest.php


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