Hey..
I´m trying to write my first simple tests but it fails just at the beginning. I wrote a module which creates a link in the navigation:
function mymodule_menu() {
$items['mymodule'] = array(
'title' => 'MyLink',
'page callback' => 'mymodule_hello',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
The callback function "mymodule_hello" only displays the word "hello".
Now i wanted to check this link and its output with simpletest.
I wrote the following piece of code:
class MyModuleTest extends DrupalWebTestCase {
function getInfo() {
return array(
'name' => t('MyModule'),
'desc' => t('A simple test.'),
'group' => t('My tests'),
);
}
function setUp() {
parent::setUp();
$user = $this->drupalCreateUser(array('administer site configuration'));
$this->drupalLogin($user);
}
function testModulLink(){
$this->drupalGet('');
$this->clickLink('MyLink');
}
}
If i now run the test i get the following messages:
12 passes, 1 fail, and 0 exceptions
...
Clicked link "MyLink" () from http://localhost/drupal/ Browser mytest.test 26 MyModuleTest->testModulLink()
If i use the link "Log out" the test works fine. Only my own links don´t work.
Comments
Comment #1
dave reidYou are missing the access argument/callback for your menu item. Try using:
Comment #2
boombatower commentedYou need to enable your test module in the setup call:
and the
getInfo()method should bepublic static function getInfo()Comment #3
boombatower commentedPlease rep-open if still having issues.