Last active
May 14, 2017 22:34
-
-
Save deleugpn/d0e07980be8ae38dd628581c8de1c82d to your computer and use it in GitHub Desktop.
Allow Dusk to assert environment matches Browser environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests; | |
use PHPUnit\Framework\Assert as PHPUnit; | |
use Laravel\Dusk\Browser as DuskBrowser; | |
class Browser extends DuskBrowser { | |
/** | |
* Check if the Browser environment matches with the | |
* environment loaded by `php artisan dusk` | |
* @return $this | |
*/ | |
public function assertBrowserEnvironment() { | |
$environment = getenv('APP_ENV'); | |
$browserEnvironment = $this->visit('/_dusk/env') | |
->element('')->getText(); | |
PHPUnit::assertEquals($environment, $browserEnvironment, | |
"Browser environment [{$browserEnvironment}] | |
diverge from the given environment [{$environment}]"); | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment