Wednesday, 11 September 2013

Testing for working links in PHPUnit

Testing for working links in PHPUnit

I am realy new to PHPUnit, and for my first self-made test case, I would
like to check if a website has an image, by providing a link to PHPUnit
like this.
lets call link I want to test http://somedomain.com/images/images.jpg
Now, I wrote this functions, and I know I am probably doing it very wrong,
but that is why I am asking it here.
class WebsiteHasImage{
public function images(){
$website = 'http://somedomain.com/images/img.jpg';
return $website;
}
}
class WebsiteHasImageTest extends PHPUnit_Framework_TestCase
{
public function testSuccess(){
$this->assertTrue($this->images(), TRUE);
}
}
Call to undefined method WebsiteHasImageTest::images() in ... on line 15
line 15 is this. $this->assertTrue($this->images(), TRUE);

No comments:

Post a Comment