コード例 #1
0
 /**
  * Test relations between AccountUserRole and Websites
  */
 public function testWebsiteRelations()
 {
     $accountUserRole = new AccountUserRole();
     $website = new Website();
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $accountUserRole->getWebsites());
     $this->assertCount(0, $accountUserRole->getWebsites());
     $this->assertInstanceOf('OroB2B\\Bundle\\CustomerBundle\\Entity\\AccountUserRole', $accountUserRole->addWebsite($website));
     $this->assertCount(1, $accountUserRole->getWebsites());
     $accountUserRole->addWebsite($website);
     $this->assertCount(1, $accountUserRole->getWebsites());
     $accountUserRole->removeWebsite($website);
     $this->assertCount(0, $accountUserRole->getWebsites());
 }
コード例 #2
0
 /**
  * @param ObjectManager $manager
  * @param string $roleLabel
  * @param string $websiteName
  */
 protected function loadRoleWithWebsite(ObjectManager $manager, $roleLabel, $websiteName)
 {
     $entity = new AccountUserRole();
     $entity->setLabel($roleLabel);
     /** @var Website $website */
     $website = $this->getReference($websiteName);
     $entity->addWebsite($website);
     $this->setReference($entity->getLabel(), $entity);
     $manager->persist($entity);
 }
コード例 #3
0
 /**
  * @param ObjectManager $manager
  * @param AccountUserRole $role
  */
 protected function setWebsiteDefaultRoles(ObjectManager $manager, AccountUserRole $role)
 {
     $websites = $manager->getRepository('OroB2BWebsiteBundle:Website')->findAll();
     foreach ($websites as $website) {
         $role->addWebsite($website);
     }
 }