public function testInterface()
 {
     $channel = new Integration();
     $someOwner = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User');
     $channel->setDefaultUserOwner($someOwner);
     $event = new DefaultOwnerSetEvent($channel);
     $this->assertSame($channel, $event->getChannel());
     $this->assertSame($someOwner, $event->getDefaultUserOwner());
 }
Пример #2
0
 /**
  * @return array
  */
 public function defaultIntegrationOwnerProvider()
 {
     $integrationEmptyOwner = new Integration();
     $user = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User');
     $organization = $this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization');
     $integrationWithOwner = new Integration();
     $integrationWithOwner->setDefaultUserOwner($user);
     $integrationWithOrganization = new Integration();
     $integrationWithOrganization->setOrganization($organization);
     return ['should set, user given and user owned entity' => [$integrationWithOwner, 'USER', false, true], 'should set with reload' => [$integrationWithOwner, 'USER', true, true], 'should not set, user not given even if user owned entity' => [$integrationEmptyOwner, 'USER', false, false], 'should not set, user given and BU owned entity' => [$integrationWithOwner, 'BUSINESS_UNIT', false, false], 'set organization' => [$integrationWithOrganization, 'BUSINESS_UNIT', false, false, true]];
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $userManager = $this->container->get('oro_user.manager');
     $admin = $userManager->findUserByEmail(LoadAdminUserData::DEFAULT_ADMIN_EMAIL);
     foreach ($this->data as $data) {
         $integration = new Integration();
         $integration->setName($data['name']);
         $integration->setType($data['type']);
         $integration->setEnabled($data['enabled']);
         $integration->setDefaultUserOwner($admin);
         $integration->setOrganization($admin->getOrganization());
         $this->setReference($data['reference'], $integration);
         $manager->persist($integration);
     }
     $manager->flush();
 }
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $userManager = $this->container->get('oro_user.manager');
     $admin = $userManager->findUserByEmail(LoadAdminUserData::DEFAULT_ADMIN_EMAIL);
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     foreach ($this->channelData as $data) {
         $entity = new Channel();
         $data['transport'] = $this->getReference($data['transport']);
         $entity->setDefaultUserOwner($admin);
         $entity->setOrganization($organization);
         $this->setEntityPropertyValues($entity, $data, ['reference', 'synchronizationSettings']);
         $this->setReference($data['reference'], $entity);
         if (isset($data['synchronizationSettings'])) {
             foreach ($data['synchronizationSettings'] as $key => $value) {
                 $entity->getSynchronizationSettingsReference()->offsetSet($key, $value);
             }
         }
         $manager->persist($entity);
     }
     $manager->flush();
 }