Reputation: 1479
I want to link the directory to the $screenshotPath string, but an error in PHPStorm shows up: expression is not allowed as field default value. How can I fix it? Code:
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" ) );
}
}
Upvotes: 4
Views: 4082
Reputation: 85578
Move it into to the constructor (or any other function) - you seem not to have any constructor for the class, but __construct
will be called anyway :
protected $screenshotPath = '';
public function __construct() {
$this->$screenshotPath = __DIR__ . "/FailedTestsScreenshots";
}
or into SetUp()
:
protected function SetUp() {
$this->$screenshotPath = __DIR__ . "/FailedTestsScreenshots";
$this->setBrowser( "*firefox" );
$this->SetBrowserUrl( $this->path );
}
Upvotes: 4