是否可以使用变量动态实例化一个类?例如在PHP中可能是这样的吗?
class foo
{
public $something;
}
$class_name = "foo";
$f = new $class_name();
Run Code Online (Sandbox Code Playgroud) 除了使用ODBC之外,还有什么办法吗?我怀疑有,但只是想检查一下.我认为ODBC性能很差,但不确定该问题.我所知道的是功能集很差(就像无法获取所选的行数一样.)
我的测试应该失败,但它通过了:
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) 我正在使用 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 selenium phpunit google-chrome selenium-chromedriver