示例#1
0
 public function testGettersAndSetters()
 {
     $this->assertEquals(self::TEST_NAME, $this->entity->getName());
     $testLabel = 'label_test';
     $this->assertNull($this->entity->getLabel());
     $this->entity->setLabel($testLabel);
     $this->assertEquals($testLabel, $this->entity->getLabel());
     $this->assertEquals($testLabel, (string) $this->entity);
 }
示例#2
0
 /**
  * Load available segment types
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $types = [SegmentType::TYPE_DYNAMIC, SegmentType::TYPE_STATIC];
     foreach ($types as $typeCode) {
         $type = new SegmentType($typeCode);
         $type->setLabel('oro.segment.type.' . $typeCode);
         $manager->persist($type);
     }
     $manager->flush();
 }
示例#3
0
 public function testGetSegmentTypeChoices()
 {
     $this->repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->any())->method('getRepository')->with('OroSegmentBundle:SegmentType')->will($this->returnValue($this->repository));
     $type = new SegmentType('test');
     $type->setLabel('testLabel');
     $types = [$type];
     $this->repository->expects($this->once())->method('findAll')->will($this->returnValue($types));
     $result = $this->manager->getSegmentTypeChoices();
     $this->assertInternalType('array', $result);
     $this->assertCount(1, $result);
     $this->assertSame(['test' => 'testLabel'], $result);
 }
示例#4
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();
 }