/**
  * @covers CustomerGroupAclTool::checkAcl()
  *
  * @param CustomerGroup $customerGroup Group to test.
  * @param Customer $customer Customer to use for the test.
  * @param array $expectedRessourceAccesses A map of [expected resource => [expected accesses...], ...].
  */
 protected function doTestCheckAclCustomerWithGroup(CustomerGroup $customerGroup, Customer $customer, $expectedRessourceAccesses)
 {
     // add the customer to the test group
     $addCustomerToGroupEvent = new AddCustomerToCustomerGroupEvent();
     $addCustomerToGroupEvent->setCustomerId($customer->getId())->setCustomerGroupId($customerGroup->getId());
     $this->dispatcher->dispatch(CustomerGroupEvents::ADD_CUSTOMER_TO_CUSTOMER_GROUP, $addCustomerToGroupEvent);
     // login the customer
     $this->dispatcher->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer));
     // assert its accesses
     $this->assertGroupOnlyHasTheseAccesses($expectedRessourceAccesses);
     // assert it twice to also test the ACL checking cache
     $this->assertGroupOnlyHasTheseAccesses($expectedRessourceAccesses);
 }
 /**
  * Parse one customergroupacl
  *
  * @param SimpleXMLElement $customerGroupAcl A customergroupacl
  * @param CustomerGroup $customerGroupModel CustomerGroup propel object for who the access have to be created
  *
  * @throws \Exception When an error is detected on xml file (customer group or acl don't exist)
  */
 protected function parseCustomerGroupAcl(SimpleXMLElement $customerGroupAcl, CustomerGroup $customerGroupModel)
 {
     $acl = AclQuery::create()->findOneByCode($customerGroupAcl->getAttributeAsPhp('aclcode'));
     if (null === $customerGroupModel) {
         throw new \Exception($this->translator->trans("Error in %a file the customer group '%s' doesn't exist", ['%a' => $this->xmlFilePath, '%s' => $customerGroupModel->getCode()], CustomerGroupAcl::DOMAIN_MESSAGE));
     }
     if (null === $acl) {
         throw new \Exception($this->translator->trans("Error in %a file the acl '%s' doesn't exist", ['%a' => $this->xmlFilePath, '%s' => $customerGroupAcl->getAttributeAsPhp('aclcode')], CustomerGroupAcl::DOMAIN_MESSAGE));
     }
     $this->parseAccesses($customerGroupAcl->children(), $acl, $customerGroupModel);
 }
 /**
  * Filter the query by a related \CustomerGroup\Model\CustomerGroup object
  *
  * @param \CustomerGroup\Model\CustomerGroup|ObjectCollection $customerGroup The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildCustomerGroupAclQuery The current query, for fluid interface
  */
 public function filterByCustomerGroup($customerGroup, $comparison = null)
 {
     if ($customerGroup instanceof \CustomerGroup\Model\CustomerGroup) {
         return $this->addUsingAlias(CustomerGroupAclTableMap::CUSTOMER_GROUP_ID, $customerGroup->getId(), $comparison);
     } elseif ($customerGroup instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CustomerGroupAclTableMap::CUSTOMER_GROUP_ID, $customerGroup->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCustomerGroup() only accepts arguments of type \\CustomerGroup\\Model\\CustomerGroup or Collection');
     }
 }
 /**
  * Declares an association between this object and a ChildCustomerGroup object.
  *
  * @param                  ChildCustomerGroup $v
  * @return                 \CustomerGroupAcl\Model\CustomerGroupAcl The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCustomerGroup(ChildCustomerGroup $v = null)
 {
     if ($v === null) {
         $this->setCustomerGroupId(NULL);
     } else {
         $this->setCustomerGroupId($v->getId());
     }
     $this->aCustomerGroup = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildCustomerGroup object, it will not be re-added.
     if ($v !== null) {
         $v->addCustomerGroupAcl($this);
     }
     return $this;
 }