2018-06-01 04:45:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Tests\Browser;
|
|
|
|
|
|
|
|
use Laravel\Dusk\TestCase;
|
2018-06-01 05:30:05 +00:00
|
|
|
use BadMethodCallException;
|
2018-06-01 04:45:49 +00:00
|
|
|
use Tests\CreatesApplication;
|
2018-06-01 05:30:05 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2018-06-01 04:45:49 +00:00
|
|
|
use Facebook\WebDriver\Chrome\ChromeOptions;
|
|
|
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
|
|
|
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
|
|
|
|
abstract class BrowserTestCase extends TestCase
|
|
|
|
{
|
|
|
|
use CreatesApplication, DatabaseMigrations;
|
|
|
|
|
2018-06-01 05:30:05 +00:00
|
|
|
/**
|
|
|
|
* Setup tests.
|
|
|
|
*/
|
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
// Don't accidentally run the migrations aganist the non-testing database. Ask me
|
|
|
|
// how many times I've accidentally dropped my database...
|
|
|
|
if (env('DB_CONNECTION') !== 'testing') {
|
|
|
|
throw new BadMethodCallException('Cannot call browser tests using the non-testing database connection.');
|
|
|
|
}
|
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Gotta unset this to continue avoiding issues with the validation.
|
|
|
|
Model::unsetEventDispatcher();
|
|
|
|
}
|
|
|
|
|
2018-06-01 04:45:49 +00:00
|
|
|
/**
|
|
|
|
* Create the RemoteWebDriver instance.
|
|
|
|
*
|
|
|
|
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
|
|
|
|
*/
|
|
|
|
protected function driver()
|
|
|
|
{
|
|
|
|
$options = (new ChromeOptions)->addArguments([
|
|
|
|
'--disable-gpu',
|
2018-06-01 05:42:52 +00:00
|
|
|
'--disable-infobars',
|
2018-06-01 04:45:49 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
return RemoteWebDriver::create(
|
|
|
|
'http://services.pterodactyl.local:4444/wd/hub', DesiredCapabilities::chrome()->setCapability(
|
|
|
|
ChromeOptions::CAPABILITY, $options
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an instance of the browser to be used for tests.
|
|
|
|
*
|
|
|
|
* @param \Facebook\WebDriver\Remote\RemoteWebDriver $driver
|
|
|
|
* @return \Pterodactyl\Tests\Browser\PterodactylBrowser
|
|
|
|
*/
|
|
|
|
protected function newBrowser($driver): PterodactylBrowser
|
|
|
|
{
|
|
|
|
return new PterodactylBrowser($driver);
|
|
|
|
}
|
|
|
|
}
|