I have been using SimpleTest to do basic testing of my project. I want to do some basic checks on the pages themselves to make sure things continue working as we develop. I have hit a few issues though.

First I tried using the class WebTestCase, I received 403 when attempting to connect to google and the same error as below. I switched to using normal UnitTestCase and the SimpleBrowser helper class provided by SimpleTest. Using this, I can connect to google with no issue, but I still get the same error when attempting to reach my own site.

Unexpected PHP error [fclose() expects parameter 1 to be resource, boolean given] severity [2] in [simpletest/socket.php line 255]

class TestOfBasicFunctionality extends UnitTestCase
{
    function testGoogleBrowser()
    {
        $browser = &new SimpleBrowser();
        $browser->get('https://www.google.com');
        $this->assertEqual($browser->getTitle(), 'Google');
        $this->assertEqual($browser->getResponseCode(), 200);
    }

    function testIndexBrowser()
    {
        $browser = &new SimpleBrowser();
        $browser->get('https://subdomain.mywebsite.com/');
        $this->assertEqual($browser->getResponseCode(), 200);
    }
}

In the end, I dont understand what is going wrong. If the code is complex, I can understand that I did something wrong. However, these are very simple tests, and I don't see any mistakes. My only thought is that there are settings on the server that are preventing the connection from happening.

Can anyone help me? Is this a SimpleTest problem, my coding fault, or an issue with server settings?

1

There are 1 best solutions below

0
Ricardo CF On

After you tried it: fopen is not working on my server

You can try the code below, this solution not solve the problem, but you can keep your tests...

in simpletest/socket.php line 255 , try this:

function close() {
    $this->is_open = false;
    if(is_resource($this->handle)){
        return fclose($this->handle);
    }else{ return true; }
}

Then you can run tests.