public function testName()
 {
     $name = 'test';
     $this->assertNull($this->unit->getName());
     $this->unit->setName($name);
     $this->assertEquals($name, $this->unit->getName());
     $this->assertEquals($name, (string) $this->unit);
 }
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $businessUnitName = 'bu1';
     $organizationsCount = 3;
     /** @var Organization[] $organizations */
     $organizations = [];
     for ($i = 1; $i <= $organizationsCount; $i++) {
         $key = 'org' . $i;
         $organizations[$key] = new Organization();
         $organizations[$key]->setName($key)->setEnabled(true);
         $manager->persist($organizations[$key]);
         $this->addReference($key, $organizations[$key]);
     }
     $businessUnit = new BusinessUnit();
     $businessUnit->setName($businessUnitName)->setOrganization($organizations['org1']);
     $manager->persist($businessUnit);
     $this->addReference('bu1', $businessUnit);
     $userManager = $this->container->get('oro_user.manager');
     /** @var User $user */
     $user = $userManager->createUser();
     $user->setUsername('test_user_main')->setPlainPassword('admin')->setEmail('*****@*****.**')->setEnabled(true);
     $userManager->updateUser($user, false);
     $this->setReference($user->getUsername(), $user);
     $manager->flush();
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var Organization $organization */
     $organization = $this->organizationRepository->getFirst();
     $this->addReference('default_organization', $organization);
     /** @var BusinessUnit $oroMain */
     $oroMain = $this->businessUnitRepository->findOneBy(array('name' => 'Main'));
     if (!$oroMain) {
         $oroMain = $this->businessUnitRepository->findOneBy(array('name' => 'Acme, General'));
     }
     if (!$oroMain) {
         throw new \Exception('"Main" business unit is not defined');
     }
     $oroMain->setName('Acme, General');
     $oroMain->setEmail('*****@*****.**');
     $oroMain->setPhone('798-682-5917');
     $this->persistAndFlush($this->organizationManager, $oroMain);
     $this->addReference('default_main_business', $oroMain);
     /** @var BusinessUnit $oroUnit */
     $oroUnit = new BusinessUnit();
     /** @var BusinessUnit $mageCoreUnit */
     $mageCoreUnit = new BusinessUnit();
     $oroUnit->setName('Acme, West')->setWebsite('http://www.orocrm.com')->setOrganization($organization)->setEmail('*****@*****.**')->setPhone('798-682-5918')->setOwner($oroMain);
     $this->persist($this->organizationManager, $oroUnit);
     $this->addReference('default_crm_business', $oroUnit);
     $mageCoreUnit->setName('Acme, East')->setWebsite('http://www.magecore.com/')->setOrganization($organization)->setEmail('*****@*****.**')->setPhone('798-682-5919')->setOwner($oroMain);
     $this->persistAndFlush($this->organizationManager, $mageCoreUnit);
     $this->addReference('default_core_business', $mageCoreUnit);
 }
 public function load(ObjectManager $manager)
 {
     $defaultBusinessUnit = new BusinessUnit();
     $defaultBusinessUnit->setName('Main')->setOrganization($this->getReference('default_organization'));
     $this->addReference('default_business_unit', $defaultBusinessUnit);
     $manager->persist($defaultBusinessUnit);
     $manager->flush();
 }
Esempio n. 5
0
 /**
  * @param string       $key
  * @param BusinessUnit $entity
  */
 public function fillEntityData($key, $entity)
 {
     switch ($key) {
         case 'Main':
             $entity->setName($key);
             return;
     }
     parent::fillEntityData($key, $entity);
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $businessUnit = new BusinessUnit();
     $businessUnit->setOrganization($organization);
     $businessUnit->setName('TestBusinessUnit');
     $manager->persist($businessUnit);
     $this->setReference('TestBusinessUnit', $businessUnit);
     $manager->flush();
 }
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     // load default organization
     $defaultOrganization = new Organization();
     $defaultOrganization->setName(self::MAIN_ORGANIZATION)->setEnabled(true);
     $this->addReference('default_organization', $defaultOrganization);
     $manager->persist($defaultOrganization);
     // load default business unit
     $defaultBusinessUnit = new BusinessUnit();
     $defaultBusinessUnit->setName(self::MAIN_BUSINESS_UNIT)->setOrganization($defaultOrganization);
     $this->addReference('default_business_unit', $defaultBusinessUnit);
     $manager->persist($defaultBusinessUnit);
     $manager->flush();
 }
Esempio n. 8
0
 public function load(ObjectManager $manager)
 {
     $staticType = $manager->getRepository('OroSegmentBundle:SegmentType')->find(SegmentType::TYPE_STATIC);
     if (!$staticType) {
         $staticType = new SegmentType(SegmentType::TYPE_STATIC);
         $staticType->setLabel('Static');
         $manager->persist($staticType);
     }
     $dynamicType = $manager->getRepository('OroSegmentBundle:SegmentType')->find(SegmentType::TYPE_DYNAMIC);
     if (!$dynamicType) {
         $dynamicType = new SegmentType(SegmentType::TYPE_DYNAMIC);
         $dynamicType->setLabel('Dynamic');
         $manager->persist($dynamicType);
     }
     $organisation = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $owner = $manager->getRepository('OroOrganizationBundle:BusinessUnit')->findOneBy(array('name' => 'Test'));
     if (!$owner) {
         $owner = new BusinessUnit();
         $owner->setName('Test');
         $owner->setOrganization($organisation);
         $manager->persist($owner);
     }
     for ($i = 1; $i <= self::COUNT; $i++) {
         $definition = array('columns' => array('func' => null, 'label' => 'label' . $i, 'name' => '', 'sorting' => ''), 'filters' => array());
         $entity = new Segment();
         $entity->setCreatedAt(new \DateTime('now'));
         $entity->setDefinition(json_encode($definition));
         $entity->setDescription('description_' . $i);
         $entity->setEntity('Oro\\Bundle\\TestFrameworkBundle\\Entity\\WorkflowAwareEntity');
         $entity->setLastRun(new \DateTime('now'));
         $entity->setName('segment_' . $i);
         $entity->setOwner($owner);
         $entity->setType(rand(0, 100) % 2 ? $staticType : $dynamicType);
         $entity->setUpdatedAt(new \DateTime('now'));
         $entity->setOrganization($organisation);
         $manager->persist($entity);
     }
     $manager->flush();
 }