You are here

public function MessageUiHardCodedArguments::testHardCoded in Message UI 7

Verify that a user can update the arguments for each instance.

File

./message_ui.test, line 180

Class

MessageUiHardCodedArguments
Testing the editing of the hard coded arguments.

Code

public function testHardCoded() {
  $this
    ->drupalLogin($this->user1);
  $message = message_create('dummy_message');
  $message->uid = $this->user1->uid;
  $message
    ->save();

  // Verifying the message hard coded value is set to the user 1.
  $this
    ->drupalGet('message/' . $message->mid);
  $this
    ->assertText($this->user1->name, 'The message token is set to the user 1.');
  $message->uid = $this->user2->uid;
  $message
    ->save();
  $this
    ->drupalGet('message/' . $message->mid);
  $this
    ->assertNoText($this->user2->name, 'The message token is set to the user 1 after editing the message.');

  // Update the message arguments automatically.
  $edit = array(
    'name' => $this->user2->name,
    'replace_tokens' => 'update',
  );
  $this
    ->drupalPost('message/' . $message->mid . '/edit', $edit, t('Update'));
  $this
    ->assertText($this->user2->name, 'The message token as updated automatically.');

  // Update the message arguments manually.
  $edit = array(
    'name' => $this->user2->name,
    'replace_tokens' => 'update_manually',
    '@{message:user:name}' => 'Dummy name',
  );
  $this
    ->drupalPost('message/' . $message->mid . '/edit', $edit, t('Update'));
  $this
    ->assertText('Dummy name', 'The hard coded token was updated with a custom value.');
}