frosty
frosty

Reputation: 769

Dealing with HTTP Status Codes in PHPUnit_Extensions_Selenium2TestCase

I have a series of tests that I'm running for an Open Source Project, I'd like to get the status code of the curl request that is made to determine the difference of a code change breaking functionality vs a code change breaking the site completely.

    class ExampleTest extends PHPUnit_Extensions_Selenium2TestCase
    {
        public function setUp()
        {
            $this->setBrowser('firefox');
            $this->setBrowserUrl('http://localhost');
        }

        public function testForError()
        {
            $this->url('/');
            $this->assertNotEmpty($this->title());
        }
    }

That's an example of how I'm going about it now, but I'd like to have some concrete information. Short of getting the information from the CURL request, I'm not really sure how to go about this...

Upvotes: 2

Views: 481

Answers (2)

Qoheleth-Tech
Qoheleth-Tech

Reputation: 201

This helped me for a similar issue (when you are satisfied to get the information from the curl request):

// inside phpunit test
$url = ''; //your http://url.string.here
$request = curl_init($url);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
curl_close($request);
$this->assertTrue($status == 200);

Upvotes: 0

frosty
frosty

Reputation: 769

Apparently this isn't possible, I spoke with the maintainer of the project on Github, I'm asking for something that isn't possible.

Upvotes: 2

Related Questions