-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI Pipeline Add Laravel Dusk Browser tests and integration test
- Loading branch information
Showing
10 changed files
with
321 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
version: v1.0 | ||
name: CI Pipeline | ||
agent: | ||
machine: | ||
type: e1-standard-2 | ||
os_image: ubuntu1804 | ||
blocks: | ||
- name: Install dependencies | ||
task: | ||
jobs: | ||
- name: Composer | ||
commands: | ||
- checkout | ||
- cache restore | ||
- composer install | ||
- cache store | ||
env_vars: | ||
- name: APP_ENV | ||
value: development | ||
- name: Code analysis | ||
task: | ||
prologue: | ||
commands: | ||
- checkout | ||
- cache restore | ||
jobs: | ||
- name: Mess Detect | ||
commands: | ||
- php vendor/bin/phpmd routes json phpmd_rules.xml | ||
- php vendor/bin/phpmd resources json phpmd_rules.xml | ||
- php vendor/bin/phpmd app/Http json phpmd_rules.xml | ||
- name: Code Sniffer | ||
commands: | ||
- php vendor/bin/phpcs -n --standard=PSR2 app routes resources | ||
- name: Security Test | ||
commands: | ||
- 'vendor/bin/security-checker security:check composer.lock' | ||
- name: Tests | ||
task: | ||
secrets: | ||
- name: unsplash | ||
prologue: | ||
commands: | ||
- checkout | ||
- cache restore | ||
- cp .env.example .env | ||
- 'php artisan key:generate' | ||
jobs: | ||
- name: Integration Tests | ||
commands: | ||
- php vendor/bin/phpunit | ||
- name: Browser Tests | ||
commands: | ||
- 'php artisan dusk:chrome-driver' | ||
- php artisan serve --port=8021 & | ||
- php artisan dusk |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Tests\Browser; | ||
|
||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Laravel\Dusk\Browser; | ||
use Tests\DuskTestCase; | ||
|
||
class ExampleTest extends DuskTestCase | ||
{ | ||
/** | ||
* A basic browser test example. | ||
* | ||
* @return void | ||
*/ | ||
public function testBasicExample() | ||
{ | ||
$this->browse(function (Browser $browser) { | ||
$browser->visit('/') | ||
->assertTitle('Unsplash Image Gallery Demo'); | ||
}); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Tests\Browser\Pages; | ||
|
||
use Laravel\Dusk\Browser; | ||
|
||
class HomePage extends Page | ||
{ | ||
/** | ||
* Get the URL for the page. | ||
* | ||
* @return string | ||
*/ | ||
public function url() | ||
{ | ||
return '/'; | ||
} | ||
|
||
/** | ||
* Assert that the browser is on the page. | ||
* | ||
* @param \Laravel\Dusk\Browser $browser | ||
* @return void | ||
*/ | ||
public function assert(Browser $browser) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the element shortcuts for the page. | ||
* | ||
* @return array | ||
*/ | ||
public function elements() | ||
{ | ||
return [ | ||
'@element' => '#selector', | ||
]; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Tests\Browser\Pages; | ||
|
||
use Laravel\Dusk\Page as BasePage; | ||
|
||
abstract class Page extends BasePage | ||
{ | ||
/** | ||
* Get the global element shortcuts for the site. | ||
* | ||
* @return array | ||
*/ | ||
public static function siteElements() | ||
{ | ||
return [ | ||
'@element' => '#selector', | ||
]; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Facebook\WebDriver\Chrome\ChromeOptions; | ||
use Facebook\WebDriver\Remote\DesiredCapabilities; | ||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Laravel\Dusk\TestCase as BaseTestCase; | ||
|
||
abstract class DuskTestCase extends BaseTestCase | ||
{ | ||
use CreatesApplication; | ||
|
||
/** | ||
* Prepare for Dusk test execution. | ||
* | ||
* @beforeClass | ||
* @return void | ||
*/ | ||
public static function prepare() | ||
{ | ||
static::startChromeDriver(); | ||
} | ||
|
||
/** | ||
* Create the RemoteWebDriver instance. | ||
* | ||
* @return \Facebook\WebDriver\Remote\RemoteWebDriver | ||
*/ | ||
protected function driver() | ||
{ | ||
$options = (new ChromeOptions)->addArguments([ | ||
'--disable-gpu', | ||
'--headless', | ||
'--window-size=1920,1080', | ||
]); | ||
|
||
return RemoteWebDriver::create( | ||
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( | ||
ChromeOptions::CAPABILITY, $options | ||
) | ||
); | ||
} | ||
} |