Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Last active May 14, 2017 22:34
Show Gist options
  • Save deleugpn/d0e07980be8ae38dd628581c8de1c82d to your computer and use it in GitHub Desktop.
Save deleugpn/d0e07980be8ae38dd628581c8de1c82d to your computer and use it in GitHub Desktop.
Allow Dusk to assert environment matches Browser environment
<?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