Removed browserkit testing from project

Converted last bits of the roles tests and removed dependancies.
Updated other PHP dependancies at the same time.
This commit is contained in:
Dan Brown 2021-09-18 21:15:39 +01:00
parent d74255df5d
commit 6454e24657
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
4 changed files with 423 additions and 600 deletions

View File

@ -20,7 +20,7 @@
"facade/ignition": "^1.16.4",
"fideloper/proxy": "^4.4.1",
"intervention/image": "^2.5.1",
"laravel/framework": "^6.20.16",
"laravel/framework": "^6.20.33",
"laravel/socialite": "^5.1",
"league/commonmark": "^1.5",
"league/flysystem-aws-s3-v3": "^1.0.29",
@ -41,9 +41,9 @@
"barryvdh/laravel-debugbar": "^3.5.1",
"barryvdh/laravel-ide-helper": "^2.8.2",
"fakerphp/faker": "^1.13.0",
"laravel/browser-kit-testing": "^5.2",
"mockery/mockery": "^1.3.3",
"phpunit/phpunit": "^9.5.3"
"phpunit/phpunit": "^9.5.3",
"symfony/dom-crawler": "^5.3"
},
"autoload": {
"classmap": [

342
composer.lock generated
View File

@ -4,23 +4,74 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4d845f3c8b77c8d73bf92c9223ddd805",
"content-hash": "10825887b8f66d1d412b92bcc0ca864f",
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.191.8",
"name": "aws/aws-crt-php",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "949feb83cc0db46f07b12aa3128d47be3b9cca63"
"url": "https://github.com/awslabs/aws-crt-php.git",
"reference": "3942776a8c99209908ee0b287746263725685732"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/949feb83cc0db46f07b12aa3128d47be3b9cca63",
"reference": "949feb83cc0db46f07b12aa3128d47be3b9cca63",
"url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/3942776a8c99209908ee0b287746263725685732",
"reference": "3942776a8c99209908ee0b287746263725685732",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35|^5.4.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "AWS SDK Common Runtime Team",
"email": "aws-sdk-common-runtime@amazon.com"
}
],
"description": "AWS Common Runtime for PHP",
"homepage": "http://aws.amazon.com/sdkforphp",
"keywords": [
"amazon",
"aws",
"crt",
"sdk"
],
"support": {
"issues": "https://github.com/awslabs/aws-crt-php/issues",
"source": "https://github.com/awslabs/aws-crt-php/tree/v1.0.2"
},
"time": "2021-09-03T22:57:30+00:00"
},
{
"name": "aws/aws-sdk-php",
"version": "3.194.1",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "67bdee05acef9e8ad60098090996690b49babd09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/67bdee05acef9e8ad60098090996690b49babd09",
"reference": "67bdee05acef9e8ad60098090996690b49babd09",
"shasum": ""
},
"require": {
"aws/aws-crt-php": "^1.0.2",
"ext-json": "*",
"ext-pcre": "*",
"ext-simplexml": "*",
@ -92,9 +143,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.191.8"
"source": "https://github.com/aws/aws-sdk-php/tree/3.194.1"
},
"time": "2021-08-31T18:18:02+00:00"
"time": "2021-09-17T18:15:42+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -428,16 +479,16 @@
},
{
"name": "doctrine/dbal",
"version": "2.13.2",
"version": "2.13.3",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4"
"reference": "0d7adf4cadfee6f70850e5b163e6cdd706417838"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/8dd39d2ead4409ce652fd4f02621060f009ea5e4",
"reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/0d7adf4cadfee6f70850e5b163e6cdd706417838",
"reference": "0d7adf4cadfee6f70850e5b163e6cdd706417838",
"shasum": ""
},
"require": {
@ -449,13 +500,14 @@
},
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"jetbrains/phpstorm-stubs": "2020.2",
"phpstan/phpstan": "0.12.81",
"jetbrains/phpstorm-stubs": "2021.1",
"phpstan/phpstan": "0.12.96",
"phpunit/phpunit": "^7.5.20|^8.5|9.5.5",
"psalm/plugin-phpunit": "0.16.1",
"squizlabs/php_codesniffer": "3.6.0",
"symfony/cache": "^4.4",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
"vimeo/psalm": "4.6.4"
"vimeo/psalm": "4.10.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@ -516,7 +568,7 @@
],
"support": {
"issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/2.13.2"
"source": "https://github.com/doctrine/dbal/tree/2.13.3"
},
"funding": [
{
@ -532,7 +584,7 @@
"type": "tidelift"
}
],
"time": "2021-06-18T21:48:39+00:00"
"time": "2021-09-12T19:11:48+00:00"
},
{
"name": "doctrine/deprecations",
@ -1052,16 +1104,16 @@
},
{
"name": "facade/flare-client-php",
"version": "1.8.1",
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/facade/flare-client-php.git",
"reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f"
"reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/flare-client-php/zipball/47b639dc02bcfdfc4ebb83de703856fa01e35f5f",
"reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f",
"url": "https://api.github.com/repos/facade/flare-client-php/zipball/b2adf1512755637d0cef4f7d1b54301325ac78ed",
"reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed",
"shasum": ""
},
"require": {
@ -1105,7 +1157,7 @@
],
"support": {
"issues": "https://github.com/facade/flare-client-php/issues",
"source": "https://github.com/facade/flare-client-php/tree/1.8.1"
"source": "https://github.com/facade/flare-client-php/tree/1.9.1"
},
"funding": [
{
@ -1113,7 +1165,7 @@
"type": "github"
}
],
"time": "2021-05-31T19:23:29+00:00"
"time": "2021-09-13T12:16:46+00:00"
},
{
"name": "facade/ignition",
@ -1762,16 +1814,16 @@
},
{
"name": "laravel/framework",
"version": "v6.20.33",
"version": "v6.20.34",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58"
"reference": "72a6da88c90cee793513b3fe49cf0fcb368eefa0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58",
"reference": "49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58",
"url": "https://api.github.com/repos/laravel/framework/zipball/72a6da88c90cee793513b3fe49cf0fcb368eefa0",
"reference": "72a6da88c90cee793513b3fe49cf0fcb368eefa0",
"shasum": ""
},
"require": {
@ -1911,7 +1963,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-08-31T13:56:36+00:00"
"time": "2021-09-07T13:28:55+00:00"
},
{
"name": "laravel/socialite",
@ -2230,16 +2282,16 @@
},
{
"name": "league/html-to-markdown",
"version": "5.0.0",
"version": "5.0.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "c4dbebbebe0fe454b6b38e6c683a977615bd7dc2"
"reference": "e5600a2c5ce7b7571b16732c7086940f56f7abec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/c4dbebbebe0fe454b6b38e6c683a977615bd7dc2",
"reference": "c4dbebbebe0fe454b6b38e6c683a977615bd7dc2",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/e5600a2c5ce7b7571b16732c7086940f56f7abec",
"reference": "e5600a2c5ce7b7571b16732c7086940f56f7abec",
"shasum": ""
},
"require": {
@ -2295,7 +2347,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/html-to-markdown/issues",
"source": "https://github.com/thephpleague/html-to-markdown/tree/5.0.0"
"source": "https://github.com/thephpleague/html-to-markdown/tree/5.0.1"
},
"funding": [
{
@ -2311,11 +2363,11 @@
"type": "github"
},
{
"url": "https://www.patreon.com/colinodell",
"type": "patreon"
"url": "https://tidelift.com/funding/github/packagist/league/html-to-markdown",
"type": "tidelift"
}
],
"time": "2021-03-29T01:29:08+00:00"
"time": "2021-09-17T20:00:27+00:00"
},
{
"name": "league/mime-type-detection",
@ -2451,24 +2503,24 @@
},
{
"name": "monolog/monolog",
"version": "2.3.2",
"version": "2.3.4",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "71312564759a7db5b789296369c1a264efc43aad"
"reference": "437e7a1c50044b92773b361af77620efb76fff59"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/71312564759a7db5b789296369c1a264efc43aad",
"reference": "71312564759a7db5b789296369c1a264efc43aad",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/437e7a1c50044b92773b361af77620efb76fff59",
"reference": "437e7a1c50044b92773b361af77620efb76fff59",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/log": "^1.0.1"
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
"psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
@ -2483,7 +2535,7 @@
"phpunit/phpunit": "^8.5",
"predis/predis": "^1.1",
"rollbar/rollbar": "^1.3",
"ruflin/elastica": ">=0.90 <7.0.1",
"ruflin/elastica": ">=0.90@dev",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
@ -2491,8 +2543,11 @@
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
"ext-mbstring": "Allow to work properly with unicode symbols",
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
"ext-openssl": "Required to send log messages using SSL",
"ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
@ -2531,7 +2586,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.3.2"
"source": "https://github.com/Seldaek/monolog/tree/2.3.4"
},
"funding": [
{
@ -2543,7 +2598,7 @@
"type": "tidelift"
}
],
"time": "2021-07-23T07:42:52+00:00"
"time": "2021-09-15T11:27:21+00:00"
},
{
"name": "mtdowling/jmespath.php",
@ -2608,16 +2663,16 @@
},
{
"name": "nesbot/carbon",
"version": "2.52.0",
"version": "2.53.1",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "369c0e2737c56a0f39c946dd261855255a6fccbe"
"reference": "f4655858a784988f880c1b8c7feabbf02dfdf045"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/369c0e2737c56a0f39c946dd261855255a6fccbe",
"reference": "369c0e2737c56a0f39c946dd261855255a6fccbe",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f4655858a784988f880c1b8c7feabbf02dfdf045",
"reference": "f4655858a784988f880c1b8c7feabbf02dfdf045",
"shasum": ""
},
"require": {
@ -2629,7 +2684,7 @@
},
"require-dev": {
"doctrine/orm": "^2.7",
"friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0",
"phpmd/phpmd": "^2.9",
"phpstan/extension-installer": "^1.0",
@ -2698,7 +2753,7 @@
"type": "tidelift"
}
],
"time": "2021-08-14T19:10:52+00:00"
"time": "2021-09-06T09:29:23+00:00"
},
{
"name": "nunomaduro/collision",
@ -4492,20 +4547,20 @@
},
{
"name": "symfony/css-selector",
"version": "v4.4.27",
"version": "v5.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "5194f18bd80d106f11efa8f7cd0fbdcc3af96ce6"
"reference": "7fb120adc7f600a59027775b224c13a33530dd90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/5194f18bd80d106f11efa8f7cd0fbdcc3af96ce6",
"reference": "5194f18bd80d106f11efa8f7cd0fbdcc3af96ce6",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/7fb120adc7f600a59027775b224c13a33530dd90",
"reference": "7fb120adc7f600a59027775b224c13a33530dd90",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"php": ">=7.2.5",
"symfony/polyfill-php80": "^1.16"
},
"type": "library",
@ -4538,7 +4593,7 @@
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/v4.4.27"
"source": "https://github.com/symfony/css-selector/tree/v5.3.4"
},
"funding": [
{
@ -4554,7 +4609,7 @@
"type": "tidelift"
}
],
"time": "2021-07-21T12:19:41+00:00"
"time": "2021-07-21T12:38:00+00:00"
},
{
"name": "symfony/debug",
@ -6884,16 +6939,16 @@
},
{
"name": "composer/composer",
"version": "2.1.6",
"version": "2.1.8",
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
"reference": "e5cac5f9d2354d08b67f1d21c664ae70d748c603"
"reference": "24d38e9686092de05214cafa187dc282a5d89497"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/composer/zipball/e5cac5f9d2354d08b67f1d21c664ae70d748c603",
"reference": "e5cac5f9d2354d08b67f1d21c664ae70d748c603",
"url": "https://api.github.com/repos/composer/composer/zipball/24d38e9686092de05214cafa187dc282a5d89497",
"reference": "24d38e9686092de05214cafa187dc282a5d89497",
"shasum": ""
},
"require": {
@ -6962,7 +7017,7 @@
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/composer/issues",
"source": "https://github.com/composer/composer/tree/2.1.6"
"source": "https://github.com/composer/composer/tree/2.1.8"
},
"funding": [
{
@ -6978,7 +7033,7 @@
"type": "tidelift"
}
],
"time": "2021-08-19T15:11:08+00:00"
"time": "2021-09-15T11:55:15+00:00"
},
{
"name": "composer/metadata-minifier",
@ -7344,21 +7399,21 @@
},
{
"name": "fakerphp/faker",
"version": "v1.15.0",
"version": "v1.16.0",
"source": {
"type": "git",
"url": "https://github.com/FakerPHP/Faker.git",
"reference": "89c6201c74db25fa759ff16e78a4d8f32547770e"
"reference": "271d384d216e5e5c468a6b28feedf95d49f83b35"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/89c6201c74db25fa759ff16e78a4d8f32547770e",
"reference": "89c6201c74db25fa759ff16e78a4d8f32547770e",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/271d384d216e5e5c468a6b28feedf95d49f83b35",
"reference": "271d384d216e5e5c468a6b28feedf95d49f83b35",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"psr/container": "^1.0",
"psr/container": "^1.0 || ^2.0",
"symfony/deprecation-contracts": "^2.2"
},
"conflict": {
@ -7378,7 +7433,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "v1.15-dev"
"dev-main": "v1.16-dev"
}
},
"autoload": {
@ -7403,9 +7458,9 @@
],
"support": {
"issues": "https://github.com/FakerPHP/Faker/issues",
"source": "https://github.com/FakerPHP/Faker/tree/v1.15.0"
"source": "https://github.com/FakerPHP/Faker/tree/v1.16.0"
},
"time": "2021-07-06T20:39:40+00:00"
"time": "2021-09-06T14:53:37+00:00"
},
{
"name": "hamcrest/hamcrest-php",
@ -7528,71 +7583,6 @@
},
"time": "2021-07-22T09:24:00+00:00"
},
{
"name": "laravel/browser-kit-testing",
"version": "v5.2.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/browser-kit-testing.git",
"reference": "fa0efb279c009e2a276f934f8aff946caf66edc7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/fa0efb279c009e2a276f934f8aff946caf66edc7",
"reference": "fa0efb279c009e2a276f934f8aff946caf66edc7",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0",
"illuminate/database": "~5.7.0|~5.8.0|^6.0",
"illuminate/http": "~5.7.0|~5.8.0|^6.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0",
"mockery/mockery": "^1.0",
"php": "^7.1.3|^8.0",
"phpunit/phpunit": "^7.5|^8.0|^9.3",
"symfony/console": "^4.2",
"symfony/css-selector": "^4.2",
"symfony/dom-crawler": "^4.2",
"symfony/http-foundation": "^4.2",
"symfony/http-kernel": "^4.2"
},
"require-dev": {
"laravel/framework": "~5.7.0|~5.8.0|^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.x-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\BrowserKitTesting\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Provides backwards compatibility for BrowserKit testing in the latest Laravel release.",
"keywords": [
"laravel",
"testing"
],
"support": {
"issues": "https://github.com/laravel/browser-kit-testing/issues",
"source": "https://github.com/laravel/browser-kit-testing/tree/v5.2.0"
},
"time": "2020-10-30T08:49:09+00:00"
},
{
"name": "maximebf/debugbar",
"version": "v1.17.1",
@ -7660,16 +7650,16 @@
},
{
"name": "mockery/mockery",
"version": "1.4.3",
"version": "1.4.4",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
"reference": "d1339f64479af1bee0e82a0413813fe5345a54ea"
"reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea",
"reference": "d1339f64479af1bee0e82a0413813fe5345a54ea",
"url": "https://api.github.com/repos/mockery/mockery/zipball/e01123a0e847d52d186c5eb4b9bf58b0c6d00346",
"reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346",
"shasum": ""
},
"require": {
@ -7726,9 +7716,9 @@
],
"support": {
"issues": "https://github.com/mockery/mockery/issues",
"source": "https://github.com/mockery/mockery/tree/1.4.3"
"source": "https://github.com/mockery/mockery/tree/1.4.4"
},
"time": "2021-02-24T09:51:49+00:00"
"time": "2021-09-13T15:28:59+00:00"
},
{
"name": "myclabs/deep-copy",
@ -8066,16 +8056,16 @@
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.4.0",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
"reference": "30f38bffc6f24293dadd1823936372dfa9e86e2f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
"reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/30f38bffc6f24293dadd1823936372dfa9e86e2f",
"reference": "30f38bffc6f24293dadd1823936372dfa9e86e2f",
"shasum": ""
},
"require": {
@ -8083,7 +8073,8 @@
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
"ext-tokenizer": "*"
"ext-tokenizer": "*",
"psalm/phar": "^4.8"
},
"type": "library",
"extra": {
@ -8109,39 +8100,39 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.0"
},
"time": "2020-09-17T18:55:26+00:00"
"time": "2021-09-17T15:28:14+00:00"
},
{
"name": "phpspec/prophecy",
"version": "1.13.0",
"version": "1.14.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
"reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
"reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.2",
"php": "^7.2 || ~8.0, <8.1",
"php": "^7.2 || ~8.0, <8.2",
"phpdocumentor/reflection-docblock": "^5.2",
"sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^3.0 || ^4.0"
},
"require-dev": {
"phpspec/phpspec": "^6.0",
"phpspec/phpspec": "^6.0 || ^7.0",
"phpunit/phpunit": "^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11.x-dev"
"dev-master": "1.x-dev"
}
},
"autoload": {
@ -8176,29 +8167,29 @@
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
"source": "https://github.com/phpspec/prophecy/tree/1.13.0"
"source": "https://github.com/phpspec/prophecy/tree/1.14.0"
},
"time": "2021-03-17T13:42:18+00:00"
"time": "2021-09-10T09:02:12+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.6",
"version": "9.2.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f6293e1b30a2354e8428e004689671b83871edde"
"reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
"reference": "f6293e1b30a2354e8428e004689671b83871edde",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d4c798ed8d51506800b441f7a13ecb0f76f12218",
"reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
"nikic/php-parser": "^4.10.2",
"nikic/php-parser": "^4.12.0",
"php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
@ -8247,7 +8238,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.7"
},
"funding": [
{
@ -8255,7 +8246,7 @@
"type": "github"
}
],
"time": "2021-03-28T07:26:59+00:00"
"time": "2021-09-17T05:39:03+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -9728,20 +9719,21 @@
},
{
"name": "symfony/dom-crawler",
"version": "v4.4.30",
"version": "v5.3.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "4632ae3567746c7e915c33c67a2fb6ab746090c4"
"reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4632ae3567746c7e915c33c67a2fb6ab746090c4",
"reference": "4632ae3567746c7e915c33c67a2fb6ab746090c4",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c7eef3a60ccfdd8eafe07f81652e769ac9c7146c",
"reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.16"
@ -9751,7 +9743,7 @@
},
"require-dev": {
"masterminds/html5": "^2.6",
"symfony/css-selector": "^3.4|^4.0|^5.0"
"symfony/css-selector": "^4.4|^5.0"
},
"suggest": {
"symfony/css-selector": ""
@ -9782,7 +9774,7 @@
"description": "Eases DOM navigation for HTML and XML documents",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/dom-crawler/tree/v4.4.30"
"source": "https://github.com/symfony/dom-crawler/tree/v5.3.7"
},
"funding": [
{
@ -9798,7 +9790,7 @@
"type": "tidelift"
}
],
"time": "2021-08-28T15:40:01+00:00"
"time": "2021-08-29T19:32:13+00:00"
},
{
"name": "symfony/filesystem",

View File

@ -1,185 +0,0 @@
<?php
namespace Tests;
use BookStack\Auth\Permissions\PermissionService;
use BookStack\Auth\User;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
use BookStack\Settings\SettingService;
use DB;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Laravel\BrowserKitTesting\TestCase;
use Symfony\Component\DomCrawler\Crawler;
abstract class BrowserKitTest extends TestCase
{
use DatabaseTransactions;
use SharedTestHelpers;
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
public function tearDown(): void
{
DB::disconnect();
parent::tearDown();
}
/**
* Creates the application.
*
* @return Application
*/
public function createApplication()
{
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
/**
* Quickly sets an array of settings.
*
* @param $settingsArray
*/
protected function setSettings($settingsArray)
{
$settings = app(SettingService::class);
foreach ($settingsArray as $key => $value) {
$settings->put($key, $value);
}
}
/**
* Helper for updating entity permissions.
*
* @param Entity $entity
*/
protected function updateEntityPermissions(Entity $entity)
{
$restrictionService = $this->app[PermissionService::class];
$restrictionService->buildJointPermissionsForEntity($entity);
}
/**
* Assert that a given string is seen inside an element.
*
* @param bool|string|null $element
* @param int $position
* @param string $text
* @param bool $negate
*
* @return $this
*/
protected function seeInNthElement($element, $position, $text, $negate = false)
{
$method = $negate ? 'assertDoesNotMatchRegularExpression' : 'assertMatchesRegularExpression';
$rawPattern = preg_quote($text, '/');
$escapedPattern = preg_quote(e($text), '/');
$content = $this->crawler->filter($element)->eq($position)->html();
$pattern = $rawPattern == $escapedPattern
? $rawPattern : "({$rawPattern}|{$escapedPattern})";
$this->$method("/$pattern/i", $content);
return $this;
}
/**
* Assert that the current page matches a given URI.
*
* @param string $uri
*
* @return $this
*/
protected function seePageUrlIs($uri)
{
$this->assertEquals(
$uri,
$this->currentUri,
"Did not land on expected page [{$uri}].\n"
);
return $this;
}
/**
* Do a forced visit that does not error out on exception.
*
* @param string $uri
* @param array $parameters
* @param array $cookies
* @param array $files
*
* @return $this
*/
protected function forceVisit($uri, $parameters = [], $cookies = [], $files = [])
{
$method = 'GET';
$uri = $this->prepareUrlForRequest($uri);
$this->call($method, $uri, $parameters, $cookies, $files);
$this->clearInputs()->followRedirects();
$this->currentUri = $this->app->make('request')->fullUrl();
$this->crawler = new Crawler($this->response->getContent(), $uri);
return $this;
}
/**
* Click the text within the selected element.
*
* @param $parentElement
* @param $linkText
*
* @return $this
*/
protected function clickInElement($parentElement, $linkText)
{
$elem = $this->crawler->filter($parentElement);
$link = $elem->selectLink($linkText);
$this->visit($link->link()->getUri());
return $this;
}
/**
* Check if the page contains the given element.
*
* @param string $selector
*/
protected function pageHasElement($selector)
{
$elements = $this->crawler->filter($selector);
$this->assertTrue(count($elements) > 0, 'The page does not contain an element matching ' . $selector);
return $this;
}
/**
* Check if the page contains the given element.
*
* @param string $selector
*/
protected function pageNotHasElement($selector)
{
$elements = $this->crawler->filter($selector);
$this->assertFalse(count($elements) > 0, 'The page contains ' . count($elements) . ' elements matching ' . $selector);
return $this;
}
}

View File

@ -2,12 +2,14 @@
namespace Tests\Permissions;
use BookStack\Actions\ActivityType;
use BookStack\Actions\Comment;
use BookStack\Auth\Role;
use BookStack\Auth\User;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
use BookStack\Uploads\Image;
use Tests\TestCase;
@ -56,70 +58,104 @@ class RolesTest extends TestCase
$testRoleUpdateName = 'An Super Updated role';
// Creation
$this->asAdmin()->get('/settings')
->click('Roles')
->seePageIs('/settings/roles')
->click('Create New Role')
->type('Test Role', 'display_name')
->type('A little test description', 'description')
->press('Save Role')
->assertDatabaseHas('roles', ['display_name' => $testRoleName, 'description' => $testRoleDesc, 'mfa_enforced' => false])
->seePageIs('/settings/roles');
$resp = $this->asAdmin()->get('/settings');
$resp->assertElementContains('a[href="' . url('/settings/roles') . '"]', 'Roles');
$resp = $this->get('/settings/roles');
$resp->assertElementContains('a[href="' . url('/settings/roles/new') . '"]', 'Create New Role');
$resp = $this->get('/settings/roles/new');
$resp->assertElementContains('form[action="' . url('/settings/roles/new') . '"]', 'Save Role');
$resp = $this->post('/settings/roles/new', [
'display_name' => $testRoleName,
'description' => $testRoleDesc,
]);
$resp->assertRedirect('/settings/roles');
$resp = $this->get('/settings/roles');
$resp->assertSee($testRoleName);
$resp->assertSee($testRoleDesc);
$this->assertDatabaseHas('roles', [
'display_name' => $testRoleName,
'description' => $testRoleDesc,
'mfa_enforced' => false,
]);
/** @var Role $role */
$role = Role::query()->where('display_name', '=', $testRoleName)->first();
// Updating
$this->asAdmin()->get('/settings/roles')
->assertSee($testRoleDesc)
->click($testRoleName)
->type($testRoleUpdateName, '#display_name')
->check('#mfa_enforced')
->press('Save Role')
->assertDatabaseHas('roles', ['display_name' => $testRoleUpdateName, 'description' => $testRoleDesc, 'mfa_enforced' => true])
->seePageIs('/settings/roles');
$resp = $this->get('/settings/roles/' . $role->id);
$resp->assertSee($testRoleName);
$resp->assertSee($testRoleDesc);
$resp->assertElementContains('form[action="' . url('/settings/roles/' . $role->id) . '"]', 'Save Role');
$resp = $this->put('/settings/roles/' . $role->id, [
'display_name' => $testRoleUpdateName,
'description' => $testRoleDesc,
'mfa_enforced' => 'true',
]);
$resp->assertRedirect('/settings/roles');
$this->assertDatabaseHas('roles', [
'display_name' => $testRoleUpdateName,
'description' => $testRoleDesc,
'mfa_enforced' => true,
]);
// Deleting
$this->asAdmin()->get('/settings/roles')
->click($testRoleUpdateName)
->click('Delete Role')
->assertSee($testRoleUpdateName)
->press('Confirm')
->seePageIs('/settings/roles')
->assertDontSee($testRoleUpdateName);
$resp = $this->get('/settings/roles/' . $role->id);
$resp->assertElementContains('a[href="' . url("/settings/roles/delete/$role->id") . '"]', 'Delete Role');
$resp = $this->get("/settings/roles/delete/$role->id");
$resp->assertSee($testRoleUpdateName);
$resp->assertElementContains('form[action="' . url("/settings/roles/delete/$role->id") . '"]', 'Confirm');
$resp = $this->delete("/settings/roles/delete/$role->id");
$resp->assertRedirect('/settings/roles');
$this->get('/settings/roles')->assertSee('Role successfully deleted');
$this->assertActivityExists(ActivityType::ROLE_DELETE);
}
public function test_admin_role_cannot_be_removed_if_user_last_admin()
{
$adminRole = Role::where('system_name', '=', 'admin')->first();
/** @var Role $adminRole */
$adminRole = Role::query()->where('system_name', '=', 'admin')->first();
$adminUser = $this->getAdmin();
$adminRole->users()->where('id', '!=', $adminUser->id)->delete();
$this->assertEquals($adminRole->users()->count(), 1);
$this->assertEquals(1, $adminRole->users()->count());
$viewerRole = $this->getViewer()->roles()->first();
$editUrl = '/settings/users/' . $adminUser->id;
$this->actingAs($adminUser)->put($editUrl, [
$resp = $this->actingAs($adminUser)->put($editUrl, [
'name' => $adminUser->name,
'email' => $adminUser->email,
'roles' => [
'viewer' => strval($viewerRole->id),
],
])->followRedirects();
]);
$this->seePageIs($editUrl);
$this->assertSee('This user is the only user assigned to the administrator role');
$resp->assertRedirect($editUrl);
$resp = $this->get($editUrl);
$resp->assertSee('This user is the only user assigned to the administrator role');
}
public function test_migrate_users_on_delete_works()
{
/** @var Role $roleA */
$roleA = Role::query()->create(['display_name' => 'Delete Test A']);
/** @var Role $roleB */
$roleB = Role::query()->create(['display_name' => 'Delete Test B']);
$this->user->attachRole($roleB);
$this->assertCount(0, $roleA->users()->get());
$this->assertCount(1, $roleB->users()->get());
$deletePage = $this->asAdmin()->get("/settings/roles/delete/{$roleB->id}");
$deletePage = $this->asAdmin()->get("/settings/roles/delete/$roleB->id");
$deletePage->assertElementExists('select[name=migrate_role_id]');
$this->asAdmin()->delete("/settings/roles/delete/{$roleB->id}", [
$this->asAdmin()->delete("/settings/roles/delete/$roleB->id", [
'migrate_role_id' => $roleA->id,
]);
@ -129,11 +165,9 @@ class RolesTest extends TestCase
public function test_manage_user_permission()
{
$this->actingAs($this->user)->get('/settings/users')
->seePageIs('/');
$this->actingAs($this->user)->get('/settings/users')->assertRedirect('/');
$this->giveUserPermissions($this->user, ['users-manage']);
$this->actingAs($this->user)->get('/settings/users')
->seePageIs('/settings/users');
$this->actingAs($this->user)->get('/settings/users')->assertOk();
}
public function test_manage_users_permission_shows_link_in_header_if_does_not_have_settings_manage_permision()
@ -185,35 +219,41 @@ class RolesTest extends TestCase
public function test_user_roles_manage_permission()
{
$this->actingAs($this->user)->get('/settings/roles')
->seePageIs('/')->get('/settings/roles/1')->seePageIs('/');
$this->actingAs($this->user)->get('/settings/roles')->assertRedirect('/');
$this->get('/settings/roles/1')->assertRedirect('/');
$this->giveUserPermissions($this->user, ['user-roles-manage']);
$this->actingAs($this->user)->get('/settings/roles')
->seePageIs('/settings/roles')->click('Admin')
->assertSee('Edit Role');
$this->actingAs($this->user)->get('/settings/roles')->assertOk();
$this->get('/settings/roles/1')
->assertOk()
->assertSee('Admin');
}
public function test_settings_manage_permission()
{
$this->actingAs($this->user)->get('/settings')
->seePageIs('/');
$this->actingAs($this->user)->get('/settings')->assertRedirect('/');
$this->giveUserPermissions($this->user, ['settings-manage']);
$this->actingAs($this->user)->get('/settings')
->seePageIs('/settings')->press('Save Settings')->assertSee('Settings Saved');
$this->get('/settings')->assertOk();
$resp = $this->post('/settings', []);
$resp->assertRedirect('/settings');
$resp = $this->get('/settings');
$resp->assertSee('Settings saved');
}
public function test_restrictions_manage_all_permission()
{
$page = Page::take(1)->get()->first();
$this->actingAs($this->user)->get($page->getUrl())
->assertDontSee('Permissions')
->get($page->getUrl() . '/permissions')
->seePageIs('/');
$page = Page::query()->get()->first();
$this->actingAs($this->user)->get($page->getUrl())->assertDontSee('Permissions');
$this->get($page->getUrl('/permissions'))->assertRedirect('/');
$this->giveUserPermissions($this->user, ['restrictions-manage-all']);
$this->actingAs($this->user)->get($page->getUrl())
->assertSee('Permissions')
->click('Permissions')
->assertSee('Page Permissions')->seePageIs($page->getUrl() . '/permissions');
$this->actingAs($this->user)->get($page->getUrl())->assertSee('Permissions');
$this->get($page->getUrl('/permissions'))
->assertOk()
->assertSee('Page Permissions');
}
public function test_restrictions_manage_own_permission()
@ -230,43 +270,33 @@ class RolesTest extends TestCase
$page->save();
// Check can't restrict other's content
$this->actingAs($this->user)->get($otherUsersPage->getUrl())
->assertDontSee('Permissions')
->get($otherUsersPage->getUrl() . '/permissions')
->seePageIs('/');
$this->actingAs($this->user)->get($otherUsersPage->getUrl())->assertDontSee('Permissions');
$this->get($otherUsersPage->getUrl('/permissions'))->assertRedirect('/');
// Check can't restrict own content
$this->actingAs($this->user)->get($page->getUrl())
->assertDontSee('Permissions')
->get($page->getUrl() . '/permissions')
->seePageIs('/');
$this->actingAs($this->user)->get($page->getUrl())->assertDontSee('Permissions');
$this->get($page->getUrl('/permissions'))->assertRedirect('/');
$this->giveUserPermissions($this->user, ['restrictions-manage-own']);
// Check can't restrict other's content
$this->actingAs($this->user)->get($otherUsersPage->getUrl())
->assertDontSee('Permissions')
->get($otherUsersPage->getUrl() . '/permissions')
->seePageIs('/');
$this->actingAs($this->user)->get($otherUsersPage->getUrl())->assertDontSee('Permissions');
$this->get($otherUsersPage->getUrl('/permissions'))->assertRedirect();
// Check can restrict own content
$this->actingAs($this->user)->get($page->getUrl())
->assertSee('Permissions')
->click('Permissions')
->seePageIs($page->getUrl() . '/permissions');
$this->actingAs($this->user)->get($page->getUrl())->assertSee('Permissions');
$this->get($page->getUrl('/permissions'))->assertOk();
}
/**
* Check a standard entity access permission.
*
* @param string $permission
* @param array $accessUrls Urls that are only accessible after having the permission
* @param array $visibles Check this text, In the buttons toolbar, is only visible with the permission
*/
private function checkAccessPermission($permission, $accessUrls = [], $visibles = [])
private function checkAccessPermission(string $permission, array $accessUrls = [], array $visibles = [])
{
foreach ($accessUrls as $url) {
$this->actingAs($this->user)->get($url)
->seePageIs('/');
$this->actingAs($this->user)->get($url)->assertRedirect('/');
}
foreach ($visibles as $url => $text) {
$this->actingAs($this->user)->get($url)
->assertElementNotContains('.action-buttons', $text);
@ -275,12 +305,10 @@ class RolesTest extends TestCase
$this->giveUserPermissions($this->user, [$permission]);
foreach ($accessUrls as $url) {
$this->actingAs($this->user)->get($url)
->seePageIs($url);
$this->actingAs($this->user)->get($url)->assertOk();
}
foreach ($visibles as $url => $text) {
$this->actingAs($this->user)->get($url)
->assertSee($text);
$this->actingAs($this->user)->get($url)->assertSee($text);
}
}
@ -292,11 +320,10 @@ class RolesTest extends TestCase
'/shelves' => 'New Shelf',
]);
$this->get('/create-shelf')
->type('test shelf', 'name')
->type('shelf desc', 'description')
->press('Save Shelf')
->seePageIs('/shelves/test-shelf');
$this->post('/shelves', [
'name' => 'test shelf',
'description' => 'shelf desc',
])->assertRedirect('/shelves/test-shelf');
}
public function test_bookshelves_edit_own_permission()
@ -313,10 +340,8 @@ class RolesTest extends TestCase
$ownShelf->getUrl() => 'Edit',
]);
$this->get($otherShelf->getUrl())
->assertElementNotContains('.action-buttons', 'Edit')
->get($otherShelf->getUrl('/edit'))
->seePageIs('/');
$this->get($otherShelf->getUrl())->assertElementNotContains('.action-buttons', 'Edit');
$this->get($otherShelf->getUrl('/edit'))->assertRedirect('/');
}
public function test_bookshelves_edit_all_permission()
@ -345,14 +370,12 @@ class RolesTest extends TestCase
$ownShelf->getUrl() => 'Delete',
]);
$this->get($otherShelf->getUrl())
->assertElementNotContains('.action-buttons', 'Delete')
->get($otherShelf->getUrl('/delete'))
->seePageIs('/');
$this->get($ownShelf->getUrl())->get($ownShelf->getUrl('/delete'))
->press('Confirm')
->seePageIs('/shelves')
->assertDontSee($ownShelf->name);
$this->get($otherShelf->getUrl())->assertElementNotContains('.action-buttons', 'Delete');
$this->get($otherShelf->getUrl('/delete'))->assertRedirect('/');
$this->get($ownShelf->getUrl());
$this->delete($ownShelf->getUrl())->assertRedirect('/shelves');
$this->get('/shelves')->assertDontSee($ownShelf->name);
}
public function test_bookshelves_delete_all_permission()
@ -366,10 +389,8 @@ class RolesTest extends TestCase
$otherShelf->getUrl() => 'Delete',
]);
$this->get($otherShelf->getUrl())->get($otherShelf->getUrl('/delete'))
->press('Confirm')
->seePageIs('/shelves')
->assertDontSee($otherShelf->name);
$this->delete($otherShelf->getUrl())->assertRedirect('/shelves');
$this->get('/shelves')->assertDontSee($otherShelf->name);
}
public function test_books_create_all_permissions()
@ -380,11 +401,10 @@ class RolesTest extends TestCase
'/books' => 'Create New Book',
]);
$this->get('/create-book')
->type('test book', 'name')
->type('book desc', 'description')
->press('Save Book')
->seePageIs('/books/test-book');
$this->post('/books', [
'name' => 'test book',
'description' => 'book desc',
])->assertRedirect('/books/test-book');
}
public function test_books_edit_own_permission()
@ -398,10 +418,8 @@ class RolesTest extends TestCase
$ownBook->getUrl() => 'Edit',
]);
$this->get($otherBook->getUrl())
->assertElementNotContains('.action-buttons', 'Edit')
->get($otherBook->getUrl() . '/edit')
->seePageIs('/');
$this->get($otherBook->getUrl())->assertElementNotContains('.action-buttons', 'Edit');
$this->get($otherBook->getUrl('/edit'))->assertRedirect('/');
}
public function test_books_edit_all_permission()
@ -427,14 +445,11 @@ class RolesTest extends TestCase
$ownBook->getUrl() => 'Delete',
]);
$this->get($otherBook->getUrl())
->assertElementNotContains('.action-buttons', 'Delete')
->get($otherBook->getUrl() . '/delete')
->seePageIs('/');
$this->get($ownBook->getUrl())->get($ownBook->getUrl() . '/delete')
->press('Confirm')
->seePageIs('/books')
->assertDontSee($ownBook->name);
$this->get($otherBook->getUrl())->assertElementNotContains('.action-buttons', 'Delete');
$this->get($otherBook->getUrl('/delete'))->assertRedirect('/');
$this->get($ownBook->getUrl());
$this->delete($ownBook->getUrl())->assertRedirect('/books');
$this->get('/books')->assertDontSee($ownBook->name);
}
public function test_books_delete_all_permission()
@ -448,10 +463,9 @@ class RolesTest extends TestCase
$otherBook->getUrl() => 'Delete',
]);
$this->get($otherBook->getUrl())->get($otherBook->getUrl() . '/delete')
->press('Confirm')
->seePageIs('/books')
->assertDontSee($otherBook->name);
$this->get($otherBook->getUrl());
$this->delete($otherBook->getUrl())->assertRedirect('/books');
$this->get('/books')->assertDontSee($otherBook->name);
}
public function test_chapter_create_own_permissions()
@ -465,37 +479,35 @@ class RolesTest extends TestCase
$ownBook->getUrl() => 'New Chapter',
]);
$this->get($ownBook->getUrl('/create-chapter'))
->type('test chapter', 'name')
->type('chapter desc', 'description')
->press('Save Chapter')
->seePageIs($ownBook->getUrl('/chapter/test-chapter'));
$this->post($ownBook->getUrl('/create-chapter'), [
'name' => 'test chapter',
'description' => 'chapter desc',
])->assertRedirect($ownBook->getUrl('/chapter/test-chapter'));
$this->get($book->getUrl())
->assertElementNotContains('.action-buttons', 'New Chapter')
->get($book->getUrl('/create-chapter'))
->seePageIs('/');
$this->get($book->getUrl())->assertElementNotContains('.action-buttons', 'New Chapter');
$this->get($book->getUrl('/create-chapter'))->assertRedirect('/');
}
public function test_chapter_create_all_permissions()
{
$book = Book::take(1)->get()->first();
/** @var Book $book */
$book = Book::query()->first();
$this->checkAccessPermission('chapter-create-all', [
$book->getUrl('/create-chapter'),
], [
$book->getUrl() => 'New Chapter',
]);
$this->get($book->getUrl('/create-chapter'))
->type('test chapter', 'name')
->type('chapter desc', 'description')
->press('Save Chapter')
->seePageIs($book->getUrl('/chapter/test-chapter'));
$this->post($book->getUrl('/create-chapter'), [
'name' => 'test chapter',
'description' => 'chapter desc',
])->assertRedirect($book->getUrl('/chapter/test-chapter'));
}
public function test_chapter_edit_own_permission()
{
$otherChapter = Chapter::take(1)->get()->first();
/** @var Chapter $otherChapter */
$otherChapter = Chapter::query()->first();
$ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
$this->checkAccessPermission('chapter-update-own', [
$ownChapter->getUrl() . '/edit',
@ -503,10 +515,8 @@ class RolesTest extends TestCase
$ownChapter->getUrl() => 'Edit',
]);
$this->get($otherChapter->getUrl())
->assertElementNotContains('.action-buttons', 'Edit')
->get($otherChapter->getUrl() . '/edit')
->seePageIs('/');
$this->get($otherChapter->getUrl())->assertElementNotContains('.action-buttons', 'Edit');
$this->get($otherChapter->getUrl('/edit'))->assertRedirect('/');
}
public function test_chapter_edit_all_permission()
@ -524,7 +534,7 @@ class RolesTest extends TestCase
{
$this->giveUserPermissions($this->user, ['chapter-update-all']);
/** @var Chapter $otherChapter */
$otherChapter = Chapter::query()->take(1)->get()->first();
$otherChapter = Chapter::query()->first();
$ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
$this->checkAccessPermission('chapter-delete-own', [
$ownChapter->getUrl() . '/delete',
@ -533,20 +543,18 @@ class RolesTest extends TestCase
]);
$bookUrl = $ownChapter->book->getUrl();
$this->get($otherChapter->getUrl())
->assertElementNotContains('.action-buttons', 'Delete')
->get($otherChapter->getUrl() . '/delete')
->seePageIs('/');
$this->get($ownChapter->getUrl())->get($ownChapter->getUrl() . '/delete')
->press('Confirm')
->seePageIs($bookUrl)
->assertElementNotContains('.book-content', $ownChapter->name);
$this->get($otherChapter->getUrl())->assertElementNotContains('.action-buttons', 'Delete');
$this->get($otherChapter->getUrl('/delete'))->assertRedirect('/');
$this->get($ownChapter->getUrl());
$this->delete($ownChapter->getUrl())->assertRedirect($bookUrl);
$this->get($bookUrl)->assertElementNotContains('.book-content', $ownChapter->name);
}
public function test_chapter_delete_all_permission()
{
$this->giveUserPermissions($this->user, ['chapter-update-all']);
$otherChapter = Chapter::take(1)->get()->first();
/** @var Chapter $otherChapter */
$otherChapter = Chapter::query()->first();
$this->checkAccessPermission('chapter-delete-all', [
$otherChapter->getUrl() . '/delete',
], [
@ -554,10 +562,9 @@ class RolesTest extends TestCase
]);
$bookUrl = $otherChapter->book->getUrl();
$this->get($otherChapter->getUrl())->get($otherChapter->getUrl() . '/delete')
->press('Confirm')
->seePageIs($bookUrl)
->assertElementNotContains('.book-content', $otherChapter->name);
$this->get($otherChapter->getUrl());
$this->delete($otherChapter->getUrl())->assertRedirect($bookUrl);
$this->get($bookUrl)->assertElementNotContains('.book-content', $otherChapter->name);
}
public function test_page_create_own_permissions()
@ -576,8 +583,7 @@ class RolesTest extends TestCase
$accessUrls = [$createUrl, $createUrlChapter];
foreach ($accessUrls as $url) {
$this->actingAs($this->user)->get($url)
->seePageIs('/');
$this->actingAs($this->user)->get($url)->assertRedirect('/');
}
$this->checkAccessPermission('page-create-own', [], [
@ -588,39 +594,39 @@ class RolesTest extends TestCase
$this->giveUserPermissions($this->user, ['page-create-own']);
foreach ($accessUrls as $index => $url) {
$this->actingAs($this->user)->get($url);
$expectedUrl = Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
$this->seePageIs($expectedUrl);
$resp = $this->actingAs($this->user)->get($url);
$expectedUrl = Page::query()->where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
$resp->assertRedirect($expectedUrl);
}
$this->get($createUrl)
->type('test page', 'name')
->type('page desc', 'html')
->press('Save Page')
->seePageIs($ownBook->getUrl('/page/test-page'));
$this->get($createUrl);
/** @var Page $draft */
$draft = Page::query()->where('draft', '=', true)->orderBy('id', 'desc')->first();
$this->post($draft->getUrl(), [
'name' => 'test page',
'html' => 'page desc',
])->assertRedirect($ownBook->getUrl('/page/test-page'));
$this->get($book->getUrl())
->assertElementNotContains('.action-buttons', 'New Page')
->get($book->getUrl() . '/create-page')
->seePageIs('/');
$this->get($chapter->getUrl())
->assertElementNotContains('.action-buttons', 'New Page')
->get($chapter->getUrl() . '/create-page')
->seePageIs('/');
$this->get($book->getUrl())->assertElementNotContains('.action-buttons', 'New Page');
$this->get($book->getUrl('/create-page'))->assertRedirect('/');
$this->get($chapter->getUrl())->assertElementNotContains('.action-buttons', 'New Page');
$this->get($chapter->getUrl('/create-page'))->assertRedirect('/');
}
public function test_page_create_all_permissions()
{
$book = Book::take(1)->get()->first();
$chapter = Chapter::take(1)->get()->first();
/** @var Book $book */
$book = Book::query()->first();
/** @var Chapter $chapter */
$chapter = Chapter::query()->first();
$createUrl = $book->getUrl('/create-page');
$createUrlChapter = $chapter->getUrl('/create-page');
$accessUrls = [$createUrl, $createUrlChapter];
foreach ($accessUrls as $url) {
$this->actingAs($this->user)->get($url)
->seePageIs('/');
$this->actingAs($this->user)->get($url)->assertRedirect('/');
}
$this->checkAccessPermission('page-create-all', [], [
@ -631,27 +637,32 @@ class RolesTest extends TestCase
$this->giveUserPermissions($this->user, ['page-create-all']);
foreach ($accessUrls as $index => $url) {
$this->actingAs($this->user)->get($url);
$expectedUrl = Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
$this->seePageIs($expectedUrl);
$resp = $this->actingAs($this->user)->get($url);
$expectedUrl = Page::query()->where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
$resp->assertRedirect($expectedUrl);
}
$this->get($createUrl)
->type('test page', 'name')
->type('page desc', 'html')
->press('Save Page')
->seePageIs($book->getUrl('/page/test-page'));
$this->get($createUrl);
/** @var Page $draft */
$draft = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
$this->post($draft->getUrl(), [
'name' => 'test page',
'html' => 'page desc',
])->assertRedirect($book->getUrl('/page/test-page'));
$this->get($chapter->getUrl('/create-page'))
->type('new test page', 'name')
->type('page desc', 'html')
->press('Save Page')
->seePageIs($book->getUrl('/page/new-test-page'));
$this->get($chapter->getUrl('/create-page'));
/** @var Page $draft */
$draft = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
$this->post($draft->getUrl(), [
'name' => 'new test page',
'html' => 'page desc',
])->assertRedirect($book->getUrl('/page/new-test-page'));
}
public function test_page_edit_own_permission()
{
$otherPage = Page::take(1)->get()->first();
/** @var Page $otherPage */
$otherPage = Page::query()->first();
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
$this->checkAccessPermission('page-update-own', [
$ownPage->getUrl() . '/edit',
@ -659,17 +670,16 @@ class RolesTest extends TestCase
$ownPage->getUrl() => 'Edit',
]);
$this->get($otherPage->getUrl())
->assertElementNotContains('.action-buttons', 'Edit')
->get($otherPage->getUrl() . '/edit')
->seePageIs('/');
$this->get($otherPage->getUrl())->assertElementNotContains('.action-buttons', 'Edit');
$this->get($otherPage->getUrl() . '/edit')->assertRedirect('/');
}
public function test_page_edit_all_permission()
{
$otherPage = Page::take(1)->get()->first();
/** @var Page $otherPage */
$otherPage = Page::query()->first();
$this->checkAccessPermission('page-update-all', [
$otherPage->getUrl() . '/edit',
$otherPage->getUrl('/edit'),
], [
$otherPage->getUrl() => 'Edit',
]);
@ -678,7 +688,8 @@ class RolesTest extends TestCase
public function test_page_delete_own_permission()
{
$this->giveUserPermissions($this->user, ['page-update-all']);
$otherPage = Page::take(1)->get()->first();
/** @var Page $otherPage */
$otherPage = Page::query()->first();
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
$this->checkAccessPermission('page-delete-own', [
$ownPage->getUrl() . '/delete',
@ -687,36 +698,37 @@ class RolesTest extends TestCase
]);
$parent = $ownPage->chapter ?? $ownPage->book;
$this->get($otherPage->getUrl())
->assertElementNotContains('.action-buttons', 'Delete')
->get($otherPage->getUrl() . '/delete')
->seePageIs('/');
$this->get($ownPage->getUrl())->get($ownPage->getUrl() . '/delete')
->press('Confirm')
->seePageIs($parent->getUrl())
->assertElementNotContains('.book-content', $ownPage->name);
$this->get($otherPage->getUrl())->assertElementNotContains('.action-buttons', 'Delete');
$this->get($otherPage->getUrl('/delete'))->assertRedirect('/');
$this->get($ownPage->getUrl());
$this->delete($ownPage->getUrl())->assertRedirect($parent->getUrl());
$this->get($parent->getUrl())->assertElementNotContains('.book-content', $ownPage->name);
}
public function test_page_delete_all_permission()
{
$this->giveUserPermissions($this->user, ['page-update-all']);
$otherPage = Page::take(1)->get()->first();
/** @var Page $otherPage */
$otherPage = Page::query()->first();
$this->checkAccessPermission('page-delete-all', [
$otherPage->getUrl() . '/delete',
], [
$otherPage->getUrl() => 'Delete',
]);
/** @var Entity $parent */
$parent = $otherPage->chapter ?? $otherPage->book;
$this->get($otherPage->getUrl())->get($otherPage->getUrl() . '/delete')
->press('Confirm')
->seePageIs($parent->getUrl())
->assertElementNotContains('.book-content', $otherPage->name);
$this->get($otherPage->getUrl());
$this->delete($otherPage->getUrl())->assertRedirect($parent->getUrl());
$this->get($parent->getUrl())->assertDontSee($otherPage->name);
}
public function test_public_role_visible_in_user_edit_screen()
{
$user = User::first();
/** @var User $user */
$user = User::query()->first();
$adminRole = Role::getSystemRole('admin');
$publicRole = Role::getSystemRole('public');
$this->asAdmin()->get('/settings/users/' . $user->id)
@ -738,53 +750,57 @@ class RolesTest extends TestCase
->assertElementExists('[data-system-role-name="public"]');
}
public function test_public_role_not_deleteable()
public function test_public_role_not_deletable()
{
$this->asAdmin()->get('/settings/roles')
->click('Public')
->assertSee('Edit Role')
->click('Delete Role')
->press('Confirm')
->assertSee('Delete Role')
->assertSee('Cannot be deleted');
/** @var Role $publicRole */
$publicRole = Role::getSystemRole('public');
$resp = $this->asAdmin()->delete('/settings/roles/delete/' . $publicRole->id);
$resp->assertRedirect('/');
$this->get('/settings/roles/delete/' . $publicRole->id);
$resp = $this->delete('/settings/roles/delete/' . $publicRole->id);
$resp->assertRedirect('/settings/roles/delete/' . $publicRole->id);
$resp = $this->get('/settings/roles/delete/' . $publicRole->id);
$resp->assertSee('This role is a system role and cannot be deleted');
}
public function test_image_delete_own_permission()
{
$this->giveUserPermissions($this->user, ['image-update-all']);
$page = Page::first();
$image = factory(Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $this->user->id, 'updated_by' => $this->user->id]);
/** @var Page $page */
$page = Page::query()->first();
$image = factory(Image::class)->create([
'uploaded_to' => $page->id,
'created_by' => $this->user->id,
'updated_by' => $this->user->id,
]);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
->assertStatus(403);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
$this->giveUserPermissions($this->user, ['image-delete-own']);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
->assertOk()
->assertDatabaseMissing('images', ['id' => $image->id]);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertOk();
$this->assertDatabaseMissing('images', ['id' => $image->id]);
}
public function test_image_delete_all_permission()
{
$this->giveUserPermissions($this->user, ['image-update-all']);
$admin = $this->getAdmin();
$page = Page::first();
/** @var Page $page */
$page = Page::query()->first();
$image = factory(Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
->assertStatus(403);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
$this->giveUserPermissions($this->user, ['image-delete-own']);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
->assertStatus(403);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
$this->giveUserPermissions($this->user, ['image-delete-all']);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
->assertOk()
->assertDatabaseMissing('images', ['id' => $image->id]);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertOk();
$this->assertDatabaseMissing('images', ['id' => $image->id]);
}
public function test_role_permission_removal()