douyi1963 2017-03-28 13:46 采纳率: 0%
浏览 29

意外的PHP错误[fclose()期望参数1为资源,给定布尔值] [simpletest / socket.php第255行]中的severity [2]

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条回答 默认 最新

  • doudiejian5827 2018-01-29 12:14
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看