/** * @param ProfileModel $profile * @depends testUpdate */ public function testUpdateResourceAccess(ProfileModel $profile) { $event = new ProfileEvent(); $event->setId($profile->getId())->setResourceAccess(array('admin.address' => array(AccessManager::CREATE))); $action = new Profile($this->getMockEventDispatcher()); $action->updateResourceAccess($event); $updatedProfile = $event->getProfile(); $this->assertInstanceOf('Thelia\\Model\\Profile', $updatedProfile); $resources = $updatedProfile->getResources(); $this->assertEquals(1, count($resources)); $resource = $resources->getFirst(); $this->assertEquals('admin.address', $resource->getCode()); $profileResource = $updatedProfile->getProfileResources()->getFirst(); $accessManager = new AccessManager($profileResource->getAccess()); $this->assertTrue($accessManager->can(AccessManager::CREATE)); }
protected function getUpdateModuleAccessEvent($formData) { $event = new ProfileEvent(); $event->setId($formData['id']); $event->setModuleAccess($this->getModuleAccess($formData)); return $event; }
/** * @param ProfileEvent $event */ public function delete(ProfileEvent $event) { if (null !== ($profile = ProfileQuery::create()->findPk($event->getId()))) { $profile->delete(); $event->setProfile($profile); } }