Example #1
0
	/**
	 * @covers Bedrock\View::getMessages
	 * @covers Bedrock\View::setMessage
	 *
	 * @return void
	 */
	public function testGetMessages() {
		// Setup
		$messages = array(
			'success' => array(
				'Testing message type: SUCCESS_01',
				'Testing message type: SUCCESS_02',
				'Testing message type: SUCCESS_03'
			),
			'info' => array(
				'Testing message type: INFO_01',
				'Testing message type: INFO_02',
				'Testing message type: INFO_03'
			),
			'warn' => array(
				'Testing message type: WARN_01',
				'Testing message type: WARN_02',
				'Testing message type: WARN_03'
			),
			'error' => array(
				'Testing message type: ERROR_01',
				'Testing message type: ERROR_02',
				'Testing message type: ERROR_03'
			)
		);

		$this->_object->setMessage(\Bedrock\View::MESSAGE_SUCCESS, $messages['success'][0]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_SUCCESS, $messages['success'][1]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_SUCCESS, $messages['success'][2]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_INFO, $messages['info'][0]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_INFO, $messages['info'][1]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_INFO, $messages['info'][2]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_WARN, $messages['warn'][0]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_WARN, $messages['warn'][1]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_WARN, $messages['warn'][2]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_ERROR, $messages['error'][0]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_ERROR, $messages['error'][1]);
		$this->_object->setMessage(\Bedrock\View::MESSAGE_ERROR, $messages['error'][2]);

		// Assertions
		$this->assertAttributeSame($messages, '_messages', $this->_object);
		$this->assertSame($messages, $this->_object->getMessages(\Bedrock\View::MESSAGE_ALL));
		$this->assertSame($messages['success'], $this->_object->getMessages(\Bedrock\View::MESSAGE_SUCCESS));
		$this->assertSame($messages['info'], $this->_object->getMessages(\Bedrock\View::MESSAGE_INFO));
		$this->assertSame($messages['warn'], $this->_object->getMessages(\Bedrock\View::MESSAGE_WARN));
		$this->assertSame($messages['error'], $this->_object->getMessages(\Bedrock\View::MESSAGE_ERROR));
	}