You are not logged in.
Hello,
How would you approach this challenge:
make PHPUnit select a link from a web page
e.g.: <a title="Demo Title" href="/index/demo">Demo</a>
then use the result to check if the page is reachable
e.g.: $this->dispatch("/index/demo");
At the moment I'm doing this:
[code=php]
public function testPageIndexReachable()
{
$this->dispatch("/");
// check if link on currently loaded page exist
$this->assertQueryContentContains('a[href="/index/demo"]', 'Demo');
$this->assertModule("default");
$this->assertController("index");
$this->assertAction("index");
$this->assertResponseCode(200);
}[/code]
Any suggestions?
Thanks, Udo
Offline
Udo, does this work?
Offline
yes, sometimes I wonder myself... ![]()
Or are you referring to a specific line?
Complete code looks similar to this:
[code=php]
<?php
/**
* Module Default: IndexControllerTest class
*/
class IndexControllerTest extends ControllerTestCase
{
/* some other tests ... */
public function testPageIndexReachable()
{
$this->dispatch("/");
// check if link on currently loaded page exist
$this->assertQueryContentContains('a[href="/index/demo"]', 'Demo');
$this->assertModule("default");
$this->assertController("index");
$this->assertAction("index");
$this->assertResponseCode(200);
}
}[/code]
Update:
Maybe you are referring to this line:
[code=php]$this->assertQueryContentContains('a[href="/index/demo"]', 'Demo');[/code]
I think the page has to be valid(!) XHTML to work properly.
Offline