Get Laravel Dusk installed using PhantomJS so it can work with Travis CI easily
This commit is contained in:
parent
db44423c2e
commit
94969e7f97
25 changed files with 314 additions and 1123 deletions
|
@ -38,9 +38,11 @@ before_script:
|
|||
- php artisan migrate
|
||||
- php artisan db:seed
|
||||
- php artisan token:generate
|
||||
- phantomjs --webserver=127.0.0.1:9515 &
|
||||
- php artisan serve &
|
||||
- sleep 5 # Give artisan some time to start serving
|
||||
|
||||
script:
|
||||
- phpdbg -qrr vendor/bin/phpunit --coverage-text
|
||||
- php artisan dusk
|
||||
- php artisan security:check
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Providers;
|
|||
use App\Tag;
|
||||
use App\Note;
|
||||
use Validator;
|
||||
use Laravel\Dusk\DuskServiceProvider;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
|
@ -54,6 +55,8 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
if ($this->app->environment('local', 'testing')) {
|
||||
$this->app->register(DuskServiceProvider::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,14 +29,12 @@
|
|||
"laravel/tinker": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": "~5.7",
|
||||
"symfony/css-selector": "3.1.*",
|
||||
"symfony/dom-crawler": "3.1.*",
|
||||
"barryvdh/laravel-debugbar": "~2.0",
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"jakub-onderka/php-parallel-lint": "^0.9.2",
|
||||
"laravel/browser-kit-testing": "^1.0"
|
||||
"laravel/dusk": "^1.0",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": "~5.7"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
@ -47,10 +45,9 @@
|
|||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/TestCase.php",
|
||||
"tests/BrowserKitTest.php"
|
||||
]
|
||||
"psr-4": {
|
||||
"Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-root-package-install": [
|
||||
|
|
249
composer.lock
generated
249
composer.lock
generated
|
@ -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": "16af842252275cac279c7f118ad6e6d4",
|
||||
"content-hash": "e4236aef74a9e56de4a85dc50bf32dcf",
|
||||
"packages": [
|
||||
{
|
||||
"name": "anahkiasen/underscore-php",
|
||||
|
@ -58,16 +58,16 @@
|
|||
},
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.22.4",
|
||||
"version": "3.22.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "916f708c1a643f86f74eacd3c5be787b40d814f8"
|
||||
"reference": "eea83aaac2b6c86f72a5c85c54d1839b70d4fd21"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/916f708c1a643f86f74eacd3c5be787b40d814f8",
|
||||
"reference": "916f708c1a643f86f74eacd3c5be787b40d814f8",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/eea83aaac2b6c86f72a5c85c54d1839b70d4fd21",
|
||||
"reference": "eea83aaac2b6c86f72a5c85c54d1839b70d4fd21",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -134,7 +134,7 @@
|
|||
"s3",
|
||||
"sdk"
|
||||
],
|
||||
"time": "2017-02-14T21:23:54+00:00"
|
||||
"time": "2017-02-17T20:09:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "barnabywalters/mf-cleaner",
|
||||
|
@ -3280,16 +3280,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "7a8405a9fc175f87fed8a3c40856b0d866d61936"
|
||||
"reference": "0e5e6899f82230fcb1153bcaf0e106ffaa44b870"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/7a8405a9fc175f87fed8a3c40856b0d866d61936",
|
||||
"reference": "7a8405a9fc175f87fed8a3c40856b0d866d61936",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/0e5e6899f82230fcb1153bcaf0e106ffaa44b870",
|
||||
"reference": "0e5e6899f82230fcb1153bcaf0e106ffaa44b870",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3339,20 +3339,20 @@
|
|||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-02-06T12:04:21+00:00"
|
||||
"time": "2017-02-16T14:07:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/css-selector",
|
||||
"version": "v3.1.10",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/css-selector.git",
|
||||
"reference": "722a87478a72d95dc2a3bcf41dc9c2d13fd4cb2d"
|
||||
"reference": "f0e628f04fc055c934b3211cfabdb1c59eefbfaa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/css-selector/zipball/722a87478a72d95dc2a3bcf41dc9c2d13fd4cb2d",
|
||||
"reference": "722a87478a72d95dc2a3bcf41dc9c2d13fd4cb2d",
|
||||
"url": "https://api.github.com/repos/symfony/css-selector/zipball/f0e628f04fc055c934b3211cfabdb1c59eefbfaa",
|
||||
"reference": "f0e628f04fc055c934b3211cfabdb1c59eefbfaa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3361,7 +3361,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
"dev-master": "3.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -3392,20 +3392,20 @@
|
|||
],
|
||||
"description": "Symfony CssSelector Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:31:54+00:00"
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/debug.git",
|
||||
"reference": "b4d9818f127c60ce21ed62c395da7df868dc8477"
|
||||
"reference": "9b98854cb45bc59d100b7d4cc4cf9e05f21026b9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/b4d9818f127c60ce21ed62c395da7df868dc8477",
|
||||
"reference": "b4d9818f127c60ce21ed62c395da7df868dc8477",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/9b98854cb45bc59d100b7d4cc4cf9e05f21026b9",
|
||||
"reference": "9b98854cb45bc59d100b7d4cc4cf9e05f21026b9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3449,11 +3449,11 @@
|
|||
],
|
||||
"description": "Symfony Debug Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-28T02:37:08+00:00"
|
||||
"time": "2017-02-16T16:34:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
|
@ -3513,7 +3513,7 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
|
@ -3562,16 +3562,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-foundation.git",
|
||||
"reference": "e192b04de44aa1ed0e39d6793f7e06f5e0b672a0"
|
||||
"reference": "a90da6dd679605d88c9803a57a6fc1fb7a19a6e0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e192b04de44aa1ed0e39d6793f7e06f5e0b672a0",
|
||||
"reference": "e192b04de44aa1ed0e39d6793f7e06f5e0b672a0",
|
||||
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/a90da6dd679605d88c9803a57a6fc1fb7a19a6e0",
|
||||
"reference": "a90da6dd679605d88c9803a57a6fc1fb7a19a6e0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3611,20 +3611,20 @@
|
|||
],
|
||||
"description": "Symfony HttpFoundation Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-02-02T13:47:35+00:00"
|
||||
"time": "2017-02-16T22:46:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-kernel",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-kernel.git",
|
||||
"reference": "96443239baf674b143604fb87cb27cb01672ab77"
|
||||
"reference": "4cd0d4bc31819095c6ef13573069f621eb321081"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/96443239baf674b143604fb87cb27cb01672ab77",
|
||||
"reference": "96443239baf674b143604fb87cb27cb01672ab77",
|
||||
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/4cd0d4bc31819095c6ef13573069f621eb321081",
|
||||
"reference": "4cd0d4bc31819095c6ef13573069f621eb321081",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3693,7 +3693,7 @@
|
|||
],
|
||||
"description": "Symfony HttpKernel Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-02-06T13:15:19+00:00"
|
||||
"time": "2017-02-16T23:59:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
|
@ -3756,16 +3756,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "32646a7cf53f3956c76dcb5c82555224ae321858"
|
||||
"reference": "0ab87c1e7570b3534a6e51eb4ca8e9f6d7327856"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/32646a7cf53f3956c76dcb5c82555224ae321858",
|
||||
"reference": "32646a7cf53f3956c76dcb5c82555224ae321858",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/0ab87c1e7570b3534a6e51eb4ca8e9f6d7327856",
|
||||
"reference": "0ab87c1e7570b3534a6e51eb4ca8e9f6d7327856",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3801,11 +3801,11 @@
|
|||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-02-03T12:11:38+00:00"
|
||||
"time": "2017-02-16T14:07:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/routing",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/routing.git",
|
||||
|
@ -3880,16 +3880,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation.git",
|
||||
"reference": "ca032cc56976d88b85e7386b17020bc6dc95dbc5"
|
||||
"reference": "d6825c6bb2f1da13f564678f9f236fe8242c0029"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/ca032cc56976d88b85e7386b17020bc6dc95dbc5",
|
||||
"reference": "ca032cc56976d88b85e7386b17020bc6dc95dbc5",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/d6825c6bb2f1da13f564678f9f236fe8242c0029",
|
||||
"reference": "d6825c6bb2f1da13f564678f9f236fe8242c0029",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3940,20 +3940,20 @@
|
|||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-21T17:06:35+00:00"
|
||||
"time": "2017-02-16T22:46:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "5bb4435a03a4f05c211f4a9a8ee2756965924511"
|
||||
"reference": "cb50260b674ee1c2d4ab49f2395a42e0b4681e20"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/5bb4435a03a4f05c211f4a9a8ee2756965924511",
|
||||
"reference": "5bb4435a03a4f05c211f4a9a8ee2756965924511",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/cb50260b674ee1c2d4ab49f2395a42e0b4681e20",
|
||||
"reference": "cb50260b674ee1c2d4ab49f2395a42e0b4681e20",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4003,7 +4003,7 @@
|
|||
"debug",
|
||||
"dump"
|
||||
],
|
||||
"time": "2017-01-24T12:58:58+00:00"
|
||||
"time": "2017-02-16T22:46:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "themattharris/tmhoauth",
|
||||
|
@ -4298,6 +4298,55 @@
|
|||
],
|
||||
"time": "2015-06-14T21:17:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "facebook/webdriver",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/php-webdriver.git",
|
||||
"reference": "77300c4ab2025d4316635f592ec849ca7323bd8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/facebook/php-webdriver/zipball/77300c4ab2025d4316635f592ec849ca7323bd8c",
|
||||
"reference": "77300c4ab2025d4316635f592ec849ca7323bd8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"php": "^5.5 || ~7.0",
|
||||
"symfony/process": "^2.8 || ^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^1.11",
|
||||
"php-mock/php-mock-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "4.6.* || ~5.0",
|
||||
"satooshi/php-coveralls": "^1.0",
|
||||
"squizlabs/php_codesniffer": "^2.6"
|
||||
},
|
||||
"suggest": {
|
||||
"phpdocumentor/phpdocumentor": "2.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Facebook\\WebDriver\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"description": "A PHP client for WebDriver",
|
||||
"homepage": "https://github.com/facebook/php-webdriver",
|
||||
"keywords": [
|
||||
"facebook",
|
||||
"php",
|
||||
"selenium",
|
||||
"webdriver"
|
||||
],
|
||||
"time": "2017-01-13T15:48:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fzaninotto/faker",
|
||||
"version": "v1.6.0",
|
||||
|
@ -4439,23 +4488,30 @@
|
|||
"time": "2015-12-15T10:42:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/browser-kit-testing",
|
||||
"version": "v1.0.3",
|
||||
"name": "laravel/dusk",
|
||||
"version": "v1.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/browser-kit-testing.git",
|
||||
"reference": "0adfb725147815bff5516d157577f375a6e66ebd"
|
||||
"url": "https://github.com/laravel/dusk.git",
|
||||
"reference": "804bf2ef20de7d86caac1aff433c761399b55e56"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/0adfb725147815bff5516d157577f375a6e66ebd",
|
||||
"reference": "0adfb725147815bff5516d157577f375a6e66ebd",
|
||||
"url": "https://api.github.com/repos/laravel/dusk/zipball/804bf2ef20de7d86caac1aff433c761399b55e56",
|
||||
"reference": "804bf2ef20de7d86caac1aff433c761399b55e56",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"symfony/css-selector": "~3.1",
|
||||
"symfony/dom-crawler": "~3.1"
|
||||
"facebook/webdriver": "~1.0",
|
||||
"illuminate/support": "~5.3",
|
||||
"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": {
|
||||
|
@ -4465,7 +4521,7 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\BrowserKitTesting\\": "src/"
|
||||
"Laravel\\Dusk\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -4478,12 +4534,13 @@
|
|||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Provides backwards compatibility for BrowserKit testing in Laravel 5.4.",
|
||||
"description": "Laravel Dusk provides simple end-to-end testing and browser automation.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"testing"
|
||||
"testing",
|
||||
"webdriver"
|
||||
],
|
||||
"time": "2017-02-08T22:32:37+00:00"
|
||||
"time": "2017-02-15T20:21:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
|
@ -5760,74 +5817,18 @@
|
|||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2016-10-03T07:35:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/dom-crawler",
|
||||
"version": "v3.1.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dom-crawler.git",
|
||||
"reference": "7eede2a901a19928494194f7d1815a77b9a473a0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/7eede2a901a19928494194f7d1815a77b9a473a0",
|
||||
"reference": "7eede2a901a19928494194f7d1815a77b9a473a0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/css-selector": "~2.8|~3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/css-selector": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\DomCrawler\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony DomCrawler Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-21T17:13:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v3.2.3",
|
||||
"version": "v3.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "e1718c6bf57e1efbb8793ada951584b2ab27775b"
|
||||
"reference": "9724c684646fcb5387d579b4bfaa63ee0b0c64c8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/e1718c6bf57e1efbb8793ada951584b2ab27775b",
|
||||
"reference": "e1718c6bf57e1efbb8793ada951584b2ab27775b",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/9724c684646fcb5387d579b4bfaa63ee0b0c64c8",
|
||||
"reference": "9724c684646fcb5387d579b4bfaa63ee0b0c64c8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5869,7 +5870,7 @@
|
|||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-21T17:06:35+00:00"
|
||||
"time": "2017-02-16T22:46:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
|
|
10
phpunit.xml
10
phpunit.xml
|
@ -9,16 +9,16 @@
|
|||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
<testsuite name="Feature Tests">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit Tests">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./app</directory>
|
||||
<exclude>
|
||||
<file>./app/Http/routes.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ArticlesTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `/blog` page returns the article, this
|
||||
* means the database is being hit.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArticlesPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/blog')
|
||||
->see('My New Blog');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `/blog/{year}` page returns the article, this
|
||||
* means the database is being hit.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArticlesYearPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/blog/2016')
|
||||
->see('My New Blog');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `/blog/{year}/{month}` page returns the article,
|
||||
* this means the database is being hit.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArticlesMonthPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/blog/2016/01')
|
||||
->see('My New Blog');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a single article page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSingleArticlePage()
|
||||
{
|
||||
$this->visit($this->appurl . '/blog/2016/01/my-new-blog')
|
||||
->see('My New Blog');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the RSS feed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRSSFeed()
|
||||
{
|
||||
$response = $this->call('GET', $this->appurl . '/feed');
|
||||
|
||||
$this->assertEquals('application/rss+xml', $response->headers->get('Content-Type'));
|
||||
}
|
||||
}
|
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('Jonny Barnes');
|
||||
});
|
||||
}
|
||||
}
|
40
tests/Browser/Pages/HomePage.php
Normal file
40
tests/Browser/Pages/HomePage.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?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.
|
||||
*
|
||||
* @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/screenshots/.gitignore
vendored
Normal file
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ContactsTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `/contacts` page and see if response is OK.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testContactsPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/contacts')
|
||||
->assertResponseOK();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test an individual contact page with default profile image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testContactPageWithDefaultPic()
|
||||
{
|
||||
$this->visit($this->appurl . '/contacts/tantek')
|
||||
->see('<img src="/assets/profile-images/default-image" alt="" class="u-photo">');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test an individual contact page with a specific profile image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testContactPageWithSpecificPic()
|
||||
{
|
||||
$this->visit($this->appurl . '/contacts/aaron')
|
||||
->see('<img src="/assets/profile-images/aaronparecki.com/image" alt="" class="u-photo">');
|
||||
}
|
||||
}
|
|
@ -1,17 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
|
||||
|
||||
abstract class BrowserKitTest extends BaseTestCase
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
* The base URL to use while testing the application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUrl = 'http://localhost';
|
||||
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
|
@ -20,9 +14,7 @@ abstract class BrowserKitTest extends BaseTestCase
|
|||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
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::phantomjs()
|
||||
);
|
||||
}
|
||||
}
|
22
tests/Feature/ExampleTest.php
Normal file
22
tests/Feature/ExampleTest.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class IndieAuthTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getAuthorizationEndpoint calls the correct service methods,
|
||||
* though these methods are actually mocked.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndieAuthServiceDiscoversEndpoint()
|
||||
{
|
||||
$service = new \App\Services\IndieAuthService();
|
||||
$client = new \IndieAuth\Client();
|
||||
$result = $service->getAuthorizationEndpoint($this->appurl, $client);
|
||||
$this->assertSame('https://indieauth.com/auth', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the Service build the correct redirect URL.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndieAuthServiceBuildRedirectURL()
|
||||
{
|
||||
$client = new \IndieAuth\Client();
|
||||
$service = new \App\Services\IndieAuthService();
|
||||
$result = $service->buildAuthorizationURL(
|
||||
'https://indieauth.com/auth',
|
||||
$this->appurl,
|
||||
$client
|
||||
);
|
||||
$this->assertSame(
|
||||
'https://indieauth.com/auth?me=',
|
||||
substr($result, 0, 30)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `start` method redirects to the client on error.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndieAuthControllerBeginAuthRedirectsToClientOnFail()
|
||||
{
|
||||
$response = $this->call('GET', $this->appurl . '/indieauth/start', ['me' => 'http://example.org']);
|
||||
$this->assertSame($this->appurl . '/micropub/create', $response->headers->get('Location'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Now we test the `start` method as a whole.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndieAuthControllerBeginAuthRedirectsToEndpoint()
|
||||
{
|
||||
$response = $this->call('GET', $this->appurl . '/indieauth/start', ['me' => $this->appurl]);
|
||||
$this->assertSame(
|
||||
'https://indieauth.com/auth?me=',
|
||||
substr($response->headers->get('Location'), 0, 30)
|
||||
);
|
||||
$response = null;
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Lcobucci\JWT\Builder;
|
||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class MicropubClientTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the client gets shown for an unauthorised request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testClientPageUnauthorised()
|
||||
{
|
||||
$this->visit($this->appurl . '/micropub/create')
|
||||
->see('IndieAuth');
|
||||
}
|
||||
|
||||
public function testClientPageRecentAuth()
|
||||
{
|
||||
$this->visit($this->appurl . '/micropub/create')
|
||||
->see($this->appurl);
|
||||
}
|
||||
|
||||
public function testClientCreatesNewNoteWithTag()
|
||||
{
|
||||
//in this test, the syndication targets are blank
|
||||
$faker = \Faker\Factory::create();
|
||||
$note = 'Fake note from #PHPUnit: ' . $faker->text;
|
||||
$this->visit($this->appurl . '/micropub/create')
|
||||
->type($note, 'content')
|
||||
->press('Submit');
|
||||
$this->seeInDatabase('notes', ['note' => $note]);
|
||||
$this->visit($this->appurl . '/notes/tagged/PHPUnit')
|
||||
->see('PHPUnit');
|
||||
//my client has made a request to my endpoint, which then adds
|
||||
//to the db, so database transaction don’t work
|
||||
//so lets manually delete the new entry
|
||||
//first, if we are using algolia, we need to delete it
|
||||
if (env('SCOUT_DRIVER') == 'algolia') {
|
||||
//we need to allow the index to update in order to query it
|
||||
sleep(2);
|
||||
$client = new \AlgoliaSearch\Client(env('ALGOLIA_APP_ID'), env('ALGOLIA_SECRET'));
|
||||
$index = $client->initIndex('notes');
|
||||
//here we query for the new note and tell algolia too delete it
|
||||
$res = $index->deleteByQuery('Fake note from');
|
||||
if ($res == 0) {
|
||||
//somehow the new not didn’t get deleted
|
||||
$this->fail('Didn’t delete the note from the index');
|
||||
}
|
||||
}
|
||||
$newNote = \App\Note::where('note', $note)->first();
|
||||
$newNote->forceDelete();
|
||||
}
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Lcobucci\JWT\Builder;
|
||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class MicropubTest extends BrowserKitTest
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
public function testMicropubRequestWithoutToken()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post');
|
||||
$this->assertResponseStatus(400);
|
||||
$this->seeJson(['error_description' => 'No token provided with request']);
|
||||
}
|
||||
|
||||
public function testMicropubRequestWithoutValidToken()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', [], [], [], ['HTTP_Authorization' => 'Bearer abc123']);
|
||||
$this->assertResponseStatus(400);
|
||||
$this->seeJson(['error_description' => 'The provided token did not pass validation']);
|
||||
}
|
||||
|
||||
public function testMicropubRequestWithValidToken()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', [], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$this->seeJson(['response' => 'token']);
|
||||
}
|
||||
|
||||
public function testMicropubRequestForSyndication()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'syndicate-to'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$this->seeJson(['uid' => 'https://twitter.com/jonnybarnes']);
|
||||
}
|
||||
|
||||
public function testMicropubRequestForNearbyPlacesThatExist()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'geo:53.5,-2.38'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$this->see('the-bridgewater-pub');
|
||||
}
|
||||
|
||||
public function testMicropubRequestForNearbyPlacesThatExistWithUncertaintyParameter()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'geo:53.5,-2.38;u=35'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$this->see('the-bridgewater-pub');
|
||||
}
|
||||
|
||||
public function testMicropubRequestForNearbyPlacesThatDoNotExist()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'geo:1.23,4.56'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$this->see('[]');
|
||||
}
|
||||
|
||||
public function testMicropubRequestForConfig()
|
||||
{
|
||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'config'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||
$this->seeJson(['uid' => 'https://twitter.com/jonnybarnes']);
|
||||
}
|
||||
|
||||
public function testMicropubRequestCreateNewNote()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$note = $faker->text;
|
||||
$this->call(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'h' => 'entry',
|
||||
'content' => $note
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||
);
|
||||
$this->seeInDatabase('notes', ['note' => $note]);
|
||||
}
|
||||
|
||||
public function testMicropubRequestCreateNewPlace()
|
||||
{
|
||||
$this->call(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'h' => 'card',
|
||||
'name' => 'The Barton Arms',
|
||||
'geo' => 'geo:53.4974,-2.3768'
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||
);
|
||||
$this->seeInDatabase('places', ['slug' => 'the-barton-arms']);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewNote()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$note = $faker->text;
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'content' => [$note],
|
||||
],
|
||||
],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||
)->seeJson([
|
||||
'response' => 'created'
|
||||
])->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewNoteWithoutToken()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$note = $faker->text;
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'content' => [$note],
|
||||
],
|
||||
]
|
||||
)->seeJson([
|
||||
'response' => 'error',
|
||||
'error' => 'no_token'
|
||||
])->assertResponseStatus(400);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewNoteWithInvalidToken()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$note = $faker->text;
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'content' => [$note],
|
||||
],
|
||||
],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getInvalidToken()]
|
||||
)->seeJson([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_token'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewPlace()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-card'],
|
||||
'properties' => [
|
||||
'name' => $faker->name,
|
||||
'geo' => 'geo:' . $faker->latitude . ',' . $faker->longitude
|
||||
],
|
||||
],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||
)->seeJson([
|
||||
'response' => 'created'
|
||||
])->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewPlaceWithoutToken()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'name' => $faker->name,
|
||||
'geo' => 'geo:' . $faker->latitude . ',' . $faker->longitude
|
||||
],
|
||||
]
|
||||
)->seeJson([
|
||||
'response' => 'error',
|
||||
'error' => 'no_token'
|
||||
])->assertResponseStatus(400);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewPlaceWithInvalidToken()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'name' => $faker->name,
|
||||
'geo' => 'geo:' . $faker->latitude . ',' . $faker->longitude
|
||||
],
|
||||
],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getInvalidToken()]
|
||||
)->seeJson([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_token'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testMicropubJSONRequestCreateNewPlaceWithUncertaintyParam()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$this->json(
|
||||
'POST',
|
||||
$this->appurl . '/api/post',
|
||||
[
|
||||
'type' => ['h-card'],
|
||||
'properties' => [
|
||||
'name' => $faker->name,
|
||||
'geo' => 'geo:' . $faker->latitude . ',' . $faker->longitude . ';u=35'
|
||||
],
|
||||
],
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||
)->seeJson([
|
||||
'response' => 'created'
|
||||
])->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
private function getToken()
|
||||
{
|
||||
$signer = new Sha256();
|
||||
$token = (new Builder())
|
||||
->set('client_id', 'https://quill.p3k.io')
|
||||
->set('me', 'https://jonnybarnes.localhost')
|
||||
->set('scope', 'post')
|
||||
->set('issued_at', time())
|
||||
->sign($signer, env('APP_KEY'))
|
||||
->getToken();
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
private function getInvalidToken()
|
||||
{
|
||||
$signer = new Sha256();
|
||||
$token = (new Builder())
|
||||
->set('client_id', 'https://quill.p3k.io')
|
||||
->set('me', 'https://jonnybarnes.localhost')
|
||||
->set('scope', 'view')
|
||||
->set('issued_at', time())
|
||||
->sign($signer, env('APP_KEY'))
|
||||
->getToken();
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class NotesAdminTest extends BrowserKitTest
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
protected $appurl;
|
||||
protected $notesAdminController;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
$this->notesAdminController = new \App\Http\Controllers\NotesAdminController();
|
||||
}
|
||||
|
||||
public function testCreatedNoteDispatchesSendWebmentionsJob()
|
||||
{
|
||||
$this->expectsJobs(\App\Jobs\SendWebMentions::class);
|
||||
|
||||
$this->withSession(['loggedin' => true])
|
||||
->visit($this->appurl . '/admin/note/new')
|
||||
->type('Mentioning', 'content')
|
||||
->press('Submit');
|
||||
}
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use Cache;
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class NotesTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
protected $notesController;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
$this->notesController = new \App\Http\Controllers\NotesController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `/notes` page returns 200, this should
|
||||
* mean the database is being hit.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNotesPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes')
|
||||
->assertResponseOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a specific note so that `singleNote()` get called.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSpecificNote()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/B')
|
||||
->see('#beer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that `/note/{decID}` redirects to `/notes/{nb60id}`.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDecIDRedirect()
|
||||
{
|
||||
$this->get($this->appurl . '/note/11')
|
||||
->assertRedirectedTo(config('app.url') . '/notes/B');
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit the tagged page and see text from the note.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTaggedNotesPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/tagged/beer')
|
||||
->see('at the local.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for a default image in the contact’s h-card.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDefaultImageUsed()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/C')
|
||||
->see('<img class="u-photo" alt="" src="/assets/profile-images/default-image">');
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for a specific profile image in the contact’s h-card.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testProfileImageUsed()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/D')
|
||||
->see('<img class="u-photo" alt="" src="/assets/profile-images/aaronparecki.com/image">');
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for twitter URL when there’s no associated contact.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTwitterLinkCreatedWhenNoContactFound()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/E')
|
||||
->see('<a href="https://twitter.com/bob">@bob</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test hashtag linking.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testHashtags()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/B')
|
||||
->see('<a rel="tag" class="p-category" href="/notes/tagged/beer">#beer</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the client name after the note.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testClientNameDisplayed()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/D')
|
||||
->see('JBL5');
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the client URL after the note.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testClientURLDisplayed()
|
||||
{
|
||||
$this->visit($this->appurl . '/notes/E')
|
||||
->see('quill.p3k.io');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a correct profile link is formed from a generic URL.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreatePhotoLinkWithNonCachedImage()
|
||||
{
|
||||
$homepage = 'https://example.org/profile.png';
|
||||
$expected = 'https://example.org/profile.png';
|
||||
$this->assertEquals($expected, $this->notesController->createPhotoLink($homepage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a correct profile link is formed from a generic URL.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreatePhotoLinkWithCachedImage()
|
||||
{
|
||||
$homepage = 'https://aaronparecki.com/profile.png';
|
||||
$expected = '/assets/profile-images/aaronparecki.com/image';
|
||||
$this->assertEquals($expected, $this->notesController->createPhotoLink($homepage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a correct profile link is formed from a twitter URL.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreatePhotoLinkWithTwimgProfileImageURL()
|
||||
{
|
||||
$twitterProfileImage = 'http://pbs.twimg.com/1234';
|
||||
$expected = 'https://pbs.twimg.com/1234';
|
||||
$this->assertEquals($expected, $this->notesController->createPhotoLink($twitterProfileImage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test `null` is returned for a twitter profile.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreatePhotoLinkWithCachedTwitterURL()
|
||||
{
|
||||
$twitterURL = 'https://twitter.com/example';
|
||||
$expected = 'https://pbs.twimg.com/static_profile_link.jpg';
|
||||
Cache::put($twitterURL, $expected, 1);
|
||||
$this->assertEquals($expected, $this->notesController->createPhotoLink($twitterURL));
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class PlacesTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the `/places` page for OK response.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPlacesPage()
|
||||
{
|
||||
$this->visit($this->appurl . '/places')
|
||||
->assertResponseOK();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a specific place.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSinglePlace()
|
||||
{
|
||||
$this->visit($this->appurl . '/places/the-bridgewater-pub')
|
||||
->see('The Bridgewater Pub');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the nearby method returns a collection.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNearbyMethod()
|
||||
{
|
||||
$nearby = \App\Place::near(53.5, -2.38, 1000);
|
||||
$this->assertEquals('the-bridgewater-pub', $nearby[0]->slug);
|
||||
}
|
||||
}
|
|
@ -1,25 +1,10 @@
|
|||
<?php
|
||||
|
||||
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* The base URL to use while testing the application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUrl = 'http://localhost';
|
||||
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
use CreatesApplication;
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class TokenServiceTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
$this->tokenService = new \App\Services\TokenService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the token is dependent on a random nonce, the time of creation and
|
||||
* the APP_KEY, to test, we shall create a token, and then verify it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTokenCreationAndValidation()
|
||||
{
|
||||
$data = [
|
||||
'me' => 'https://example.org',
|
||||
'client_id' => 'https://quill.p3k.io',
|
||||
'scope' => 'post'
|
||||
];
|
||||
$token = $this->tokenService->getNewToken($data);
|
||||
$valid = $this->tokenService->validateToken($token);
|
||||
$validData = [
|
||||
'me' => $valid->getClaim('me'),
|
||||
'client_id' => $valid->getClaim('client_id'),
|
||||
'scope' => $valid->getClaim('scope')
|
||||
];
|
||||
$this->assertSame($data, $validData);
|
||||
}
|
||||
}
|
20
tests/Unit/ExampleTest.php
Normal file
20
tests/Unit/ExampleTest.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use BrowserKitTest;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class WebMentionsTest extends BrowserKitTest
|
||||
{
|
||||
protected $appurl;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->appurl = config('app.url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test webmentions without source and target are rejected.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testWebmentionsWithoutSourceAndTargetAreRejected()
|
||||
{
|
||||
$this->call('POST', $this->appurl . '/webmention', ['source' => 'https://example.org/post/123']);
|
||||
$this->assertResponseStatus(400)
|
||||
->see('You need both the target and source parameters');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test invalid target gets a 400 response.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTargetReturns400Response()
|
||||
{
|
||||
$this->call('POST', $this->appurl . '/webmention', [
|
||||
'source' => 'https://example.org/post/123',
|
||||
'target' => $this->appurl . '/invalid/target'
|
||||
]);
|
||||
$this->assertResponseStatus(400)
|
||||
->see('Invalid request');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test blog target gets a 501 response.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBlogpostTargetReturns501Response()
|
||||
{
|
||||
$this->call('POST', $this->appurl . '/webmention', [
|
||||
'source' => 'https://example.org/post/123',
|
||||
'target' => $this->appurl . '/blog/target'
|
||||
]);
|
||||
$this->assertResponseStatus(501)
|
||||
->see('I don’t accept webmentions for blog posts yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a non-existant note gives a 400 response.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNonexistantNoteReturns400Response()
|
||||
{
|
||||
$this->call('POST', $this->appurl . '/webmention', [
|
||||
'source' => 'https://example.org/post/123',
|
||||
'target' => $this->appurl . '/notes/ZZZZZ'
|
||||
]);
|
||||
$this->assertResponseStatus(400)
|
||||
->see('This note doesn’t exist.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a legit webmention triggers the ProcessWebMention job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLegitimateWebmnetionTriggersProcessWebMentionJob()
|
||||
{
|
||||
$this->expectsJobs(\App\Jobs\ProcessWebMention::class);
|
||||
$this->call('POST', $this->appurl . '/webmention', [
|
||||
'source' => 'https://example.org/post/123',
|
||||
'target' => $this->appurl . '/notes/B'
|
||||
]);
|
||||
$this->assertResponseStatus(202)
|
||||
->see('Webmention received, it will be processed shortly');
|
||||
}
|
||||
}
|
BIN
tests/aaron.png
BIN
tests/aaron.png
Binary file not shown.
Before Width: | Height: | Size: 6.4 KiB |
Loading…
Add table
Reference in a new issue