Skip to content

Commit

Permalink
Fix PHPStan errors in tests/Browser/
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Jan 27, 2024
1 parent dfb88b5 commit c63ec98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1149,13 +1149,3 @@ parameters:
message: "#^Call to an undefined method rcube\\:\\:get_uploaded_file\\(\\)\\.$#"
count: 1
path: tests/Actions/Settings/Upload.php

-
message: "#^Call to an undefined method Tests\\\\Browser\\\\Browser\\:\\:assertEquals\\(\\)\\.$#"
count: 1
path: tests/Browser/Browser.php

-
message: "#^Call to an undefined method Tests\\\\Browser\\\\Browser\\:\\:getEnv\\(\\)\\.$#"
count: 1
path: tests/Browser/Browser.php
10 changes: 9 additions & 1 deletion tests/Browser/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function assertElementsCount($selector, $expected_count, $visible = true)
*/
public function assertEnvEquals($key, $expected)
{
$this->assertEquals($expected, $this->getEnv($key));
Assert::assertEquals($expected, $this->getEnv($key));

return $this;
}
Expand Down Expand Up @@ -144,6 +144,14 @@ public function ctrlClick($selector)
return $this;
}

/**
* Return rcmail.env entry
*/
public function getEnv($key)
{
return $this->driver->executeScript("return rcmail.env['{$key}']");
}

/**
* Visit specified task/action with logon if needed
*/
Expand Down
14 changes: 3 additions & 11 deletions tests/Browser/Components/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public function assertEnv($browser, $key, $expected = null)
{
if (is_array($key)) {
foreach ($key as $name => $expected) {
Assert::assertEquals($expected, $this->getEnv($browser, $name));
Assert::assertEquals($expected, $browser->getEnv($name));
}
} else {
Assert::assertEquals($expected, $this->getEnv($browser, $key));
Assert::assertEquals($expected, $browser->getEnv($key));
}
}

Expand All @@ -72,14 +72,6 @@ public function assertObjects($browser, array $names)
}
}

/**
* Return rcmail.env entry
*/
public function getEnv($browser, $key)
{
return $browser->driver->executeScript("return rcmail.env['{$key}']");
}

/**
* Return names of defined gui_objects
*/
Expand All @@ -96,7 +88,7 @@ public function gotoAction($browser, $task = 'mail', $action = null, $login = tr
$browser->visit("?_task={$task}&_action={$action}");

// check if we have a valid session
if ($login && $this->getEnv($browser, 'task') == 'login') {
if ($login && $browser->getEnv($browser, 'task') == 'login') {
$this->doLogin($browser);
}
}
Expand Down

0 comments on commit c63ec98

Please sign in to comment.