public function testProcessValidData() { $subtotal = new Subtotal(); $amount = 42; $subtotal->setType(Subtotal::TYPE_SUBTOTAL); $subtotal->setAmount($amount); $subtotals = new ArrayCollection([$subtotal]); $this->subtotalsProvider->expects($this->any())->method('getSubtotals')->willReturn($subtotals); $this->request->setMethod('POST'); $this->form->expects($this->once())->method('submit')->with($this->request); $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->manager->expects($this->once())->method('persist')->with($this->entity); $this->manager->expects($this->once())->method('flush'); $this->assertTrue($this->handler->process($this->entity)); $propertyAccessor = PropertyAccess::createPropertyAccessor(); foreach ($subtotals as $subtotal) { $this->assertEquals($amount, $propertyAccessor->getValue($this->entity, $subtotal->getType())); } }
/** * @param float $subtotalAmount */ protected function assertCalculateSubtotalsCalled($subtotalAmount) { $subtotal = new Subtotal(); $subtotal->setType(Subtotal::TYPE_SUBTOTAL)->setAmount($subtotalAmount); $this->subtotalsProvider->expects($this->once())->method('getSubtotals')->willReturn(new ArrayCollection([$subtotal])); }