/** * Assert that the group of the currently logged in customer only has some accesses to some resources * (ACLs), and not any other. * @param array $expectedRessourceAccesses A map of [expected resource => [expected accesses...], ...]. */ protected function assertGroupOnlyHasTheseAccesses(array $expectedRessourceAccesses) { $unexpectedRessourceAccesses = []; foreach (self::$TEST_ACL_CODES as $aclCode) { foreach (CustomerGroupAclAccessManager::getAccessPows() as $accessCode => $accessCodeValue) { if (!isset($expectedRessourceAccesses[$aclCode]) || !in_array($accessCode, $expectedRessourceAccesses[$aclCode])) { $unexpectedRessourceAccesses[$aclCode][] = $accessCode; } } } $this->assertGroupAccesses($expectedRessourceAccesses, true); $this->assertGroupAccesses($unexpectedRessourceAccesses, false); }
public function testCreateCustomerGroupAcl() { /** @var Acl $testAcl */ $testAcl = $this->testAcls[0]; /** @var CustomerGroup $testGroup */ $testGroup = self::$testCustomerGroups[2]; $testAccessType = array_rand(CustomerGroupAclAccessManager::getAccessPows(), 1); $createEvent = new CustomerGroupAclEvent($testAcl->getId(), $testGroup->getId(), $testAccessType); $this->dispatcher->dispatch(CustomerGroupAclEvents::CUSTOMER_GROUP_ACL_UPDATE, $createEvent); $groupAcl = CustomerGroupAclQuery::create()->filterByAcl($testAcl)->filterByCustomerGroup($testGroup)->filterByType($testAccessType)->findOne(); $this->assertNotNull($groupAcl); $this->assertEquals(1, $groupAcl->getActivate()); }
/** * Get pows (but I don't know what is call pows) * * @param array $params Parameters * @param \Smarty_Internal_Template $template Smarty template * * @return array */ public function getAccessPows($params, $template = null) { $template->assign($params['load_access_pows'], CustomerGroupAclAccessManager::getAccessPows()); }
public function __construct(Translator $translator) { $this->translator = $translator; $this->accessPows = CustomerGroupAclAccessManager::getAccessPows(); }