public function testSaveMessageWillUpdateExistingMessagesIfTheyAlreadyHaveAnId() { $messageData = array('queue_id' => '123', 'service' => 'testService', 'method' => 'testMethod', 'status' => 'testStatus', 'data' => 'some data', 'date_queued' => '2013-04-18 16:11:22', 'date_start_processing' => '2013-04-18 16:11:24', 'date_finished_processing' => '2013-04-18 16:11:24'); $message = new Message(); $message->exchangeArray($messageData); $resultSet = new ResultSet(); $resultSet->setArrayObjectPrototype(new Message()); $resultSet->initialize(array($message)); $mockTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select', 'update'), array(), '', false); $mockTableGateway->expects($this->once())->method('select')->with(array('queue_id' => 123))->will($this->returnValue($resultSet)); $mockTableGateway->expects($this->once())->method('update')->with(array('service' => 'testService', 'method' => 'testMethod', 'status' => 'testStatus', 'data' => 'some data', 'date_queued' => '2013-04-18 16:11:22', 'date_start_processing' => '2013-04-18 16:11:24', 'date_finished_processing' => '2013-04-18 16:11:24'), array('queue_id' => 123)); $messageTable = new MessageTable($mockTableGateway); $messageTable->saveMessageItem($message); }
public function testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent() { $message = new Message(); $data = array('queue_id' => '123', 'service' => 'testService', 'method' => 'testMethod', 'status' => 'testStatus', 'data' => 'some data', 'date_queued' => '2013-04-18 16:11:22', 'date_start_processing' => '2013-04-18 16:11:24', 'date_finished_processing' => '2013-04-18 16:11:24'); $message->exchangeArray($data); $message->exchangeArray(array()); $this->assertNull($message->queue_id, '"queue_id" should have defaulted to null'); $this->assertNull($message->service, '"service" should have defaulted to null'); $this->assertNull($message->method, '"method" should have defaulted to null'); $this->assertNull($message->data, '"data" should have defaulted to null'); $this->assertNull($message->status, '"status" should have defaulted to null'); $this->assertNull($message->date_queued, '"date_queued" should have defaulted to null'); $this->assertNull($message->date_start_processing, '"date_start_processing" should have defaulted to null'); $this->assertNull($message->date_finished_processing, '"date_finished_processing" should have defaulted to null'); }