function SimplenewsStatisticsTestCase::testClickStatisticLinkRedirect in Simplenews Statistics 7
Same name and namespace in other branches
- 7.2 tests/simplenews_statistics.test \SimplenewsStatisticsTestCase::testClickStatisticLinkRedirect()
Test Workflow: Redirected to correct page
send a newsletter, click a link, test that the user is forwarded to the correct page
File
- tests/
simplenews_statistics.test, line 389 - Simplenews Statistics test functions.
Class
- SimplenewsStatisticsTestCase
- @file Simplenews Statistics test functions.
Code
function testClickStatisticLinkRedirect() {
$this
->createAndSendNewsletter();
//get the last email sent
$mails = $this
->drupalGetMails();
$mail = end($mails);
$source = $mail['params']['simplenews_source'];
$source_node = $source
->getNode();
//obtain the full URL link by stripping off the characters
$link = $mail['body'];
$link = substr($link, strpos($link, 'title="Simplenews Statistics Link" href="'));
//make certain we get the link that we need to test
$link = substr($link, strpos($link, check_plain(url('simplenews/statistics/click', array(
'absolute' => TRUE,
)))));
//we only obtain the first of probobly several urls
$link = substr($link, 0, strpos($link, '"'));
$this
->verbose('Link thus far is: ' . $link);
$intended_url = "http://drupal.org/project/simplenews_statistics";
//defined in the test mail we send above
//click the link - see if we are re-directed to the target page
$this
->drupalGet($link);
//test
$this
->assertEqual($intended_url, $this
->getUrl());
}