Implement Laravel Dusk and write test for attempting to log in with invalid credentials
MODIFY
composer.json
composer.json
"laravel/tinker": "~1.0"
},
"require-dev": {
+ "filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
+ "laravel/dusk": "^4.0",
"mockery/mockery": "0.9.*",
- "phpunit/phpunit": "^7.0",
- "filp/whoops": "~2.0"
+ "phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [

MODIFY
composer.lock
composer.lock
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "cd90e30e038eaf1543241ccaf4d035b1",
+ "content-hash": "2c085eaf85237124c4cf71c8d6a414ec",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
],
"time": "2017-07-22T11:58:36+00:00"
},
+ {
+ "name": "facebook/webdriver",
+ "version": "1.6.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/facebook/php-webdriver.git",
+ "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bd8c740097eb9f2fc3735250fc1912bc811a954e",
+ "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "ext-zip": "*",
+ "php": "^5.6 || ~7.0",
+ "symfony/process": "^2.8 || ^3.1 || ^4.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^2.0",
+ "jakub-onderka/php-parallel-lint": "^0.9.2",
+ "php-coveralls/php-coveralls": "^2.0",
+ "php-mock/php-mock-phpunit": "^1.1",
+ "phpunit/phpunit": "^5.7",
+ "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0",
+ "squizlabs/php_codesniffer": "^2.6",
+ "symfony/var-dumper": "^3.3 || ^4.0"
+ },
+ "suggest": {
+ "ext-SimpleXML": "For Firefox profile creation"
+ },
+ "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": "2018-05-16T17:37:13+00:00"
+ },
{
"name": "filp/whoops",
"version": "2.2.0",
],
"time": "2015-05-11T14:41:42+00:00"
},
+ {
+ "name": "laravel/dusk",
+ "version": "v4.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/laravel/dusk.git",
+ "reference": "9810f8609c8b53d9a3bac7d38c56530e0d77a6bb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/laravel/dusk/zipball/9810f8609c8b53d9a3bac7d38c56530e0d77a6bb",
+ "reference": "9810f8609c8b53d9a3bac7d38c56530e0d77a6bb",
+ "shasum": ""
+ },
+ "require": {
+ "facebook/webdriver": "~1.3",
+ "illuminate/console": "~5.6",
+ "illuminate/support": "~5.6",
+ "nesbot/carbon": "~1.20",
+ "php": ">=7.1.0",
+ "symfony/console": "~4.0",
+ "symfony/process": "~4.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "~1.0",
+ "phpunit/phpunit": "~7.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Laravel\\Dusk\\DuskServiceProvider"
+ ]
+ }
+ },
+ "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": "2018-10-03T15:37:05+00:00"
+ },
{
"name": "mockery/mockery",
"version": "0.9.9",

ADD
tests/Browser/ExampleTest.php
+<?php
+
+namespace Tests\Browser;
+
+use Tests\DuskTestCase;
+use Laravel\Dusk\Browser;
+use Illuminate\Foundation\Testing\DatabaseMigrations;
+
+class ExampleTest extends DuskTestCase {
+ public function testBasicExample() {
+ $this->browse(function (Browser $browser) {
+ $browser->visit('/login')
+ ->type('email', 'johnd@gmail.com')
+ ->type('password', 'doe123')
+ ->press('Log in')
+ ->assertPathIs('/login');
+ });
+ }
+}

ADD
tests/Browser/Pages/HomePage.php
+<?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',
+ ];
+ }
+}

ADD
tests/Browser/Pages/Page.php
+<?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',
+ ];
+ }
+}

ADD
tests/Browser/console/.gitignore
+*
+!.gitignore

ADD
tests/Browser/screenshots/.gitignore
+*
+!.gitignore

ADD
tests/DuskTestCase.php
+<?php
+
+namespace Tests;
+
+use Laravel\Dusk\TestCase as BaseTestCase;
+use Facebook\WebDriver\Chrome\ChromeOptions;
+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()
+ {
+ $options = (new ChromeOptions)->addArguments([
+ '--disable-gpu',
+ '--headless'
+ ]);
+
+ return RemoteWebDriver::create(
+ 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
+ ChromeOptions::CAPABILITY, $options
+ )
+ );
+ }
+}

Implement Laravel Dusk and write test for attempting to log in with invalid credentials