public function testOrganization() { $organization = new Organization(); $this->assertNull($this->unit->getOrganization()); $this->unit->setOrganization($organization); $this->assertEquals($organization, $this->unit->getOrganization()); }
/** * {@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(); }
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(); }