Correctly tear down tests and remove cookies
This commit is contained in:
parent
8bbe6bc279
commit
6e9123af19
1 changed files with 36 additions and 0 deletions
|
@ -4,7 +4,9 @@ namespace Pterodactyl\Tests\Browser;
|
|||
|
||||
use Laravel\Dusk\TestCase;
|
||||
use BadMethodCallException;
|
||||
use Pterodactyl\Models\User;
|
||||
use Tests\CreatesApplication;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||
|
@ -15,6 +17,13 @@ abstract class BrowserTestCase extends TestCase
|
|||
{
|
||||
use CreatesApplication, DatabaseMigrations;
|
||||
|
||||
/**
|
||||
* The default password to use for new accounts.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $userPassword = 'Password123';
|
||||
|
||||
/**
|
||||
* Setup tests.
|
||||
*/
|
||||
|
@ -61,4 +70,31 @@ abstract class BrowserTestCase extends TestCase
|
|||
{
|
||||
return new PterodactylBrowser($driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down the test and delete all cookies from the browser instance to address
|
||||
* instances where the test would be kicked over to the login page.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
/** @var \Pterodactyl\Tests\Browser\PterodactylBrowser $browser */
|
||||
foreach (static::$browsers as $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a user model to authenticate aganist and use in the tests.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return \Pterodactyl\Models\User
|
||||
*/
|
||||
protected function user(array $attributes = []): User
|
||||
{
|
||||
return factory(User::class)->create(array_merge([
|
||||
'password' => Hash::make(static::$userPassword),
|
||||
], $attributes));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue