Skip to content

Commit

Permalink
Surfing bird.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Segall committed Jan 25, 2015
1 parent 8c8d637 commit 0692357
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 60 deletions.
3 changes: 2 additions & 1 deletion message.info
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ files[] = includes/message.message_type.inc
files[] = includes/message.message_type_category.inc

; Tests
files[] = message.test
files[] = tests/message.test
files[] = tests/MessageArgumentsTestCase.test

; Views includes
files[] = includes/views/message.views.inc
Expand Down
2 changes: 1 addition & 1 deletion message_example/message_example.info
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ features[variable][] = field_bundle_settings_message__example_create_comment
features[variable][] = field_bundle_settings_message__example_create_node
features[variable][] = field_bundle_settings_message__example_user_register
features[views_view][] = message_example
mtime = 1421048270
mtime = 1421303198
59 changes: 59 additions & 0 deletions tests/MessageArgumentsTestCase.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* Testing the arguments handler for messages.
*/
class MessageArgumentsTestCase extends DrupalWebTestCase {

/**
* @var \stdClass
*
* The user object.
*/
protected $user;

/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Message arguments',
'description' => 'Test the Message and arguments handling.',
'group' => 'Message',
);
}

function setUp() {
parent::setUp('message', 'message_example');

$this->user = $this->drupalCreateUser();
}

/**
* Testing ctools message arguments plugin.
*/
public function testCtoolsArguments() {
$uri = entity_uri('user', $this->user);

message_type_create('example_arguments', array())->save();

$message = message_create('example_arguments', array('uid' => $this->user->uid));
$message->save();

if (!$handler = message_get_message_arguments_handler($message)) {
throw new Exception('No arguments handler was found for the Message example message type.');
}

$arguments = $handler->getArguments();

$expected_arguments = array(
'@name' => $this->user->name,
'%time' => format_date($message->timestamp),
'!link' => l(t('link'), $uri['path'], array('absolute' => TRUE)),
);

// Verify we got the correct arguments.
$this->assertEqual($arguments, $expected_arguments, 'The arguments plugin returned the expected values.');
}

}
58 changes: 0 additions & 58 deletions message.test → tests/message.test
Original file line number Diff line number Diff line change
@@ -1,63 +1,5 @@
<?php

/**
* Testing the arguments handler for messages.
*/
class MessageArgumentsTestCase extends DrupalWebTestCase {

/**
* @var \stdClass
*
* The user object.
*/
protected $user;

/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Message arguments',
'description' => 'Test the Message and arguments handling.',
'group' => 'Message',
);
}

function setUp() {
parent::setUp('message', 'message_example');

$this->user = $this->drupalCreateUser();
}

/**
* Testing ctools message arguments plugin.
*/
public function testCtoolsArguments() {
$uri = entity_uri('user', $this->user);

message_type_create('example_arguments', array())->save();

$message = message_create('example_arguments', array('uid' => $this->user->uid));
$message->save();

if (!$handler = message_get_message_arguments_handler($message)) {
throw new Exception('No arguments handler was found for the Message example message type.');
}

$arguments = $handler->getArguments();

$expected_arguments = array(
'@name' => $this->user->name,
'%time' => format_date($message->timestamp),
'!link' => l(t('link'), $uri['path'], array('absolute' => TRUE)),
);

// Verify we got the correct arguments.
$this->assertEqual($arguments, $expected_arguments, 'The arguments plugin returned the expected values.');
}

}

/**
* Test the Message CRUD handling.
*/
Expand Down

0 comments on commit 0692357

Please sign in to comment.