From a3cce90c106fa2494f9a25168030a28584392402 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Wed, 6 Sep 2017 14:54:02 +0100 Subject: [PATCH] Clean code to take advantage of new L5.5 features, bring back some dusk tests now we can use headless chrome. Squashed commit of the following: commit d32d6e9dca7eb26303435c738f7c547e5009b86b Author: Jonny Barnes Date: Wed Sep 6 14:43:52 2017 +0100 Add dusk tests, cleanup other parts of travis.yml commit 7633b407ee222a3f4a222f889f23acf4b5549c22 Author: Jonny Barnes Date: Wed Sep 6 14:38:39 2017 +0100 I think dusk works locally with headless chrome now, just struggling on my slow laptop commit fcbc83bb0a53ac046c1af09e8caf296799a940ef Author: Jonny Barnes Date: Tue Sep 5 15:47:39 2017 +0100 Get latest package versions and remove un-needed service provider entries --- .travis.yml | 13 +--- composer.json | 4 +- composer.lock | 102 ++++++++++++++++----------- config/app.php | 30 -------- tests/Browser/ArticlesTest.php | 61 ---------------- tests/Browser/ExampleTest.php | 2 +- tests/Browser/MicropubClientTest.php | 8 +-- tests/DuskTestCase.php | 15 +++- 8 files changed, 85 insertions(+), 150 deletions(-) delete mode 100644 tests/Browser/ArticlesTest.php diff --git a/.travis.yml b/.travis.yml index 22ea860e..73a029f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ cache: - apt addons: + chrome: stable postgresql: "9.6" apt: sources: @@ -38,10 +39,6 @@ before_install: - echo 'error_log = "/tmp/php.error.log"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - psql -U travis -c 'create database travis_ci_test' - psql -U travis -d travis_ci_test -c 'create extension postgis' - - mkdir travis-phantomjs - - wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 - - tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs - - export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH - travis_retry composer self-update --preview install: @@ -55,14 +52,10 @@ before_script: - php artisan migrate - php artisan db:seed - php artisan token:generate - - phantomjs --webdriver=127.0.0.1:9515 --webdriver-loglevel=DEBUG & + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9515 http://localhost:8000 & - sleep 5 # Give artisan some time to start serving script: - php vendor/bin/phpunit --coverage-text + - php artisan dusk - php vendor/bin/security-checker security:check ./composer.lock --end-point=http://security.sensiolabs.org/check_lock - -after_script: - - killall -9 postgresql - - killall -9 php-fpm - - killall -9 nginx \ No newline at end of file diff --git a/composer.json b/composer.json index 0ce0e505..8d47a8aa 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "type": "project", "require": { "php": ">=7.1.0", - "cviebrock/eloquent-sluggable": "^4.2", + "cviebrock/eloquent-sluggable": "~4.3", "ezyang/htmlpurifier": "~4.6", "fideloper/proxy": "~3.3", "guzzlehttp/guzzle": "~6.0", @@ -30,7 +30,7 @@ "thujohn/twitter": "~2.0" }, "require-dev": { - "barryvdh/laravel-debugbar": "~2.0", + "barryvdh/laravel-debugbar": "~3.0", "filp/whoops": "~2.0", "fzaninotto/faker": "~1.4", "jakub-onderka/php-parallel-lint": "^0.9.2", diff --git a/composer.lock b/composer.lock index 0b207e1a..eb655eca 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "487a60aad9e8139562d491c207a9b64b", + "content-hash": "4aa8e5b3bd31788aff471c6f0f650cd7", "packages": [ { "name": "aws/aws-sdk-php", @@ -182,16 +182,16 @@ }, { "name": "cocur/slugify", - "version": "v2.5", + "version": "v3.0", "source": { "type": "git", "url": "https://github.com/cocur/slugify.git", - "reference": "e8167e9a3236044afebd6e8ab13ebeb3ec9ca145" + "reference": "122998753e980d0223eea0bb957102a457a13bc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cocur/slugify/zipball/e8167e9a3236044afebd6e8ab13ebeb3ec9ca145", - "reference": "e8167e9a3236044afebd6e8ab13ebeb3ec9ca145", + "url": "https://api.github.com/repos/cocur/slugify/zipball/122998753e980d0223eea0bb957102a457a13bc1", + "reference": "122998753e980d0223eea0bb957102a457a13bc1", "shasum": "" }, "require": { @@ -242,7 +242,7 @@ "slug", "slugify" ], - "time": "2017-03-23T21:52:55+00:00" + "time": "2017-08-11T20:28:15+00:00" }, { "name": "composer/ca-bundle", @@ -305,30 +305,30 @@ }, { "name": "cviebrock/eloquent-sluggable", - "version": "4.2.4", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/cviebrock/eloquent-sluggable.git", - "reference": "ae888987b7ee72366b44caf579861de99e3e8d42" + "reference": "2407515c00bd4148c6ce8156f5f82e1a6349cac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cviebrock/eloquent-sluggable/zipball/ae888987b7ee72366b44caf579861de99e3e8d42", - "reference": "ae888987b7ee72366b44caf579861de99e3e8d42", + "url": "https://api.github.com/repos/cviebrock/eloquent-sluggable/zipball/2407515c00bd4148c6ce8156f5f82e1a6349cac3", + "reference": "2407515c00bd4148c6ce8156f5f82e1a6349cac3", "shasum": "" }, "require": { - "cocur/slugify": "^2.3", - "illuminate/config": "^5.4", - "illuminate/database": "^5.4", - "illuminate/support": "^5.4", - "php": ">=5.6.4 || ^7.0" + "cocur/slugify": "^3.0", + "illuminate/config": "~5.5.0", + "illuminate/database": "~5.5.0", + "illuminate/support": "~5.5.0", + "php": "^7.0" }, "require-dev": { "mockery/mockery": "^0.9.4", - "orchestra/database": "~3.4", - "orchestra/testbench": "^3.4", - "phpunit/phpunit": "~5.7" + "orchestra/database": "~3.5.0", + "orchestra/testbench": "~3.5.0", + "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { @@ -357,10 +357,13 @@ "homepage": "https://github.com/cviebrock/eloquent-sluggable", "keywords": [ "eloquent", + "eloquent-sluggable", "laravel", - "slug" + "lumen", + "slug", + "sluggable" ], - "time": "2017-07-04T14:15:50+00:00" + "time": "2017-08-31T18:16:01+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -1755,16 +1758,16 @@ }, { "name": "laravel/framework", - "version": "v5.5.1", + "version": "v5.5.2", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "fad090f6e14b97df91489803644ac88b5321864e" + "reference": "65da63c8ad4836e2bcddcff75becd49c71c5041c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/fad090f6e14b97df91489803644ac88b5321864e", - "reference": "fad090f6e14b97df91489803644ac88b5321864e", + "url": "https://api.github.com/repos/laravel/framework/zipball/65da63c8ad4836e2bcddcff75becd49c71c5041c", + "reference": "65da63c8ad4836e2bcddcff75becd49c71c5041c", "shasum": "" }, "require": { @@ -1883,7 +1886,7 @@ "framework", "laravel" ], - "time": "2017-09-01T06:33:38+00:00" + "time": "2017-09-04T14:09:04+00:00" }, { "name": "laravel/scout", @@ -4206,25 +4209,44 @@ "packages-dev": [ { "name": "barryvdh/laravel-debugbar", - "version": "v2.4.3", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903" + "reference": "bce341e3194bbeffa60ac782d645067557f5075e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d7c88f08131f6404cb714f3f6cf0642f6afa3903", - "reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/bce341e3194bbeffa60ac782d645067557f5075e", + "reference": "bce341e3194bbeffa60ac782d645067557f5075e", "shasum": "" }, "require": { - "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*", - "maximebf/debugbar": "~1.13.0", - "php": ">=5.5.9", - "symfony/finder": "~2.7|~3.0" + "illuminate/routing": "5.5.x", + "illuminate/session": "5.5.x", + "illuminate/support": "5.5.x", + "maximebf/debugbar": "~1.14.0", + "php": ">=7.0", + "symfony/debug": "^3", + "symfony/finder": "^3" + }, + "require-dev": { + "illuminate/framework": "5.5.x" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facade" + } + } + }, "autoload": { "psr-4": { "Barryvdh\\Debugbar\\": "src/" @@ -4251,7 +4273,7 @@ "profiler", "webprofiler" ], - "time": "2017-07-21T11:56:48+00:00" + "time": "2017-08-29T08:54:25+00:00" }, { "name": "doctrine/instantiator", @@ -4625,16 +4647,16 @@ }, { "name": "maximebf/debugbar", - "version": "1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "afee79a236348e39a44cb837106b7c5b4897ac2a" + "reference": "e23a98f2d65607d8aa6c7b409a513f8fdf4acdde" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/afee79a236348e39a44cb837106b7c5b4897ac2a", - "reference": "afee79a236348e39a44cb837106b7c5b4897ac2a", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/e23a98f2d65607d8aa6c7b409a513f8fdf4acdde", + "reference": "e23a98f2d65607d8aa6c7b409a513f8fdf4acdde", "shasum": "" }, "require": { @@ -4653,7 +4675,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4682,7 +4704,7 @@ "debug", "debugbar" ], - "time": "2017-01-05T08:46:19+00:00" + "time": "2017-08-17T07:17:00+00:00" }, { "name": "mockery/mockery", diff --git a/config/app.php b/config/app.php index 878fd662..0fe15e72 100644 --- a/config/app.php +++ b/config/app.php @@ -206,41 +206,11 @@ return [ App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, - /* - * Laravel Debugbar - */ - Barryvdh\Debugbar\ServiceProvider::class, - /* * Thujohn’s Twitter API client */ Thujohn\Twitter\TwitterServiceProvider::class, - /* - * Phaza’s Postgis library - */ - Phaza\LaravelPostgis\DatabaseServiceProvider::class, - - /* - * Laravel scout - */ - Laravel\Scout\ScoutServiceProvider::class, - - /* - * Postgres Engine for Scout - */ - ScoutEngines\Postgres\PostgresEngineServiceProvider::class, - - /* - * Laravel Tinker - */ - Laravel\Tinker\TinkerServiceProvider::class, - - /* - * Eolquent Sluggable - */ - Cviebrock\EloquentSluggable\ServiceProvider::class, - ], /* diff --git a/tests/Browser/ArticlesTest.php b/tests/Browser/ArticlesTest.php deleted file mode 100644 index 2bb7cba2..00000000 --- a/tests/Browser/ArticlesTest.php +++ /dev/null @@ -1,61 +0,0 @@ -browse(function ($browser) { - $browser->visit('/blog') - ->assertSee('My New Blog'); - }); - } - - /** - * Test the `/blog` page with a year scoping results. - * - * @return void - */ - public function test_articles_page_with_specified_year() - { - $this->browse(function ($browser) { - $browser->visit('/blog/2016') - ->assertSee('My New Blog'); - }); - } - - /** - * Test the `/blog` page with a year and month scoping results. - * - * @return void - */ - public function test_articles_page_with_specified_year_and_month() - { - $this->browse(function ($browser) { - $browser->visit('/blog/2016/01') - ->assertSee('My New Blog'); - }); - } - - /** - * Test a single article page. - * - * @return void - */ - public function test_single_article_page() - { - $this->browse(function ($browser) { - $browser->visit('/blog/2016/01/my-new-blog') - ->assertSee('My New Blog'); - }); - } -} diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php index 5430fc54..a0099346 100644 --- a/tests/Browser/ExampleTest.php +++ b/tests/Browser/ExampleTest.php @@ -13,7 +13,7 @@ class ExampleTest extends DuskTestCase * * @return void */ - public function testBasicExample() + public function test_basic_example() { $this->browse(function (Browser $browser) { $browser->visit('/') diff --git a/tests/Browser/MicropubClientTest.php b/tests/Browser/MicropubClientTest.php index 120b5e41..453c0807 100644 --- a/tests/Browser/MicropubClientTest.php +++ b/tests/Browser/MicropubClientTest.php @@ -16,7 +16,7 @@ class MicropubClientTest extends DuskTestCase { $this->browse(function ($browser) { $browser->visit(route('micropub-client')) - ->assertSee('You are authenticated'); + ->assertSee('You are authenticated as'); }); } @@ -26,10 +26,10 @@ class MicropubClientTest extends DuskTestCase $faker = \Faker\Factory::create(); $note = 'Fake note from #LaravelDusk: ' . $faker->text; $this->browse(function ($browser) use ($note) { - $browser->visit(route('micropub-client')) + $response = $browser->visit(route('micropub-client')) ->assertSeeLink('log out') - ->type('content', $note) - ->press('Submit'); + ->type('content', $note); + $response->element('form')->submit(); }); sleep(2); $this->assertDatabaseHas('notes', ['note' => $note]); diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index 6b71b600..cbd48bb8 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -3,6 +3,7 @@ namespace Tests; use Laravel\Dusk\TestCase as BaseTestCase; +use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; @@ -18,7 +19,7 @@ abstract class DuskTestCase extends BaseTestCase */ public static function prepare() { - //static::startChromeDriver(); + static::startChromeDriver(); } /** @@ -28,8 +29,18 @@ abstract class DuskTestCase extends BaseTestCase */ protected function driver() { + $desiredCapabilities = DesiredCapabilities::chrome(); + + $options = new ChromeOptions(); + $options->addArguments([ + 'headless', + 'disable-gpu' + ]); + + $desiredCapabilities->setCapability(ChromeOptions::CAPABILITY, $options); + return RemoteWebDriver::create( - 'http://localhost:9515', DesiredCapabilities::phantomjs() + 'http://localhost:9515', $desiredCapabilities ); } }