From 06923574f53fe610630f0e3f87eb8dc1d7d91418 Mon Sep 17 00:00:00 2001 From: Roy Segall Date: Sun, 25 Jan 2015 09:47:25 +0200 Subject: [PATCH] Surfing bird. --- message.info | 3 +- message_example/message_example.info | 2 +- tests/MessageArgumentsTestCase.test | 59 ++++++++++++++++++++++++++++ message.test => tests/message.test | 58 --------------------------- 4 files changed, 62 insertions(+), 60 deletions(-) create mode 100644 tests/MessageArgumentsTestCase.test rename message.test => tests/message.test (95%) diff --git a/message.info b/message.info index f896bd0..acbbfd5 100644 --- a/message.info +++ b/message.info @@ -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 diff --git a/message_example/message_example.info b/message_example/message_example.info index 4f72c16..36e0b19 100644 --- a/message_example/message_example.info +++ b/message_example/message_example.info @@ -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 diff --git a/tests/MessageArgumentsTestCase.test b/tests/MessageArgumentsTestCase.test new file mode 100644 index 0000000..a161a67 --- /dev/null +++ b/tests/MessageArgumentsTestCase.test @@ -0,0 +1,59 @@ + '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.'); + } + +} diff --git a/message.test b/tests/message.test similarity index 95% rename from message.test rename to tests/message.test index e97ad40..f590b94 100644 --- a/message.test +++ b/tests/message.test @@ -1,63 +1,5 @@ '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. */