/**
  * @testdox Allows creation of a multiposting select element
  */
 public function testCreateService()
 {
     $providerOptions = new ProviderOptions();
     $channelOptions = new ChannelOptions();
     $channelOptions->setCategory('testCat')->setCurrency('€')->setDescription('testDesc')->setExternalkey('testExtKey')->setHeadLine('testHL')->setKey('testKey')->setLabel('testLabel')->setLinkText('testLinkTxt')->setLogo('testLogo')->setParams(array('test' => 'params'))->setPrice('test', 1234)->setPublishDuration(10)->setRoute('testRoute')->setTax(19);
     $providerOptions->addChannel($channelOptions);
     $currencyFormat = $this->getMockBuilder('\\Zend\\I18n\\View\\Helper\\CurrencyFormat')->disableOriginalConstructor()->getMock();
     $currencyFormat->expects($this->any())->method('__invoke')->will($this->returnArgument(0));
     $helpers = $this->getMockBuilder('\\Zend\\ServiceManager\\AbstractPluginManager')->setMethods(array('get'))->getMockForAbstractClass();
     $helpers->expects($this->once())->method('get')->with('currencyFormat')->willReturn($currencyFormat);
     $router = $this->getMockBuilder('\\Zend\\Mvc\\Router\\SimpleRouteStack')->disableOriginalConstructor()->getMock();
     $router->expects($this->any())->method('assemble')->willReturn('/test/uri');
     $services = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceManager')->disableOriginalConstructor()->getMock();
     $servicesMap = array(array('Router', true, $router), array('ViewHelperManager', true, $helpers), array('Jobs/Options/Provider', true, $providerOptions));
     $services->expects($this->exactly(3))->method('get')->will($this->returnValueMap($servicesMap));
     $elements = $this->getMockBuilder('\\Zend\\ServiceManager\\AbstractPluginManager')->setMethods(array('getServiceLocator'))->getMockForAbstractClass();
     $elements->expects($this->once())->method('getServiceLocator')->willReturn($services);
     $target = new MultipostingSelectFactory();
     $select = $target->createService($elements);
     $this->assertInstanceOf('\\Jobs\\Form\\MultipostingSelect', $select);
     $this->assertEquals('false', $select->getAttribute('data-autoinit'));
     $this->assertEquals('multiple', $select->getAttribute('multiple'));
     $actual = $select->getValueOptions();
     $expected = array('testCat' => array('label' => 'testCat', 'options' => array('testKey' => 'testLabel|testHL|testDesc|testLinkTxt|/test/uri|10|testLogo')));
     $this->assertEquals($expected, $actual);
 }
 /**
  * @covers Jobs\Options\ProviderOptions::getChannels
  */
 public function testGetChannels()
 {
     $channel = new ChannelOptions();
     $channel->setKey('test')->setLabel('label');
     $this->options->addChannel($channel);
     $this->assertEquals(['test' => $channel], $this->options->getChannels());
 }
Esempio n. 3
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $multiposting = array_key_exists('multiposting', $config) ? $config['multiposting'] : array();
     $providerOptions = new ProviderOptions();
     if (array_key_exists('channels', $multiposting)) {
         foreach ($multiposting['channels'] as $channelName => $channel) {
             $channelOptions = $serviceLocator->get('Jobs/Options/Channel');
             if (empty($channelOptions->key)) {
                 $channelOptions->key = $channelName;
             }
             $channelOptions->setFromArray($channel);
             $providerOptions->addChannel($channelOptions);
         }
     }
     return $providerOptions;
 }
Esempio n. 4
0
 public function __invoke(JobEvent $event)
 {
     $job = $event->getJobEntity();
     $invoiceAddressDraft = $this->draftRepository->findByJobId($job->getId());
     $invoiceAddress = $invoiceAddressDraft->getInvoiceAddress();
     $snapshotBuilder = new Builder();
     $snapshot = $snapshotBuilder->build($job);
     $products = new ArrayCollection();
     foreach ($job->getPortals() as $key) {
         $product = new Product();
         $channel = $this->providerOptions->getChannel($key);
         $product->setName($channel->getLabel())->setProductNumber($channel->getExternalKey())->setQuantity(1);
         $products->add($product);
     }
     $data = ['type' => OrderInterface::TYPE_JOB, 'taxRate' => $this->options->getTaxRate(), 'price' => $this->priceFilter->filter($job->getPortals()), 'invoiceAddress' => $invoiceAddress, 'currency' => $this->options->getCurrency(), 'currencySymbol' => $this->options->getCurrencySymbol(), 'entity' => $snapshot, 'products' => $products];
     $order = $this->orderRepository->create($data);
     $this->orderRepository->store($order);
     $this->draftRepository->remove($invoiceAddressDraft);
 }