mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
101 - Getting Started with Laravel Dusk
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@
|
|||||||
Homestead.json
|
Homestead.json
|
||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
.env
|
.env
|
||||||
|
.env.dusk.local
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\TicketCodeGenerator;
|
|||||||
use App\Billing\PaymentGateway;
|
use App\Billing\PaymentGateway;
|
||||||
use App\HashidsTicketCodeGenerator;
|
use App\HashidsTicketCodeGenerator;
|
||||||
use App\Billing\StripePaymentGateway;
|
use App\Billing\StripePaymentGateway;
|
||||||
|
use Laravel\Dusk\DuskServiceProvider;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use App\OrderConfirmationNumberGenerator;
|
use App\OrderConfirmationNumberGenerator;
|
||||||
use App\RandomOrderConfirmationNumberGenerator;
|
use App\RandomOrderConfirmationNumberGenerator;
|
||||||
@@ -29,6 +30,10 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
if ($this->app->environment('local', 'testing')) {
|
||||||
|
$this->app->register(DuskServiceProvider::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->app->bind(StripePaymentGateway::class, function () {
|
$this->app->bind(StripePaymentGateway::class, function () {
|
||||||
return new StripePaymentGateway(config('services.stripe.secret'));
|
return new StripePaymentGateway(config('services.stripe.secret'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
"zondicons/blade-bridge": "^0.1.0",
|
"zondicons/blade-bridge": "^0.1.0",
|
||||||
"stripe/stripe-php": "^4.3",
|
"stripe/stripe-php": "^4.3",
|
||||||
"guzzlehttp/guzzle": "^6.2",
|
"guzzlehttp/guzzle": "^6.2",
|
||||||
"hashids/hashids": "^2.0"
|
"hashids/hashids": "^2.0",
|
||||||
|
"laravel/dusk": "^1.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
|
|||||||
112
composer.lock
generated
112
composer.lock
generated
@@ -4,8 +4,8 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "94fd2c7211ef4aa80724947e13ba4651",
|
"hash": "7cbaa1ad75bde284c40bd5c43c2329c7",
|
||||||
"content-hash": "caee9b77188f151d418e434e7e9e9f21",
|
"content-hash": "2ebfbcd062d6383b3b54cc0757b1eacf",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/inflector",
|
"name": "doctrine/inflector",
|
||||||
@@ -116,6 +116,58 @@
|
|||||||
],
|
],
|
||||||
"time": "2017-03-29 16:04:15"
|
"time": "2017-03-29 16:04:15"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "facebook/webdriver",
|
||||||
|
"version": "1.4.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/facebook/php-webdriver.git",
|
||||||
|
"reference": "eadb0b7a7c3e6578185197fd40158b08c3164c83"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/facebook/php-webdriver/zipball/eadb0b7a7c3e6578185197fd40158b08c3164c83",
|
||||||
|
"reference": "eadb0b7a7c3e6578185197fd40158b08c3164c83",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
|
"php": "^5.5 || ~7.0",
|
||||||
|
"symfony/process": "^2.8 || ^3.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^2.0",
|
||||||
|
"php-mock/php-mock-phpunit": "^1.1",
|
||||||
|
"phpunit/phpunit": "4.6.* || ~5.0",
|
||||||
|
"satooshi/php-coveralls": "^1.0",
|
||||||
|
"squizlabs/php_codesniffer": "^2.6"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-community": "1.5-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Facebook\\WebDriver\\": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"Apache-2.0"
|
||||||
|
],
|
||||||
|
"description": "A PHP client for Selenium WebDriver",
|
||||||
|
"homepage": "https://github.com/facebook/php-webdriver",
|
||||||
|
"keywords": [
|
||||||
|
"facebook",
|
||||||
|
"php",
|
||||||
|
"selenium",
|
||||||
|
"webdriver"
|
||||||
|
],
|
||||||
|
"time": "2017-04-28 14:54:49"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
"version": "6.2.3",
|
"version": "6.2.3",
|
||||||
@@ -357,6 +409,62 @@
|
|||||||
],
|
],
|
||||||
"time": "2017-01-01 13:33:33"
|
"time": "2017-01-01 13:33:33"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "laravel/dusk",
|
||||||
|
"version": "v1.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/laravel/dusk.git",
|
||||||
|
"reference": "6b81e97ae1ce384e3d8dbd020b2b9751c1449889"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/laravel/dusk/zipball/6b81e97ae1ce384e3d8dbd020b2b9751c1449889",
|
||||||
|
"reference": "6b81e97ae1ce384e3d8dbd020b2b9751c1449889",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"facebook/webdriver": "~1.0",
|
||||||
|
"illuminate/console": "~5.4",
|
||||||
|
"illuminate/support": "~5.4",
|
||||||
|
"nesbot/carbon": "~1.20",
|
||||||
|
"php": ">=5.6.4",
|
||||||
|
"symfony/console": "~3.2",
|
||||||
|
"symfony/process": "~3.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^0.9.6",
|
||||||
|
"phpunit/phpunit": "^5.7"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Laravel\\Dusk\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylor@laravel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Laravel Dusk provides simple end-to-end testing and browser automation.",
|
||||||
|
"keywords": [
|
||||||
|
"laravel",
|
||||||
|
"testing",
|
||||||
|
"webdriver"
|
||||||
|
],
|
||||||
|
"time": "2017-04-23 17:13:04"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/framework",
|
"name": "laravel/framework",
|
||||||
"version": "v5.4.16",
|
"version": "v5.4.16",
|
||||||
|
|||||||
@@ -11,6 +11,10 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Route::get('/', function () {
|
||||||
|
return "Laravel";
|
||||||
|
});
|
||||||
|
|
||||||
Route::get('/concerts/{id}', 'ConcertsController@show');
|
Route::get('/concerts/{id}', 'ConcertsController@show');
|
||||||
Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store');
|
Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store');
|
||||||
Route::get('/orders/{confirmationNumber}', 'OrdersController@show');
|
Route::get('/orders/{confirmationNumber}', 'OrdersController@show');
|
||||||
|
|||||||
23
tests/Browser/ExampleTest.php
Normal file
23
tests/Browser/ExampleTest.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Browser;
|
||||||
|
|
||||||
|
use Tests\DuskTestCase;
|
||||||
|
use Laravel\Dusk\Browser;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
|
|
||||||
|
class ExampleTest extends DuskTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A basic browser test example.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBasicExample()
|
||||||
|
{
|
||||||
|
$this->browse(function (Browser $browser) {
|
||||||
|
$browser->visit('/')
|
||||||
|
->assertSee('Laravel');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
41
tests/Browser/Pages/HomePage.php
Normal file
41
tests/Browser/Pages/HomePage.php
Normal file
@@ -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 Browser $browser
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function assert(Browser $browser)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the element shortcuts for the page.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function elements()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'@element' => '#selector',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
20
tests/Browser/Pages/Page.php
Normal file
20
tests/Browser/Pages/Page.php
Normal file
@@ -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',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
2
tests/Browser/console/.gitignore
vendored
Normal file
2
tests/Browser/console/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
35
tests/DuskTestCase.php
Normal file
35
tests/DuskTestCase.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||||
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||||
|
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
return RemoteWebDriver::create(
|
||||||
|
'http://localhost:9515', DesiredCapabilities::chrome()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user