public function testAddWithQuoteAddressItem() { $entityId = 1; $giftMessages = array('quote_address_item' => array(1 => array('from' => 'sender', 'to' => 'recipient', 'message' => 'message', 'address' => 'address'))); $this->messageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->giftMessageMock)); $this->quoteMock->expects($this->once())->method('getAddressById')->with('address')->will($this->returnValue($this->quoteAddressMock)); $this->quoteAddressMock->expects($this->once())->method('getItemById')->with($entityId)->will($this->returnValue($this->quoteAddressItemMock)); $this->quoteAddressItemMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue(0)); $this->giftMessageMock->expects($this->once())->method('setSender')->with('sender')->will($this->returnValue($this->giftMessageMock)); $this->giftMessageMock->expects($this->once())->method('setRecipient')->with('recipient')->will($this->returnValue($this->giftMessageMock)); $this->giftMessageMock->expects($this->once())->method('setMessage')->with('message')->will($this->returnValue($this->giftMessageMock)); $this->giftMessageMock->expects($this->once())->method('save'); $this->giftMessageMock->expects($this->once())->method('getId')->will($this->returnValue(33)); $this->quoteAddressItemMock->expects($this->once())->method('setGiftMessageId')->with(33)->will($this->returnValue($this->quoteAddressItemMock)); $this->quoteAddressItemMock->expects($this->once())->method('save')->will($this->returnValue($this->quoteAddressItemMock)); $this->model->add($giftMessages, $this->quoteMock); }