function MessageShowMessage::testMessageArguments in Message 7
Test message-type and message arguments.
File
- tests/
message.test, line 130
Class
- MessageShowMessage
- Test the Message CRUD handling.
Code
function testMessageArguments() {
$text = 'test @token1 and @token2';
$message_type = message_type_create('foo');
$message_type->{MESSAGE_FIELD_MESSAGE_TEXT} = array(
LANGUAGE_NONE => array(
0 => array(
'value' => $text,
'format' => 'plain_text',
),
),
);
$message_type->arguments = array(
'@token1' => 'token1',
'@token2' => 'token2',
);
$message_type
->save();
$message = message_create('foo');
$output = trim(strip_tags($message
->getText()));
$this
->assertEqual('test token1 and token2', $output, t('Message type arguments replaced correctly.'));
// Test overriding message type arguments, with message arguments.
$message->arguments = array(
'@token2' => 'token3',
);
$output = trim(strip_tags($message
->getText()));
$this
->assertEqual('test token1 and token3', $output, t('Message arguments override message type arguments correctly.'));
}