php不允许修改的变量,php – 函数外部的变量中不允许表达式

我想将目录链接到$screenshotPath字符串,但PHPStorm中出现错误:表达式不允许作为字段默认值.我该如何解决?码:

use PHPUnit\Extensions\SeleniumTestCase;

use ApplicationTest\Bootstrap;

class AdminLoginLogoutTest extends PHPUnit_Extensions_SeleniumTestCase {

protected $captureScreenshotOnFailure = true;

//$screenshotPath is giving me this error...

protected $screenshotPath = __DIR__ . "/FailedTestsScreenshots";

protected $screenshotUrl = "http://icho/screenshots";

protected $path = "http://icho";

protected function SetUp() {

$this->setBrowser( "*firefox" );

$this->SetBrowserUrl( $this->path );

}

public function testAdminLoginLogout() {

$this->open( "/admin" );

$this->type( "name=username", "test" );

$this->type( "name=password", "test" );

$this->click( "id=submitbutton" );

$this->waitForPageToLoad( "30000" );

$this->assertEquals( "Dashboard", $this->getText( "link=Dashboard" ) );

$this->assertEquals( "Haios", $this->getText( "link=Haios" ) );

$this->assertEquals( "POs", $this->getText( "link=POs" ) );

$this->assertEquals( "Staco's", $this->getText( "link=Staco's" ) );

$this->assertEquals( "Mail templates", $this->getText( "link=Mail templates" ) );

$this->assertEquals( "Mailings", $this->getText( "link=Mailings" ) );

$this->assertEquals( "Sytem texts", $this->getText( "link=System texts" ) );

$this->assertEquals( "Advanced admin", $this->getText( "link=Advanced admin" ) );

$this->click( "css=a[title='Sign Out']" );

$this->click( "id=bot2-Msg1" );

$this->waitForPageToLoad( "30000" );

$this->assertEquals( "Login is vereist", $this->getText( "css=h2" ) );

}

}

解决方法:

将它移动到构造函数(或任何其他函数) – 您似乎没有该类的任何构造函数,但无论如何都将调用__construct:

protected $screenshotPath = '';

public function __construct() {

$this->$screenshotPath = __DIR__ . "/FailedTestsScreenshots";

}

或者进入SetUp():

protected function SetUp() {

$this->$screenshotPath = __DIR__ . "/FailedTestsScreenshots";

$this->setBrowser( "*firefox" );

$this->SetBrowserUrl( $this->path );

}

标签:php,selenium,phpunit

来源: https://codeday.me/bug/20190623/1275150.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值