public function testProcessExistingShoppingList()
 {
     $this->shoppingList->expects($this->once())->method('getId')->willReturn(1);
     $this->request->expects($this->once())->method('getMethod')->will($this->returnValue('PUT'));
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $manager */
     $manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $manager->expects($this->once())->method('persist');
     $manager->expects($this->once())->method('flush');
     $this->registry->expects($this->once())->method('getManagerForClass')->with(self::SHOPPING_LIST_SHORTCUT)->will($this->returnValue($manager));
     $handler = new ShoppingListHandler($this->form, $this->request, $this->manager, $this->registry);
     $this->assertTrue($handler->process($this->shoppingList));
 }
 public function testGetMetadata()
 {
     $this->formatter->expects($this->once())->method('format')->with('test value', true)->willReturn('formatted test label');
     $formView = $this->createFormView();
     $formView->vars['formatter_options'] = [];
     $typeFormView = $this->createFormView($formView);
     $typeFormView->vars['choices'] = [];
     $unitFormView = $this->createFormView($formView);
     $unitFormView->vars['choices'] = [new ChoiceView('test data', 'test value', 'test label')];
     $formView->children = ['type' => $typeFormView, 'unit' => $unitFormView];
     $this->form->expects($this->any())->method('createView')->willReturn($formView);
     $metadata = $this->productPriceFilter->getMetadata();
     $this->assertArrayHasKey('unitChoices', $metadata);
     $this->assertInternalType('array', $metadata['unitChoices']);
     $this->assertEquals([['data' => 'test data', 'value' => 'test value', 'label' => 'test label', 'shortLabel' => 'formatted test label']], $metadata['unitChoices']);
 }
 /**
  * @return mixed
  */
 public function createView()
 {
     return $this->form->createView();
 }