/** * Test addMessage, hasMessage, getMessage and clearMessages methods. */ public function testMessagesCrud() { /** Test new object does not contain any messages. */ $this->assertFalse($this->_response->hasMessages(), 'New object contains messages.'); /** Test message adding functionality. */ $this->_response->addMessage('Message text', 200, array('key' => 'value'), Mage_Webapi_Controller_Response::MESSAGE_TYPE_SUCCESS); $this->assertTrue($this->_response->hasMessages(), 'New message is not added right.'); /** Test message getting functionality. */ $expectedMessage = array(Mage_Webapi_Controller_Response::MESSAGE_TYPE_SUCCESS => array(array('key' => 'value', 'message' => 'Message text', 'code' => 200))); $this->assertEquals($expectedMessage, $this->_response->getMessages(), 'Message is got wrong.'); /** Test message clearing functionality. */ $this->_response->clearMessages(); $this->assertFalse($this->_response->hasMessages(), 'Message is not cleared.'); }