/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var \Oro\Bundle\LocaleBundle\Model\LocaleSettings $localeSettings */
     $localeSettings = $this->container->get('oro_locale.settings');
     foreach ($this->statuses as $status) {
         $entity = new RequestStatus();
         $entity->setSortOrder($status['order']);
         $entity->setName($status['name']);
         $entity->setLocale($localeSettings->getLocale())->setLabel($status['label']);
         $manager->persist($entity);
     }
     $manager->flush();
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $requestStatus = new RequestStatus();
     $requestStatus->setName(RequestStatus::OPEN);
     /* @var $repository ObjectRepository|\PHPUnit_Framework_MockObject_MockObject */
     $repository = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMock();
     $repository->expects(static::any())->method('findOneBy')->with(['name' => RequestStatus::OPEN])->willReturn($requestStatus);
     /* @var $manager ObjectManager|\PHPUnit_Framework_MockObject_MockObject */
     $manager = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $manager->expects(static::any())->method('getRepository')->with(self::REQUEST_STATUS_CLASS)->willReturn($repository);
     /* @var $registry ManagerRegistry|\PHPUnit_Framework_MockObject_MockObject */
     $registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $registry->expects(static::any())->method('getManagerForClass')->with(self::REQUEST_STATUS_CLASS)->willReturn($manager);
     /* @var $configManager ConfigManager|\PHPUnit_Framework_MockObject_MockObject */
     $configManager = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $configManager->expects(static::any())->method('get')->with('oro_b2b_rfp.default_request_status')->willReturn(RequestStatus::OPEN);
     $this->formType = new RequestType($configManager, $registry);
     $this->formType->setDataClass(self::DATA_CLASS);
     $this->formType->setRequestStatusClass(self::REQUEST_STATUS_CLASS);
     parent::setUp();
 }
 /**
  * {@inheritdoc}
  */
 public function loadEntities(ObjectManager $objectManager)
 {
     $localeSettings = $this->container->get('oro_locale.settings');
     $defaultLocale = $localeSettings->getLocale();
     $locales = $this->getTranslationLocales();
     if (!in_array($defaultLocale, $locales, true)) {
         throw new \LogicException('There are no default locale in translations!');
     }
     foreach ($this->items as $item) {
         $status = new RequestStatus();
         $status->setSortOrder($item['order']);
         $status->setName($item['name']);
         foreach ($locales as $locale) {
             $label = $this->translate($item['name'], static::PREFIX, $locale);
             if ($locale == $defaultLocale) {
                 $status->setLabel($label)->setLocale($locale);
             } else {
                 $status->addTranslation((new RequestStatusTranslation())->setLocale($locale)->setField('label')->setContent($label));
             }
         }
         $objectManager->persist($status);
     }
     $objectManager->flush();
 }
 public function testIsDraft()
 {
     $requestStatus = new RequestStatus();
     $requestStatus->setName(RequestStatus::DRAFT);
     $this->assertTrue($requestStatus->isDraft());
 }