小编Kei*_*vis的帖子

在PHP 5中,我可以动态地实例化一个类吗?

是否可以使用变量动态实例化一个类?例如在PHP中可能是这样的吗?

class foo
{
    public $something;
}

$class_name = "foo";

$f = new $class_name();
Run Code Online (Sandbox Code Playgroud)

php class dynamic instantiation

46
推荐指数
2
解决办法
1万
查看次数

从PHP连接到Informix标准引擎(SE)

除了使用ODBC之外,还有什么办法吗?我怀疑有,但只是想检查一下.我认为ODBC性能很差,但不确定该问题.我所知道的是功能集很差(就像无法获取所选的行数一样.)

php database informix odbc

5
推荐指数
1
解决办法
416
查看次数

phpunit:为什么这个assertContains会通过?

我的测试应该失败,但它通过了:

public function test_getValidProviderCodes(){
    $aTest = PRIDE\Reflection::executeStaticMethodForClassName(Apps_DoctorsReports::class, "getValidProviderCodes");
    print_r($aTest);
    $this->assertContains("xxxxxxxxxxxxxx", $aTest);
}
Run Code Online (Sandbox Code Playgroud)

输出:

Testing started at 8:53 AM ...
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Configuration read from C:\inetpub\Intranet_Local\phpunit\phpunit.xml

Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => MAYER
    [4] => MAY00
    [5] => MAYERIC
    [6] => COH00
    [7] => COH01
    [8] => POWELL
    [9] => POW00
    [10] => JOHN00
    [11] => FINO
    [12] => POL01
    [13] => NONAP
    [14] => RAYE00
    [15] => HOPS00 …
Run Code Online (Sandbox Code Playgroud)

php phpunit unit-testing

5
推荐指数
1
解决办法
3270
查看次数

使用 Selenium 和 PHPUnit 对 http POST 到 /session 抛出卷曲错误:{"desiredCapability":{"browserName":"chrome","platform":"ANY"

我正在使用 PHPUnit 运行所有测试。创建了一个包装器,用于启动 Apache 实例,然后启动 Selenium 独立服务器,然后在http://localhost:4444/wd/hub创建 Chrome Remote Webdriver 实例。这个过程在我们的开发机器上 100% 的时间有效,在测试服务器上 90% 的时间有效,但有时测试会失败,如下所示:

 [exec] 1) Intranet\Pages\FinancialReportsSeleniumTest::test_changeMonthYear
 [exec] Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--window-size=1400,900","--no-sandbox","--headless"]},"goog:chromeOptions":{"args":["--window-size=1400,900","--no-sandbox","--headless"]}}}
 [exec] 
 [exec] Failed to connect to localhost port 4444: Connection refused
 [exec] 
 [exec] C:\Jenkins\jobs\Intranet-Master\workspace\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:292
 [exec] C:\Jenkins\jobs\Intranet-Master\workspace\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
 [exec] C:\Jenkins\jobs\Intranet-Master\workspace\phpunit\library\Intranet\Selenium.php:364
 [exec] C:\Jenkins\jobs\Intranet-Master\workspace\phpunit\library\Intranet\Selenium.php:51
 [exec] C:\Jenkins\jobs\Intranet-Master\workspace\phpunit\library\Intranet\SeleniumTestCase.php:9
Run Code Online (Sandbox Code Playgroud)

如果我们重新运行测试,下次就可以正常工作。

开发机器:

  • Windows 10 专业版 (1809)(64 位)
  • 阿帕奇 2.4.38(32 位)
  • PHP 7.2.15(32 位)
  • Java 1.8.0_192(64 位)
  • 硒 3.141.59
  • 硒 Chrome 驱动程序 73.0.3683.20

试验机

  • Windows Server …

windows selenium phpunit google-chrome selenium-chromedriver

5
推荐指数
1
解决办法
4965
查看次数