Merge pull request #2928 from BookStackApp/browserkit_removal
Convert old BrowserKit tests
This commit is contained in:
		
						commit
						ba075b46f9
					
				| 
						 | 
					@ -7,10 +7,11 @@ use BookStack\Traits\HasCreatorAndUpdater;
 | 
				
			||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
 | 
					use Illuminate\Database\Eloquent\Relations\MorphTo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @property string text
 | 
					 * @property int      $id
 | 
				
			||||||
 * @property string html
 | 
					 * @property string   $text
 | 
				
			||||||
 * @property int|null parent_id
 | 
					 * @property string   $html
 | 
				
			||||||
 * @property int local_id
 | 
					 * @property int|null $parent_id
 | 
				
			||||||
 | 
					 * @property int      $local_id
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class Comment extends Model
 | 
					class Comment extends Model
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
 | 
				
			||||||
 * @property string     $external_auth_id
 | 
					 * @property string     $external_auth_id
 | 
				
			||||||
 * @property string     $system_name
 | 
					 * @property string     $system_name
 | 
				
			||||||
 * @property bool       $mfa_enforced
 | 
					 * @property bool       $mfa_enforced
 | 
				
			||||||
 | 
					 * @property Collection $users
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class Role extends Model implements Loggable
 | 
					class Role extends Model implements Loggable
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,9 @@ use Illuminate\Support\Collection;
 | 
				
			||||||
 * @property string                                   $description
 | 
					 * @property string                                   $description
 | 
				
			||||||
 * @property int                                      $image_id
 | 
					 * @property int                                      $image_id
 | 
				
			||||||
 * @property Image|null                               $cover
 | 
					 * @property Image|null                               $cover
 | 
				
			||||||
 | 
					 * @property \Illuminate\Database\Eloquent\Collection $chapters
 | 
				
			||||||
 | 
					 * @property \Illuminate\Database\Eloquent\Collection $pages
 | 
				
			||||||
 | 
					 * @property \Illuminate\Database\Eloquent\Collection $directPages
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class Book extends Entity implements HasCoverImage
 | 
					class Book extends Entity implements HasCoverImage
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ class StoppedAuthenticationException extends \Exception implements Responsable
 | 
				
			||||||
            ], 401);
 | 
					            ], 401);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (session()->get('sent-email-confirmation') === true) {
 | 
					        if (session()->pull('sent-email-confirmation') === true) {
 | 
				
			||||||
            return redirect('/register/confirm');
 | 
					            return redirect('/register/confirm');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@
 | 
				
			||||||
        "facade/ignition": "^1.16.4",
 | 
					        "facade/ignition": "^1.16.4",
 | 
				
			||||||
        "fideloper/proxy": "^4.4.1",
 | 
					        "fideloper/proxy": "^4.4.1",
 | 
				
			||||||
        "intervention/image": "^2.5.1",
 | 
					        "intervention/image": "^2.5.1",
 | 
				
			||||||
        "laravel/framework": "^6.20.16",
 | 
					        "laravel/framework": "^6.20.33",
 | 
				
			||||||
        "laravel/socialite": "^5.1",
 | 
					        "laravel/socialite": "^5.1",
 | 
				
			||||||
        "league/commonmark": "^1.5",
 | 
					        "league/commonmark": "^1.5",
 | 
				
			||||||
        "league/flysystem-aws-s3-v3": "^1.0.29",
 | 
					        "league/flysystem-aws-s3-v3": "^1.0.29",
 | 
				
			||||||
| 
						 | 
					@ -41,9 +41,9 @@
 | 
				
			||||||
        "barryvdh/laravel-debugbar": "^3.5.1",
 | 
					        "barryvdh/laravel-debugbar": "^3.5.1",
 | 
				
			||||||
        "barryvdh/laravel-ide-helper": "^2.8.2",
 | 
					        "barryvdh/laravel-ide-helper": "^2.8.2",
 | 
				
			||||||
        "fakerphp/faker": "^1.13.0",
 | 
					        "fakerphp/faker": "^1.13.0",
 | 
				
			||||||
        "laravel/browser-kit-testing": "^5.2",
 | 
					 | 
				
			||||||
        "mockery/mockery": "^1.3.3",
 | 
					        "mockery/mockery": "^1.3.3",
 | 
				
			||||||
        "phpunit/phpunit": "^9.5.3"
 | 
					        "phpunit/phpunit": "^9.5.3",
 | 
				
			||||||
 | 
					        "symfony/dom-crawler": "^5.3"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "autoload": {
 | 
					    "autoload": {
 | 
				
			||||||
        "classmap": [
 | 
					        "classmap": [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,23 +4,74 @@
 | 
				
			||||||
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
 | 
					        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
 | 
				
			||||||
        "This file is @generated automatically"
 | 
					        "This file is @generated automatically"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "content-hash": "4d845f3c8b77c8d73bf92c9223ddd805",
 | 
					    "content-hash": "10825887b8f66d1d412b92bcc0ca864f",
 | 
				
			||||||
    "packages": [
 | 
					    "packages": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "aws/aws-sdk-php",
 | 
					            "name": "aws/aws-crt-php",
 | 
				
			||||||
            "version": "3.191.8",
 | 
					            "version": "v1.0.2",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/aws/aws-sdk-php.git",
 | 
					                "url": "https://github.com/awslabs/aws-crt-php.git",
 | 
				
			||||||
                "reference": "949feb83cc0db46f07b12aa3128d47be3b9cca63"
 | 
					                "reference": "3942776a8c99209908ee0b287746263725685732"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/949feb83cc0db46f07b12aa3128d47be3b9cca63",
 | 
					                "url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/3942776a8c99209908ee0b287746263725685732",
 | 
				
			||||||
                "reference": "949feb83cc0db46f07b12aa3128d47be3b9cca63",
 | 
					                "reference": "3942776a8c99209908ee0b287746263725685732",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "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-json": "*",
 | 
				
			||||||
                "ext-pcre": "*",
 | 
					                "ext-pcre": "*",
 | 
				
			||||||
                "ext-simplexml": "*",
 | 
					                "ext-simplexml": "*",
 | 
				
			||||||
| 
						 | 
					@ -92,9 +143,9 @@
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
 | 
					                "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
 | 
				
			||||||
                "issues": "https://github.com/aws/aws-sdk-php/issues",
 | 
					                "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",
 | 
					            "name": "bacon/bacon-qr-code",
 | 
				
			||||||
| 
						 | 
					@ -428,16 +479,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "doctrine/dbal",
 | 
					            "name": "doctrine/dbal",
 | 
				
			||||||
            "version": "2.13.2",
 | 
					            "version": "2.13.3",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/doctrine/dbal.git",
 | 
					                "url": "https://github.com/doctrine/dbal.git",
 | 
				
			||||||
                "reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4"
 | 
					                "reference": "0d7adf4cadfee6f70850e5b163e6cdd706417838"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/doctrine/dbal/zipball/8dd39d2ead4409ce652fd4f02621060f009ea5e4",
 | 
					                "url": "https://api.github.com/repos/doctrine/dbal/zipball/0d7adf4cadfee6f70850e5b163e6cdd706417838",
 | 
				
			||||||
                "reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4",
 | 
					                "reference": "0d7adf4cadfee6f70850e5b163e6cdd706417838",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -449,13 +500,14 @@
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require-dev": {
 | 
					            "require-dev": {
 | 
				
			||||||
                "doctrine/coding-standard": "9.0.0",
 | 
					                "doctrine/coding-standard": "9.0.0",
 | 
				
			||||||
                "jetbrains/phpstorm-stubs": "2020.2",
 | 
					                "jetbrains/phpstorm-stubs": "2021.1",
 | 
				
			||||||
                "phpstan/phpstan": "0.12.81",
 | 
					                "phpstan/phpstan": "0.12.96",
 | 
				
			||||||
                "phpunit/phpunit": "^7.5.20|^8.5|9.5.5",
 | 
					                "phpunit/phpunit": "^7.5.20|^8.5|9.5.5",
 | 
				
			||||||
 | 
					                "psalm/plugin-phpunit": "0.16.1",
 | 
				
			||||||
                "squizlabs/php_codesniffer": "3.6.0",
 | 
					                "squizlabs/php_codesniffer": "3.6.0",
 | 
				
			||||||
                "symfony/cache": "^4.4",
 | 
					                "symfony/cache": "^4.4",
 | 
				
			||||||
                "symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
 | 
					                "symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
 | 
				
			||||||
                "vimeo/psalm": "4.6.4"
 | 
					                "vimeo/psalm": "4.10.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "suggest": {
 | 
					            "suggest": {
 | 
				
			||||||
                "symfony/console": "For helpful console commands such as SQL execution and import of files."
 | 
					                "symfony/console": "For helpful console commands such as SQL execution and import of files."
 | 
				
			||||||
| 
						 | 
					@ -516,7 +568,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/doctrine/dbal/issues",
 | 
					                "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": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -532,7 +584,7 @@
 | 
				
			||||||
                    "type": "tidelift"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-06-18T21:48:39+00:00"
 | 
					            "time": "2021-09-12T19:11:48+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "doctrine/deprecations",
 | 
					            "name": "doctrine/deprecations",
 | 
				
			||||||
| 
						 | 
					@ -1052,16 +1104,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "facade/flare-client-php",
 | 
					            "name": "facade/flare-client-php",
 | 
				
			||||||
            "version": "1.8.1",
 | 
					            "version": "1.9.1",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/facade/flare-client-php.git",
 | 
					                "url": "https://github.com/facade/flare-client-php.git",
 | 
				
			||||||
                "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f"
 | 
					                "reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/facade/flare-client-php/zipball/47b639dc02bcfdfc4ebb83de703856fa01e35f5f",
 | 
					                "url": "https://api.github.com/repos/facade/flare-client-php/zipball/b2adf1512755637d0cef4f7d1b54301325ac78ed",
 | 
				
			||||||
                "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f",
 | 
					                "reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -1105,7 +1157,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/facade/flare-client-php/issues",
 | 
					                "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": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -1113,7 +1165,7 @@
 | 
				
			||||||
                    "type": "github"
 | 
					                    "type": "github"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-05-31T19:23:29+00:00"
 | 
					            "time": "2021-09-13T12:16:46+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "facade/ignition",
 | 
					            "name": "facade/ignition",
 | 
				
			||||||
| 
						 | 
					@ -1762,16 +1814,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "laravel/framework",
 | 
					            "name": "laravel/framework",
 | 
				
			||||||
            "version": "v6.20.33",
 | 
					            "version": "v6.20.34",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/laravel/framework.git",
 | 
					                "url": "https://github.com/laravel/framework.git",
 | 
				
			||||||
                "reference": "49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58"
 | 
					                "reference": "72a6da88c90cee793513b3fe49cf0fcb368eefa0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/laravel/framework/zipball/49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58",
 | 
					                "url": "https://api.github.com/repos/laravel/framework/zipball/72a6da88c90cee793513b3fe49cf0fcb368eefa0",
 | 
				
			||||||
                "reference": "49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58",
 | 
					                "reference": "72a6da88c90cee793513b3fe49cf0fcb368eefa0",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -1911,7 +1963,7 @@
 | 
				
			||||||
                "issues": "https://github.com/laravel/framework/issues",
 | 
					                "issues": "https://github.com/laravel/framework/issues",
 | 
				
			||||||
                "source": "https://github.com/laravel/framework"
 | 
					                "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",
 | 
					            "name": "laravel/socialite",
 | 
				
			||||||
| 
						 | 
					@ -2230,16 +2282,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "league/html-to-markdown",
 | 
					            "name": "league/html-to-markdown",
 | 
				
			||||||
            "version": "5.0.0",
 | 
					            "version": "5.0.1",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/thephpleague/html-to-markdown.git",
 | 
					                "url": "https://github.com/thephpleague/html-to-markdown.git",
 | 
				
			||||||
                "reference": "c4dbebbebe0fe454b6b38e6c683a977615bd7dc2"
 | 
					                "reference": "e5600a2c5ce7b7571b16732c7086940f56f7abec"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/c4dbebbebe0fe454b6b38e6c683a977615bd7dc2",
 | 
					                "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/e5600a2c5ce7b7571b16732c7086940f56f7abec",
 | 
				
			||||||
                "reference": "c4dbebbebe0fe454b6b38e6c683a977615bd7dc2",
 | 
					                "reference": "e5600a2c5ce7b7571b16732c7086940f56f7abec",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -2295,7 +2347,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/thephpleague/html-to-markdown/issues",
 | 
					                "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": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -2311,11 +2363,11 @@
 | 
				
			||||||
                    "type": "github"
 | 
					                    "type": "github"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    "url": "https://www.patreon.com/colinodell",
 | 
					                    "url": "https://tidelift.com/funding/github/packagist/league/html-to-markdown",
 | 
				
			||||||
                    "type": "patreon"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-03-29T01:29:08+00:00"
 | 
					            "time": "2021-09-17T20:00:27+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "league/mime-type-detection",
 | 
					            "name": "league/mime-type-detection",
 | 
				
			||||||
| 
						 | 
					@ -2451,24 +2503,24 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "monolog/monolog",
 | 
					            "name": "monolog/monolog",
 | 
				
			||||||
            "version": "2.3.2",
 | 
					            "version": "2.3.4",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/Seldaek/monolog.git",
 | 
					                "url": "https://github.com/Seldaek/monolog.git",
 | 
				
			||||||
                "reference": "71312564759a7db5b789296369c1a264efc43aad"
 | 
					                "reference": "437e7a1c50044b92773b361af77620efb76fff59"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/71312564759a7db5b789296369c1a264efc43aad",
 | 
					                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/437e7a1c50044b92773b361af77620efb76fff59",
 | 
				
			||||||
                "reference": "71312564759a7db5b789296369c1a264efc43aad",
 | 
					                "reference": "437e7a1c50044b92773b361af77620efb76fff59",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
                "php": ">=7.2",
 | 
					                "php": ">=7.2",
 | 
				
			||||||
                "psr/log": "^1.0.1"
 | 
					                "psr/log": "^1.0.1 || ^2.0 || ^3.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "provide": {
 | 
					            "provide": {
 | 
				
			||||||
                "psr/log-implementation": "1.0.0"
 | 
					                "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require-dev": {
 | 
					            "require-dev": {
 | 
				
			||||||
                "aws/aws-sdk-php": "^2.4.9 || ^3.0",
 | 
					                "aws/aws-sdk-php": "^2.4.9 || ^3.0",
 | 
				
			||||||
| 
						 | 
					@ -2483,7 +2535,7 @@
 | 
				
			||||||
                "phpunit/phpunit": "^8.5",
 | 
					                "phpunit/phpunit": "^8.5",
 | 
				
			||||||
                "predis/predis": "^1.1",
 | 
					                "predis/predis": "^1.1",
 | 
				
			||||||
                "rollbar/rollbar": "^1.3",
 | 
					                "rollbar/rollbar": "^1.3",
 | 
				
			||||||
                "ruflin/elastica": ">=0.90 <7.0.1",
 | 
					                "ruflin/elastica": ">=0.90@dev",
 | 
				
			||||||
                "swiftmailer/swiftmailer": "^5.3|^6.0"
 | 
					                "swiftmailer/swiftmailer": "^5.3|^6.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "suggest": {
 | 
					            "suggest": {
 | 
				
			||||||
| 
						 | 
					@ -2491,8 +2543,11 @@
 | 
				
			||||||
                "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
 | 
					                "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
 | 
				
			||||||
                "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
 | 
					                "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-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-mbstring": "Allow to work properly with unicode symbols",
 | 
				
			||||||
                "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
 | 
					                "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",
 | 
					                "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
 | 
				
			||||||
                "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
 | 
					                "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",
 | 
					                "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
 | 
				
			||||||
| 
						 | 
					@ -2531,7 +2586,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/Seldaek/monolog/issues",
 | 
					                "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": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -2543,7 +2598,7 @@
 | 
				
			||||||
                    "type": "tidelift"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-07-23T07:42:52+00:00"
 | 
					            "time": "2021-09-15T11:27:21+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "mtdowling/jmespath.php",
 | 
					            "name": "mtdowling/jmespath.php",
 | 
				
			||||||
| 
						 | 
					@ -2608,16 +2663,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "nesbot/carbon",
 | 
					            "name": "nesbot/carbon",
 | 
				
			||||||
            "version": "2.52.0",
 | 
					            "version": "2.53.1",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/briannesbitt/Carbon.git",
 | 
					                "url": "https://github.com/briannesbitt/Carbon.git",
 | 
				
			||||||
                "reference": "369c0e2737c56a0f39c946dd261855255a6fccbe"
 | 
					                "reference": "f4655858a784988f880c1b8c7feabbf02dfdf045"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/369c0e2737c56a0f39c946dd261855255a6fccbe",
 | 
					                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f4655858a784988f880c1b8c7feabbf02dfdf045",
 | 
				
			||||||
                "reference": "369c0e2737c56a0f39c946dd261855255a6fccbe",
 | 
					                "reference": "f4655858a784988f880c1b8c7feabbf02dfdf045",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -2629,7 +2684,7 @@
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require-dev": {
 | 
					            "require-dev": {
 | 
				
			||||||
                "doctrine/orm": "^2.7",
 | 
					                "doctrine/orm": "^2.7",
 | 
				
			||||||
                "friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
 | 
					                "friendsofphp/php-cs-fixer": "^3.0",
 | 
				
			||||||
                "kylekatarnls/multi-tester": "^2.0",
 | 
					                "kylekatarnls/multi-tester": "^2.0",
 | 
				
			||||||
                "phpmd/phpmd": "^2.9",
 | 
					                "phpmd/phpmd": "^2.9",
 | 
				
			||||||
                "phpstan/extension-installer": "^1.0",
 | 
					                "phpstan/extension-installer": "^1.0",
 | 
				
			||||||
| 
						 | 
					@ -2698,7 +2753,7 @@
 | 
				
			||||||
                    "type": "tidelift"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-08-14T19:10:52+00:00"
 | 
					            "time": "2021-09-06T09:29:23+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "nunomaduro/collision",
 | 
					            "name": "nunomaduro/collision",
 | 
				
			||||||
| 
						 | 
					@ -4492,20 +4547,20 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "symfony/css-selector",
 | 
					            "name": "symfony/css-selector",
 | 
				
			||||||
            "version": "v4.4.27",
 | 
					            "version": "v5.3.4",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/symfony/css-selector.git",
 | 
					                "url": "https://github.com/symfony/css-selector.git",
 | 
				
			||||||
                "reference": "5194f18bd80d106f11efa8f7cd0fbdcc3af96ce6"
 | 
					                "reference": "7fb120adc7f600a59027775b224c13a33530dd90"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/symfony/css-selector/zipball/5194f18bd80d106f11efa8f7cd0fbdcc3af96ce6",
 | 
					                "url": "https://api.github.com/repos/symfony/css-selector/zipball/7fb120adc7f600a59027775b224c13a33530dd90",
 | 
				
			||||||
                "reference": "5194f18bd80d106f11efa8f7cd0fbdcc3af96ce6",
 | 
					                "reference": "7fb120adc7f600a59027775b224c13a33530dd90",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
                "php": ">=7.1.3",
 | 
					                "php": ">=7.2.5",
 | 
				
			||||||
                "symfony/polyfill-php80": "^1.16"
 | 
					                "symfony/polyfill-php80": "^1.16"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "type": "library",
 | 
					            "type": "library",
 | 
				
			||||||
| 
						 | 
					@ -4538,7 +4593,7 @@
 | 
				
			||||||
            "description": "Converts CSS selectors to XPath expressions",
 | 
					            "description": "Converts CSS selectors to XPath expressions",
 | 
				
			||||||
            "homepage": "https://symfony.com",
 | 
					            "homepage": "https://symfony.com",
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "source": "https://github.com/symfony/css-selector/tree/v4.4.27"
 | 
					                "source": "https://github.com/symfony/css-selector/tree/v5.3.4"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "funding": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -4554,7 +4609,7 @@
 | 
				
			||||||
                    "type": "tidelift"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-07-21T12:19:41+00:00"
 | 
					            "time": "2021-07-21T12:38:00+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "symfony/debug",
 | 
					            "name": "symfony/debug",
 | 
				
			||||||
| 
						 | 
					@ -6884,16 +6939,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "composer/composer",
 | 
					            "name": "composer/composer",
 | 
				
			||||||
            "version": "2.1.6",
 | 
					            "version": "2.1.8",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/composer/composer.git",
 | 
					                "url": "https://github.com/composer/composer.git",
 | 
				
			||||||
                "reference": "e5cac5f9d2354d08b67f1d21c664ae70d748c603"
 | 
					                "reference": "24d38e9686092de05214cafa187dc282a5d89497"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/composer/composer/zipball/e5cac5f9d2354d08b67f1d21c664ae70d748c603",
 | 
					                "url": "https://api.github.com/repos/composer/composer/zipball/24d38e9686092de05214cafa187dc282a5d89497",
 | 
				
			||||||
                "reference": "e5cac5f9d2354d08b67f1d21c664ae70d748c603",
 | 
					                "reference": "24d38e9686092de05214cafa187dc282a5d89497",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -6962,7 +7017,7 @@
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "irc": "ircs://irc.libera.chat:6697/composer",
 | 
					                "irc": "ircs://irc.libera.chat:6697/composer",
 | 
				
			||||||
                "issues": "https://github.com/composer/composer/issues",
 | 
					                "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": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -6978,7 +7033,7 @@
 | 
				
			||||||
                    "type": "tidelift"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-08-19T15:11:08+00:00"
 | 
					            "time": "2021-09-15T11:55:15+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "composer/metadata-minifier",
 | 
					            "name": "composer/metadata-minifier",
 | 
				
			||||||
| 
						 | 
					@ -7344,21 +7399,21 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "fakerphp/faker",
 | 
					            "name": "fakerphp/faker",
 | 
				
			||||||
            "version": "v1.15.0",
 | 
					            "version": "v1.16.0",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/FakerPHP/Faker.git",
 | 
					                "url": "https://github.com/FakerPHP/Faker.git",
 | 
				
			||||||
                "reference": "89c6201c74db25fa759ff16e78a4d8f32547770e"
 | 
					                "reference": "271d384d216e5e5c468a6b28feedf95d49f83b35"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/89c6201c74db25fa759ff16e78a4d8f32547770e",
 | 
					                "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/271d384d216e5e5c468a6b28feedf95d49f83b35",
 | 
				
			||||||
                "reference": "89c6201c74db25fa759ff16e78a4d8f32547770e",
 | 
					                "reference": "271d384d216e5e5c468a6b28feedf95d49f83b35",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
                "php": "^7.1 || ^8.0",
 | 
					                "php": "^7.1 || ^8.0",
 | 
				
			||||||
                "psr/container": "^1.0",
 | 
					                "psr/container": "^1.0 || ^2.0",
 | 
				
			||||||
                "symfony/deprecation-contracts": "^2.2"
 | 
					                "symfony/deprecation-contracts": "^2.2"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "conflict": {
 | 
					            "conflict": {
 | 
				
			||||||
| 
						 | 
					@ -7378,7 +7433,7 @@
 | 
				
			||||||
            "type": "library",
 | 
					            "type": "library",
 | 
				
			||||||
            "extra": {
 | 
					            "extra": {
 | 
				
			||||||
                "branch-alias": {
 | 
					                "branch-alias": {
 | 
				
			||||||
                    "dev-main": "v1.15-dev"
 | 
					                    "dev-main": "v1.16-dev"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "autoload": {
 | 
					            "autoload": {
 | 
				
			||||||
| 
						 | 
					@ -7403,9 +7458,9 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/FakerPHP/Faker/issues",
 | 
					                "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",
 | 
					            "name": "hamcrest/hamcrest-php",
 | 
				
			||||||
| 
						 | 
					@ -7528,71 +7583,6 @@
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "time": "2021-07-22T09:24:00+00:00"
 | 
					            "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",
 | 
					            "name": "maximebf/debugbar",
 | 
				
			||||||
            "version": "v1.17.1",
 | 
					            "version": "v1.17.1",
 | 
				
			||||||
| 
						 | 
					@ -7660,16 +7650,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "mockery/mockery",
 | 
					            "name": "mockery/mockery",
 | 
				
			||||||
            "version": "1.4.3",
 | 
					            "version": "1.4.4",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/mockery/mockery.git",
 | 
					                "url": "https://github.com/mockery/mockery.git",
 | 
				
			||||||
                "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea"
 | 
					                "reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea",
 | 
					                "url": "https://api.github.com/repos/mockery/mockery/zipball/e01123a0e847d52d186c5eb4b9bf58b0c6d00346",
 | 
				
			||||||
                "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea",
 | 
					                "reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -7726,9 +7716,9 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/mockery/mockery/issues",
 | 
					                "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",
 | 
					            "name": "myclabs/deep-copy",
 | 
				
			||||||
| 
						 | 
					@ -8066,16 +8056,16 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "phpdocumentor/type-resolver",
 | 
					            "name": "phpdocumentor/type-resolver",
 | 
				
			||||||
            "version": "1.4.0",
 | 
					            "version": "1.5.0",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/phpDocumentor/TypeResolver.git",
 | 
					                "url": "https://github.com/phpDocumentor/TypeResolver.git",
 | 
				
			||||||
                "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
 | 
					                "reference": "30f38bffc6f24293dadd1823936372dfa9e86e2f"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
 | 
					                "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/30f38bffc6f24293dadd1823936372dfa9e86e2f",
 | 
				
			||||||
                "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
 | 
					                "reference": "30f38bffc6f24293dadd1823936372dfa9e86e2f",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
| 
						 | 
					@ -8083,7 +8073,8 @@
 | 
				
			||||||
                "phpdocumentor/reflection-common": "^2.0"
 | 
					                "phpdocumentor/reflection-common": "^2.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require-dev": {
 | 
					            "require-dev": {
 | 
				
			||||||
                "ext-tokenizer": "*"
 | 
					                "ext-tokenizer": "*",
 | 
				
			||||||
 | 
					                "psalm/phar": "^4.8"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "type": "library",
 | 
					            "type": "library",
 | 
				
			||||||
            "extra": {
 | 
					            "extra": {
 | 
				
			||||||
| 
						 | 
					@ -8109,39 +8100,39 @@
 | 
				
			||||||
            "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
 | 
					            "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/phpDocumentor/TypeResolver/issues",
 | 
					                "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",
 | 
					            "name": "phpspec/prophecy",
 | 
				
			||||||
            "version": "1.13.0",
 | 
					            "version": "1.14.0",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/phpspec/prophecy.git",
 | 
					                "url": "https://github.com/phpspec/prophecy.git",
 | 
				
			||||||
                "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
 | 
					                "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
 | 
					                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
 | 
				
			||||||
                "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
 | 
					                "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
                "doctrine/instantiator": "^1.2",
 | 
					                "doctrine/instantiator": "^1.2",
 | 
				
			||||||
                "php": "^7.2 || ~8.0, <8.1",
 | 
					                "php": "^7.2 || ~8.0, <8.2",
 | 
				
			||||||
                "phpdocumentor/reflection-docblock": "^5.2",
 | 
					                "phpdocumentor/reflection-docblock": "^5.2",
 | 
				
			||||||
                "sebastian/comparator": "^3.0 || ^4.0",
 | 
					                "sebastian/comparator": "^3.0 || ^4.0",
 | 
				
			||||||
                "sebastian/recursion-context": "^3.0 || ^4.0"
 | 
					                "sebastian/recursion-context": "^3.0 || ^4.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require-dev": {
 | 
					            "require-dev": {
 | 
				
			||||||
                "phpspec/phpspec": "^6.0",
 | 
					                "phpspec/phpspec": "^6.0 || ^7.0",
 | 
				
			||||||
                "phpunit/phpunit": "^8.0 || ^9.0"
 | 
					                "phpunit/phpunit": "^8.0 || ^9.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "type": "library",
 | 
					            "type": "library",
 | 
				
			||||||
            "extra": {
 | 
					            "extra": {
 | 
				
			||||||
                "branch-alias": {
 | 
					                "branch-alias": {
 | 
				
			||||||
                    "dev-master": "1.11.x-dev"
 | 
					                    "dev-master": "1.x-dev"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "autoload": {
 | 
					            "autoload": {
 | 
				
			||||||
| 
						 | 
					@ -8176,29 +8167,29 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/phpspec/prophecy/issues",
 | 
					                "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",
 | 
					            "name": "phpunit/php-code-coverage",
 | 
				
			||||||
            "version": "9.2.6",
 | 
					            "version": "9.2.7",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
 | 
					                "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
 | 
				
			||||||
                "reference": "f6293e1b30a2354e8428e004689671b83871edde"
 | 
					                "reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
 | 
					                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d4c798ed8d51506800b441f7a13ecb0f76f12218",
 | 
				
			||||||
                "reference": "f6293e1b30a2354e8428e004689671b83871edde",
 | 
					                "reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
                "ext-dom": "*",
 | 
					                "ext-dom": "*",
 | 
				
			||||||
                "ext-libxml": "*",
 | 
					                "ext-libxml": "*",
 | 
				
			||||||
                "ext-xmlwriter": "*",
 | 
					                "ext-xmlwriter": "*",
 | 
				
			||||||
                "nikic/php-parser": "^4.10.2",
 | 
					                "nikic/php-parser": "^4.12.0",
 | 
				
			||||||
                "php": ">=7.3",
 | 
					                "php": ">=7.3",
 | 
				
			||||||
                "phpunit/php-file-iterator": "^3.0.3",
 | 
					                "phpunit/php-file-iterator": "^3.0.3",
 | 
				
			||||||
                "phpunit/php-text-template": "^2.0.2",
 | 
					                "phpunit/php-text-template": "^2.0.2",
 | 
				
			||||||
| 
						 | 
					@ -8247,7 +8238,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
 | 
					                "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": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -8255,7 +8246,7 @@
 | 
				
			||||||
                    "type": "github"
 | 
					                    "type": "github"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-03-28T07:26:59+00:00"
 | 
					            "time": "2021-09-17T05:39:03+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "phpunit/php-file-iterator",
 | 
					            "name": "phpunit/php-file-iterator",
 | 
				
			||||||
| 
						 | 
					@ -9728,20 +9719,21 @@
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "symfony/dom-crawler",
 | 
					            "name": "symfony/dom-crawler",
 | 
				
			||||||
            "version": "v4.4.30",
 | 
					            "version": "v5.3.7",
 | 
				
			||||||
            "source": {
 | 
					            "source": {
 | 
				
			||||||
                "type": "git",
 | 
					                "type": "git",
 | 
				
			||||||
                "url": "https://github.com/symfony/dom-crawler.git",
 | 
					                "url": "https://github.com/symfony/dom-crawler.git",
 | 
				
			||||||
                "reference": "4632ae3567746c7e915c33c67a2fb6ab746090c4"
 | 
					                "reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "dist": {
 | 
					            "dist": {
 | 
				
			||||||
                "type": "zip",
 | 
					                "type": "zip",
 | 
				
			||||||
                "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4632ae3567746c7e915c33c67a2fb6ab746090c4",
 | 
					                "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c7eef3a60ccfdd8eafe07f81652e769ac9c7146c",
 | 
				
			||||||
                "reference": "4632ae3567746c7e915c33c67a2fb6ab746090c4",
 | 
					                "reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c",
 | 
				
			||||||
                "shasum": ""
 | 
					                "shasum": ""
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require": {
 | 
					            "require": {
 | 
				
			||||||
                "php": ">=7.1.3",
 | 
					                "php": ">=7.2.5",
 | 
				
			||||||
 | 
					                "symfony/deprecation-contracts": "^2.1",
 | 
				
			||||||
                "symfony/polyfill-ctype": "~1.8",
 | 
					                "symfony/polyfill-ctype": "~1.8",
 | 
				
			||||||
                "symfony/polyfill-mbstring": "~1.0",
 | 
					                "symfony/polyfill-mbstring": "~1.0",
 | 
				
			||||||
                "symfony/polyfill-php80": "^1.16"
 | 
					                "symfony/polyfill-php80": "^1.16"
 | 
				
			||||||
| 
						 | 
					@ -9751,7 +9743,7 @@
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "require-dev": {
 | 
					            "require-dev": {
 | 
				
			||||||
                "masterminds/html5": "^2.6",
 | 
					                "masterminds/html5": "^2.6",
 | 
				
			||||||
                "symfony/css-selector": "^3.4|^4.0|^5.0"
 | 
					                "symfony/css-selector": "^4.4|^5.0"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "suggest": {
 | 
					            "suggest": {
 | 
				
			||||||
                "symfony/css-selector": ""
 | 
					                "symfony/css-selector": ""
 | 
				
			||||||
| 
						 | 
					@ -9782,7 +9774,7 @@
 | 
				
			||||||
            "description": "Eases DOM navigation for HTML and XML documents",
 | 
					            "description": "Eases DOM navigation for HTML and XML documents",
 | 
				
			||||||
            "homepage": "https://symfony.com",
 | 
					            "homepage": "https://symfony.com",
 | 
				
			||||||
            "support": {
 | 
					            "support": {
 | 
				
			||||||
                "source": "https://github.com/symfony/dom-crawler/tree/v4.4.30"
 | 
					                "source": "https://github.com/symfony/dom-crawler/tree/v5.3.7"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "funding": [
 | 
					            "funding": [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -9798,7 +9790,7 @@
 | 
				
			||||||
                    "type": "tidelift"
 | 
					                    "type": "tidelift"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "time": "2021-08-28T15:40:01+00:00"
 | 
					            "time": "2021-08-29T19:32:13+00:00"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "symfony/filesystem",
 | 
					            "name": "symfony/filesystem",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,37 +0,0 @@
 | 
				
			||||||
<?php
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Tests;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use BookStack\Entities\Models\Book;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ActivityTrackingTest extends BrowserKitTest
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public function test_recently_viewed_books()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $books = Book::all()->take(10);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit('/books')
 | 
					 | 
				
			||||||
            ->dontSeeInElement('#recents', $books[0]->name)
 | 
					 | 
				
			||||||
            ->dontSeeInElement('#recents', $books[1]->name)
 | 
					 | 
				
			||||||
            ->visit($books[0]->getUrl())
 | 
					 | 
				
			||||||
            ->visit($books[1]->getUrl())
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            ->seeInElement('#recents', $books[0]->name)
 | 
					 | 
				
			||||||
            ->seeInElement('#recents', $books[1]->name);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_popular_books()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $books = Book::all()->take(10);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit('/books')
 | 
					 | 
				
			||||||
            ->dontSeeInElement('#popular', $books[0]->name)
 | 
					 | 
				
			||||||
            ->dontSeeInElement('#popular', $books[1]->name)
 | 
					 | 
				
			||||||
            ->visit($books[0]->getUrl())
 | 
					 | 
				
			||||||
            ->visit($books[1]->getUrl())
 | 
					 | 
				
			||||||
            ->visit($books[0]->getUrl())
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            ->seeInNthElement('#popular .book', 0, $books[0]->name)
 | 
					 | 
				
			||||||
            ->seeInNthElement('#popular .book', 1, $books[1]->name);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -3,49 +3,41 @@
 | 
				
			||||||
namespace Tests\Auth;
 | 
					namespace Tests\Auth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use BookStack\Auth\Access\Mfa\MfaSession;
 | 
					use BookStack\Auth\Access\Mfa\MfaSession;
 | 
				
			||||||
use BookStack\Auth\Role;
 | 
					 | 
				
			||||||
use BookStack\Auth\User;
 | 
					use BookStack\Auth\User;
 | 
				
			||||||
use BookStack\Entities\Models\Page;
 | 
					use BookStack\Entities\Models\Page;
 | 
				
			||||||
use BookStack\Notifications\ConfirmEmail;
 | 
					use BookStack\Notifications\ConfirmEmail;
 | 
				
			||||||
use BookStack\Notifications\ResetPassword;
 | 
					use BookStack\Notifications\ResetPassword;
 | 
				
			||||||
use BookStack\Settings\SettingService;
 | 
					 | 
				
			||||||
use DB;
 | 
					use DB;
 | 
				
			||||||
use Hash;
 | 
					 | 
				
			||||||
use Illuminate\Support\Facades\Notification;
 | 
					use Illuminate\Support\Facades\Notification;
 | 
				
			||||||
use Illuminate\Support\Str;
 | 
					use Tests\TestCase;
 | 
				
			||||||
use Tests\BrowserKitTest;
 | 
					use Tests\TestResponse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AuthTest extends BrowserKitTest
 | 
					class AuthTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public function test_auth_working()
 | 
					    public function test_auth_working()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->visit('/')
 | 
					        $this->get('/')->assertRedirect('/login');
 | 
				
			||||||
            ->seePageIs('/login');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_login()
 | 
					    public function test_login()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->login('admin@admin.com', 'password')
 | 
					        $this->login('admin@admin.com', 'password')->assertRedirect('/');
 | 
				
			||||||
            ->seePageIs('/');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_public_viewing()
 | 
					    public function test_public_viewing()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $settings = app(SettingService::class);
 | 
					        $this->setSettings(['app-public' => 'true']);
 | 
				
			||||||
        $settings->put('app-public', 'true');
 | 
					        $this->get('/')
 | 
				
			||||||
        $this->visit('/')
 | 
					            ->assertOk()
 | 
				
			||||||
            ->seePageIs('/')
 | 
					            ->assertSee('Log in');
 | 
				
			||||||
            ->see('Log In');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_registration_showing()
 | 
					    public function test_registration_showing()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // Ensure registration form is showing
 | 
					        // Ensure registration form is showing
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true']);
 | 
					        $this->setSettings(['registration-enabled' => 'true']);
 | 
				
			||||||
        $this->visit('/login')
 | 
					        $this->get('/login')
 | 
				
			||||||
            ->see('Sign up')
 | 
					            ->assertElementContains('a[href="' . url('/register') . '"]', 'Sign up');
 | 
				
			||||||
            ->click('Sign up')
 | 
					 | 
				
			||||||
            ->seePageIs('/register');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_normal_registration()
 | 
					    public function test_normal_registration()
 | 
				
			||||||
| 
						 | 
					@ -55,15 +47,17 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        $user = factory(User::class)->make();
 | 
					        $user = factory(User::class)->make();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Test form and ensure user is created
 | 
					        // Test form and ensure user is created
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->get('/register')
 | 
				
			||||||
            ->see('Sign Up')
 | 
					            ->assertSee('Sign Up')
 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					            ->assertElementContains('form[action="' . url('/register') . '"]', 'Create Account');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					        $resp = $this->post('/register', $user->only('password', 'name', 'email'));
 | 
				
			||||||
            ->press('Create Account')
 | 
					        $resp->assertRedirect('/');
 | 
				
			||||||
            ->seePageIs('/')
 | 
					
 | 
				
			||||||
            ->see($user->name)
 | 
					        $resp = $this->get('/');
 | 
				
			||||||
            ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email]);
 | 
					        $resp->assertOk();
 | 
				
			||||||
 | 
					        $resp->assertSee($user->name);
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('users', ['name' => $user->name, 'email' => $user->email]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_empty_registration_redirects_back_with_errors()
 | 
					    public function test_empty_registration_redirects_back_with_errors()
 | 
				
			||||||
| 
						 | 
					@ -72,36 +66,33 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true']);
 | 
					        $this->setSettings(['registration-enabled' => 'true']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Test form and ensure user is created
 | 
					        // Test form and ensure user is created
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->get('/register');
 | 
				
			||||||
            ->press('Create Account')
 | 
					        $this->post('/register', [])->assertRedirect('/register');
 | 
				
			||||||
            ->see('The name field is required')
 | 
					        $this->get('/register')->assertSee('The name field is required');
 | 
				
			||||||
            ->seePageIs('/register');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_registration_validation()
 | 
					    public function test_registration_validation()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true']);
 | 
					        $this->setSettings(['registration-enabled' => 'true']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->get('/register');
 | 
				
			||||||
            ->type('1', '#name')
 | 
					        $resp = $this->followingRedirects()->post('/register', [
 | 
				
			||||||
            ->type('1', '#email')
 | 
					            'name'     => '1',
 | 
				
			||||||
            ->type('1', '#password')
 | 
					            'email'    => '1',
 | 
				
			||||||
            ->press('Create Account')
 | 
					            'password' => '1',
 | 
				
			||||||
            ->see('The name must be at least 2 characters.')
 | 
					        ]);
 | 
				
			||||||
            ->see('The email must be a valid email address.')
 | 
					        $resp->assertSee('The name must be at least 2 characters.');
 | 
				
			||||||
            ->see('The password must be at least 8 characters.')
 | 
					        $resp->assertSee('The email must be a valid email address.');
 | 
				
			||||||
            ->seePageIs('/register');
 | 
					        $resp->assertSee('The password must be at least 8 characters.');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_sign_up_link_on_login()
 | 
					    public function test_sign_up_link_on_login()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->visit('/login')
 | 
					        $this->get('/login')->assertDontSee('Sign up');
 | 
				
			||||||
            ->dontSee('Sign up');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true']);
 | 
					        $this->setSettings(['registration-enabled' => 'true']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/login')
 | 
					        $this->get('/login')->assertSee('Sign up');
 | 
				
			||||||
            ->see('Sign up');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_confirmed_registration()
 | 
					    public function test_confirmed_registration()
 | 
				
			||||||
| 
						 | 
					@ -114,27 +105,24 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        $user = factory(User::class)->make();
 | 
					        $user = factory(User::class)->make();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Go through registration process
 | 
					        // Go through registration process
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $resp = $this->post('/register', $user->only('name', 'email', 'password'));
 | 
				
			||||||
            ->see('Sign Up')
 | 
					        $resp->assertRedirect('/register/confirm');
 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					        $this->assertDatabaseHas('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					 | 
				
			||||||
            ->press('Create Account')
 | 
					 | 
				
			||||||
            ->seePageIs('/register/confirm')
 | 
					 | 
				
			||||||
            ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Ensure notification sent
 | 
					        // Ensure notification sent
 | 
				
			||||||
        $dbUser = User::where('email', '=', $user->email)->first();
 | 
					        /** @var User $dbUser */
 | 
				
			||||||
 | 
					        $dbUser = User::query()->where('email', '=', $user->email)->first();
 | 
				
			||||||
        Notification::assertSentTo($dbUser, ConfirmEmail::class);
 | 
					        Notification::assertSentTo($dbUser, ConfirmEmail::class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Test access and resend confirmation email
 | 
					        // Test access and resend confirmation email
 | 
				
			||||||
        $this->login($user->email, $user->password)
 | 
					        $resp = $this->login($user->email, $user->password);
 | 
				
			||||||
            ->seePageIs('/register/confirm/awaiting')
 | 
					        $resp->assertRedirect('/register/confirm/awaiting');
 | 
				
			||||||
            ->see('Resend')
 | 
					
 | 
				
			||||||
            ->visit('/books')
 | 
					        $resp = $this->get('/register/confirm/awaiting');
 | 
				
			||||||
            ->seePageIs('/login')
 | 
					        $resp->assertElementContains('form[action="' . url('/register/confirm/resend') . '"]', 'Resend');
 | 
				
			||||||
            ->visit('/register/confirm/awaiting')
 | 
					
 | 
				
			||||||
            ->press('Resend Confirmation Email');
 | 
					        $this->get('/books')->assertRedirect('/login');
 | 
				
			||||||
 | 
					        $this->post('/register/confirm/resend', $user->only('email'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Get confirmation and confirm notification matches
 | 
					        // Get confirmation and confirm notification matches
 | 
				
			||||||
        $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
 | 
					        $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
 | 
				
			||||||
| 
						 | 
					@ -143,188 +131,69 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Check confirmation email confirmation activation.
 | 
					        // Check confirmation email confirmation activation.
 | 
				
			||||||
        $this->visit('/register/confirm/' . $emailConfirmation->token)
 | 
					        $this->get('/register/confirm/' . $emailConfirmation->token)->assertRedirect('/');
 | 
				
			||||||
            ->seePageIs('/')
 | 
					        $this->get('/')->assertSee($user->name);
 | 
				
			||||||
            ->see($user->name)
 | 
					        $this->assertDatabaseMissing('email_confirmations', ['token' => $emailConfirmation->token]);
 | 
				
			||||||
            ->notSeeInDatabase('email_confirmations', ['token' => $emailConfirmation->token])
 | 
					        $this->assertDatabaseHas('users', ['name' => $dbUser->name, 'email' => $dbUser->email, 'email_confirmed' => true]);
 | 
				
			||||||
            ->seeInDatabase('users', ['name' => $dbUser->name, 'email' => $dbUser->email, 'email_confirmed' => true]);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_restricted_registration()
 | 
					    public function test_restricted_registration()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true', 'registration-restrict' => 'example.com']);
 | 
					        $this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true', 'registration-restrict' => 'example.com']);
 | 
				
			||||||
        $user = factory(User::class)->make();
 | 
					        $user = factory(User::class)->make();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Go through registration process
 | 
					        // Go through registration process
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->post('/register', $user->only('name', 'email', 'password'))
 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					            ->assertRedirect('/register');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					        $resp = $this->get('/register');
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					        $resp->assertSee('That email domain does not have access to this application');
 | 
				
			||||||
            ->press('Create Account')
 | 
					        $this->assertDatabaseMissing('users', $user->only('email'));
 | 
				
			||||||
            ->seePageIs('/register')
 | 
					 | 
				
			||||||
            ->dontSeeInDatabase('users', ['email' => $user->email])
 | 
					 | 
				
			||||||
            ->see('That email domain does not have access to this application');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user->email = 'barry@example.com';
 | 
					        $user->email = 'barry@example.com';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->post('/register', $user->only('name', 'email', 'password'))
 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					            ->assertRedirect('/register/confirm');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					        $this->assertDatabaseHas('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					 | 
				
			||||||
            ->press('Create Account')
 | 
					 | 
				
			||||||
            ->seePageIs('/register/confirm')
 | 
					 | 
				
			||||||
            ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->assertNull(auth()->user());
 | 
					        $this->assertNull(auth()->user());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/')->seePageIs('/login')
 | 
					        $this->get('/')->assertRedirect('/login');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					        $resp = $this->followingRedirects()->post('/login', $user->only('email', 'password'));
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					        $resp->assertSee('Email Address Not Confirmed');
 | 
				
			||||||
            ->press('Log In')
 | 
					        $this->assertNull(auth()->user());
 | 
				
			||||||
            ->seePageIs('/register/confirm/awaiting')
 | 
					 | 
				
			||||||
            ->seeText('Email Address Not Confirmed');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_restricted_registration_with_confirmation_disabled()
 | 
					    public function test_restricted_registration_with_confirmation_disabled()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'false', 'registration-restrict' => 'example.com']);
 | 
					        $this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'false', 'registration-restrict' => 'example.com']);
 | 
				
			||||||
        $user = factory(User::class)->make();
 | 
					        $user = factory(User::class)->make();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Go through registration process
 | 
					        // Go through registration process
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->post('/register', $user->only('name', 'email', 'password'))
 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					            ->assertRedirect('/register');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					        $this->assertDatabaseMissing('users', $user->only('email'));
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					        $this->get('/register')->assertSee('That email domain does not have access to this application');
 | 
				
			||||||
            ->press('Create Account')
 | 
					 | 
				
			||||||
            ->seePageIs('/register')
 | 
					 | 
				
			||||||
            ->dontSeeInDatabase('users', ['email' => $user->email])
 | 
					 | 
				
			||||||
            ->see('That email domain does not have access to this application');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user->email = 'barry@example.com';
 | 
					        $user->email = 'barry@example.com';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/register')
 | 
					        $this->post('/register', $user->only('name', 'email', 'password'))
 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					            ->assertRedirect('/register/confirm');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					        $this->assertDatabaseHas('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					 | 
				
			||||||
            ->press('Create Account')
 | 
					 | 
				
			||||||
            ->seePageIs('/register/confirm')
 | 
					 | 
				
			||||||
            ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->assertNull(auth()->user());
 | 
					        $this->assertNull(auth()->user());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/')->seePageIs('/login')
 | 
					        $this->get('/')->assertRedirect('/login');
 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					        $resp = $this->post('/login', $user->only('email', 'password'));
 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					        $resp->assertRedirect('/register/confirm/awaiting');
 | 
				
			||||||
            ->press('Log In')
 | 
					        $this->get('/register/confirm/awaiting')->assertSee('Email Address Not Confirmed');
 | 
				
			||||||
            ->seePageIs('/register/confirm/awaiting')
 | 
					        $this->assertNull(auth()->user());
 | 
				
			||||||
            ->seeText('Email Address Not Confirmed');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_user_creation()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        /** @var User $user */
 | 
					 | 
				
			||||||
        $user = factory(User::class)->make();
 | 
					 | 
				
			||||||
        $adminRole = Role::getRole('admin');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit('/settings/users')
 | 
					 | 
				
			||||||
            ->click('Add New User')
 | 
					 | 
				
			||||||
            ->type($user->name, '#name')
 | 
					 | 
				
			||||||
            ->type($user->email, '#email')
 | 
					 | 
				
			||||||
            ->check("roles[{$adminRole->id}]")
 | 
					 | 
				
			||||||
            ->type($user->password, '#password')
 | 
					 | 
				
			||||||
            ->type($user->password, '#password-confirm')
 | 
					 | 
				
			||||||
            ->press('Save')
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users')
 | 
					 | 
				
			||||||
            ->seeInDatabase('users', $user->only(['name', 'email']))
 | 
					 | 
				
			||||||
            ->see($user->name);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $user->refresh();
 | 
					 | 
				
			||||||
        $this->assertStringStartsWith(Str::slug($user->name), $user->slug);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_user_updating()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $user = $this->getNormalUser();
 | 
					 | 
				
			||||||
        $password = $user->password;
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit('/settings/users')
 | 
					 | 
				
			||||||
            ->click($user->name)
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users/' . $user->id)
 | 
					 | 
				
			||||||
            ->see($user->email)
 | 
					 | 
				
			||||||
            ->type('Barry Scott', '#name')
 | 
					 | 
				
			||||||
            ->press('Save')
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users')
 | 
					 | 
				
			||||||
            ->seeInDatabase('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password])
 | 
					 | 
				
			||||||
            ->notSeeInDatabase('users', ['name' => $user->name]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $user->refresh();
 | 
					 | 
				
			||||||
        $this->assertStringStartsWith(Str::slug($user->name), $user->slug);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_user_password_update()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $user = $this->getNormalUser();
 | 
					 | 
				
			||||||
        $userProfilePage = '/settings/users/' . $user->id;
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit($userProfilePage)
 | 
					 | 
				
			||||||
            ->type('newpassword', '#password')
 | 
					 | 
				
			||||||
            ->press('Save')
 | 
					 | 
				
			||||||
            ->seePageIs($userProfilePage)
 | 
					 | 
				
			||||||
            ->see('Password confirmation required')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ->type('newpassword', '#password')
 | 
					 | 
				
			||||||
            ->type('newpassword', '#password-confirm')
 | 
					 | 
				
			||||||
            ->press('Save')
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $userPassword = User::find($user->id)->password;
 | 
					 | 
				
			||||||
        $this->assertTrue(Hash::check('newpassword', $userPassword));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_user_deletion()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $userDetails = factory(User::class)->make();
 | 
					 | 
				
			||||||
        $user = $this->getEditor($userDetails->toArray());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit('/settings/users/' . $user->id)
 | 
					 | 
				
			||||||
            ->click('Delete User')
 | 
					 | 
				
			||||||
            ->see($user->name)
 | 
					 | 
				
			||||||
            ->press('Confirm')
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users')
 | 
					 | 
				
			||||||
            ->notSeeInDatabase('users', ['name' => $user->name]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_user_cannot_be_deleted_if_last_admin()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $adminRole = Role::getRole('admin');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Delete all but one admin user if there are more than one
 | 
					 | 
				
			||||||
        $adminUsers = $adminRole->users;
 | 
					 | 
				
			||||||
        if (count($adminUsers) > 1) {
 | 
					 | 
				
			||||||
            foreach ($adminUsers->splice(1) as $user) {
 | 
					 | 
				
			||||||
                $user->delete();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Ensure we currently only have 1 admin user
 | 
					 | 
				
			||||||
        $this->assertEquals(1, $adminRole->users()->count());
 | 
					 | 
				
			||||||
        $user = $adminRole->users->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit('/settings/users/' . $user->id)
 | 
					 | 
				
			||||||
            ->click('Delete User')
 | 
					 | 
				
			||||||
            ->press('Confirm')
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users/' . $user->id)
 | 
					 | 
				
			||||||
            ->see('You cannot delete the only admin');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_logout()
 | 
					    public function test_logout()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->asAdmin()
 | 
					        $this->asAdmin()->get('/')->assertOk();
 | 
				
			||||||
            ->visit('/')
 | 
					        $this->get('/logout')->assertRedirect('/');
 | 
				
			||||||
            ->seePageIs('/')
 | 
					        $this->get('/')->assertRedirect('/login');
 | 
				
			||||||
            ->visit('/logout')
 | 
					 | 
				
			||||||
            ->visit('/')
 | 
					 | 
				
			||||||
            ->seePageIs('/login');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_mfa_session_cleared_on_logout()
 | 
					    public function test_mfa_session_cleared_on_logout()
 | 
				
			||||||
| 
						 | 
					@ -335,7 +204,7 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        $mfaSession->markVerifiedForUser($user);
 | 
					        $mfaSession->markVerifiedForUser($user);
 | 
				
			||||||
        $this->assertTrue($mfaSession->isVerifiedForUser($user));
 | 
					        $this->assertTrue($mfaSession->isVerifiedForUser($user));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()->visit('/logout');
 | 
					        $this->asAdmin()->get('/logout');
 | 
				
			||||||
        $this->assertFalse($mfaSession->isVerifiedForUser($user));
 | 
					        $this->assertFalse($mfaSession->isVerifiedForUser($user));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -343,69 +212,85 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Notification::fake();
 | 
					        Notification::fake();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/login')->click('Forgot Password?')
 | 
					        $this->get('/login')
 | 
				
			||||||
            ->seePageIs('/password/email')
 | 
					            ->assertElementContains('a[href="' . url('/password/email') . '"]', 'Forgot Password?');
 | 
				
			||||||
            ->type('admin@admin.com', 'email')
 | 
					 | 
				
			||||||
            ->press('Send Reset Link')
 | 
					 | 
				
			||||||
            ->see('A password reset link will be sent to admin@admin.com if that email address is found in the system.');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->seeInDatabase('password_resets', [
 | 
					        $this->get('/password/email')
 | 
				
			||||||
 | 
					            ->assertElementContains('form[action="' . url('/password/email') . '"]', 'Send Reset Link');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->post('/password/email', [
 | 
				
			||||||
 | 
					            'email' => 'admin@admin.com',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					        $resp->assertRedirect('/password/email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get('/password/email');
 | 
				
			||||||
 | 
					        $resp->assertSee('A password reset link will be sent to admin@admin.com if that email address is found in the system.');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('password_resets', [
 | 
				
			||||||
            'email' => 'admin@admin.com',
 | 
					            'email' => 'admin@admin.com',
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user = User::where('email', '=', 'admin@admin.com')->first();
 | 
					        /** @var User $user */
 | 
				
			||||||
 | 
					        $user = User::query()->where('email', '=', 'admin@admin.com')->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Notification::assertSentTo($user, ResetPassword::class);
 | 
					        Notification::assertSentTo($user, ResetPassword::class);
 | 
				
			||||||
        $n = Notification::sent($user, ResetPassword::class);
 | 
					        $n = Notification::sent($user, ResetPassword::class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/password/reset/' . $n->first()->token)
 | 
					        $this->get('/password/reset/' . $n->first()->token)
 | 
				
			||||||
            ->see('Reset Password')
 | 
					            ->assertOk()
 | 
				
			||||||
            ->submitForm('Reset Password', [
 | 
					            ->assertSee('Reset Password');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->post('/password/reset', [
 | 
				
			||||||
            'email'                 => 'admin@admin.com',
 | 
					            'email'                 => 'admin@admin.com',
 | 
				
			||||||
            'password'              => 'randompass',
 | 
					            'password'              => 'randompass',
 | 
				
			||||||
            'password_confirmation' => 'randompass',
 | 
					            'password_confirmation' => 'randompass',
 | 
				
			||||||
            ])->seePageIs('/')
 | 
					            'token'                 => $n->first()->token,
 | 
				
			||||||
            ->see('Your password has been successfully reset');
 | 
					        ]);
 | 
				
			||||||
 | 
					        $resp->assertRedirect('/');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/')->assertSee('Your password has been successfully reset');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_reset_password_flow_shows_success_message_even_if_wrong_password_to_prevent_user_discovery()
 | 
					    public function test_reset_password_flow_shows_success_message_even_if_wrong_password_to_prevent_user_discovery()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->visit('/login')->click('Forgot Password?')
 | 
					        $this->get('/password/email');
 | 
				
			||||||
            ->seePageIs('/password/email')
 | 
					        $resp = $this->followingRedirects()->post('/password/email', [
 | 
				
			||||||
            ->type('barry@admin.com', 'email')
 | 
					            'email' => 'barry@admin.com',
 | 
				
			||||||
            ->press('Send Reset Link')
 | 
					        ]);
 | 
				
			||||||
            ->see('A password reset link will be sent to barry@admin.com if that email address is found in the system.')
 | 
					        $resp->assertSee('A password reset link will be sent to barry@admin.com if that email address is found in the system.');
 | 
				
			||||||
            ->dontSee('We can\'t find a user');
 | 
					        $resp->assertDontSee('We can\'t find a user');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit('/password/reset/arandometokenvalue')
 | 
					        $this->get('/password/reset/arandometokenvalue')->assertSee('Reset Password');
 | 
				
			||||||
            ->see('Reset Password')
 | 
					        $resp = $this->post('/password/reset', [
 | 
				
			||||||
            ->submitForm('Reset Password', [
 | 
					 | 
				
			||||||
            'email'                 => 'barry@admin.com',
 | 
					            'email'                 => 'barry@admin.com',
 | 
				
			||||||
            'password'              => 'randompass',
 | 
					            'password'              => 'randompass',
 | 
				
			||||||
            'password_confirmation' => 'randompass',
 | 
					            'password_confirmation' => 'randompass',
 | 
				
			||||||
            ])->followRedirects()
 | 
					            'token'                 => 'arandometokenvalue',
 | 
				
			||||||
            ->seePageIs('/password/reset/arandometokenvalue')
 | 
					        ]);
 | 
				
			||||||
            ->dontSee('We can\'t find a user')
 | 
					        $resp->assertRedirect('/password/reset/arandometokenvalue');
 | 
				
			||||||
            ->see('The password reset token is invalid for this email address.');
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/password/reset/arandometokenvalue')
 | 
				
			||||||
 | 
					            ->assertDontSee('We can\'t find a user')
 | 
				
			||||||
 | 
					            ->assertSee('The password reset token is invalid for this email address.');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_reset_password_page_shows_sign_links()
 | 
					    public function test_reset_password_page_shows_sign_links()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->setSettings(['registration-enabled' => 'true']);
 | 
					        $this->setSettings(['registration-enabled' => 'true']);
 | 
				
			||||||
        $this->visit('/password/email')
 | 
					        $this->get('/password/email')
 | 
				
			||||||
            ->seeLink('Log in')
 | 
					            ->assertElementContains('a', 'Log in')
 | 
				
			||||||
            ->seeLink('Sign up');
 | 
					            ->assertElementContains('a', 'Sign up');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_login_redirects_to_initially_requested_url_correctly()
 | 
					    public function test_login_redirects_to_initially_requested_url_correctly()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        config()->set('app.url', 'http://localhost');
 | 
					        config()->set('app.url', 'http://localhost');
 | 
				
			||||||
 | 
					        /** @var Page $page */
 | 
				
			||||||
        $page = Page::query()->first();
 | 
					        $page = Page::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->visit($page->getUrl())
 | 
					        $this->get($page->getUrl())->assertRedirect(url('/login'));
 | 
				
			||||||
            ->seePageUrlIs(url('/login'));
 | 
					 | 
				
			||||||
        $this->login('admin@admin.com', 'password')
 | 
					        $this->login('admin@admin.com', 'password')
 | 
				
			||||||
            ->seePageUrlIs($page->getUrl());
 | 
					            ->assertRedirect($page->getUrl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_login_intended_redirect_does_not_redirect_to_external_pages()
 | 
					    public function test_login_intended_redirect_does_not_redirect_to_external_pages()
 | 
				
			||||||
| 
						 | 
					@ -416,15 +301,15 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        $this->get('/login', ['referer' => 'https://example.com']);
 | 
					        $this->get('/login', ['referer' => 'https://example.com']);
 | 
				
			||||||
        $login = $this->post('/login', ['email' => 'admin@admin.com', 'password' => 'password']);
 | 
					        $login = $this->post('/login', ['email' => 'admin@admin.com', 'password' => 'password']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $login->assertRedirectedTo('http://localhost');
 | 
					        $login->assertRedirect('http://localhost');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_login_intended_redirect_does_not_factor_mfa_routes()
 | 
					    public function test_login_intended_redirect_does_not_factor_mfa_routes()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->get('/books')->assertRedirectedTo('/login');
 | 
					        $this->get('/books')->assertRedirect('/login');
 | 
				
			||||||
        $this->get('/mfa/setup')->assertRedirectedTo('/login');
 | 
					        $this->get('/mfa/setup')->assertRedirect('/login');
 | 
				
			||||||
        $login = $this->post('/login', ['email' => 'admin@admin.com', 'password' => 'password']);
 | 
					        $login = $this->post('/login', ['email' => 'admin@admin.com', 'password' => 'password']);
 | 
				
			||||||
        $login->assertRedirectedTo('/books');
 | 
					        $login->assertRedirect('/books');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_login_authenticates_admins_on_all_guards()
 | 
					    public function test_login_authenticates_admins_on_all_guards()
 | 
				
			||||||
| 
						 | 
					@ -469,20 +354,15 @@ class AuthTest extends BrowserKitTest
 | 
				
			||||||
        auth()->login($user);
 | 
					        auth()->login($user);
 | 
				
			||||||
        $this->assertTrue(auth()->check());
 | 
					        $this->assertTrue(auth()->check());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->get('/books');
 | 
					        $this->get('/books')->assertRedirect('/');
 | 
				
			||||||
        $this->assertRedirectedTo('/');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->assertFalse(auth()->check());
 | 
					        $this->assertFalse(auth()->check());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Perform a login.
 | 
					     * Perform a login.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected function login(string $email, string $password): AuthTest
 | 
					    protected function login(string $email, string $password): TestResponse
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->visit('/login')
 | 
					        return $this->post('/login', compact('email', 'password'));
 | 
				
			||||||
            ->type($email, '#email')
 | 
					 | 
				
			||||||
            ->type($password, '#password')
 | 
					 | 
				
			||||||
            ->press('Log In');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,218 +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);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Create a group of entities that belong to a specific user.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected function createEntityChainBelongingToUser(User $creatorUser, ?User $updaterUser = null): array
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (empty($updaterUser)) {
 | 
					 | 
				
			||||||
            $updaterUser = $creatorUser;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $userAttrs = ['created_by' => $creatorUser->id, 'owned_by' => $creatorUser->id, 'updated_by' => $updaterUser->id];
 | 
					 | 
				
			||||||
        $book = factory(Book::class)->create($userAttrs);
 | 
					 | 
				
			||||||
        $chapter = factory(Chapter::class)->create(array_merge(['book_id' => $book->id], $userAttrs));
 | 
					 | 
				
			||||||
        $page = factory(Page::class)->create(array_merge(['book_id' => $book->id, 'chapter_id' => $chapter->id], $userAttrs));
 | 
					 | 
				
			||||||
        $restrictionService = $this->app[PermissionService::class];
 | 
					 | 
				
			||||||
        $restrictionService->buildJointPermissionsForEntity($book);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return compact('book', 'chapter', 'page');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Helper for updating entity permissions.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param Entity $entity
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected function updateEntityPermissions(Entity $entity)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $restrictionService = $this->app[PermissionService::class];
 | 
					 | 
				
			||||||
        $restrictionService->buildJointPermissionsForEntity($entity);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Quick way to create a new user without any permissions.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param array $attributes
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return mixed
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected function getNewBlankUser($attributes = [])
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $user = factory(User::class)->create($attributes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $user;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -369,4 +369,12 @@ class BookShelfTest extends TestCase
 | 
				
			||||||
        $resp = $this->asEditor()->get($newBook->getUrl());
 | 
					        $resp = $this->asEditor()->get($newBook->getUrl());
 | 
				
			||||||
        $resp->assertDontSee($shelfInfo['name']);
 | 
					        $resp->assertDontSee($shelfInfo['name']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_cancel_on_child_book_creation_returns_to_original_shelf()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Bookshelf $shelf */
 | 
				
			||||||
 | 
					        $shelf = Bookshelf::query()->first();
 | 
				
			||||||
 | 
					        $resp = $this->asEditor()->get($shelf->getUrl('/create-book'));
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form a[href="' . $shelf->getUrl() . '"]', 'Cancel');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,69 @@ use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BookTest extends TestCase
 | 
					class BookTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public function test_book_delete()
 | 
					    public function test_create()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $book = factory(Book::class)->make([
 | 
				
			||||||
 | 
					            'name' => 'My First Book',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asEditor()->get('/books');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('a[href="' . url('/create-book') . '"]', 'Create New Book');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get('/create-book');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action="' . url('/books') . '"][method="POST"]', 'Save Book');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->post('/books', $book->only('name', 'description'));
 | 
				
			||||||
 | 
					        $resp->assertRedirect('/books/my-first-book');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get('/books/my-first-book');
 | 
				
			||||||
 | 
					        $resp->assertSee($book->name);
 | 
				
			||||||
 | 
					        $resp->assertSee($book->description);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_create_uses_different_slugs_when_name_reused()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $book = factory(Book::class)->make([
 | 
				
			||||||
 | 
					            'name' => 'My First Book',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asEditor()->post('/books', $book->only('name', 'description'));
 | 
				
			||||||
 | 
					        $this->asEditor()->post('/books', $book->only('name', 'description'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $books = Book::query()->where('name', '=', $book->name)
 | 
				
			||||||
 | 
					            ->orderBy('id', 'desc')
 | 
				
			||||||
 | 
					            ->take(2)
 | 
				
			||||||
 | 
					            ->get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertMatchesRegularExpression('/my-first-book-[0-9a-zA-Z]{3}/', $books[0]->slug);
 | 
				
			||||||
 | 
					        $this->assertEquals('my-first-book', $books[1]->slug);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_update()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Book $book */
 | 
				
			||||||
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
 | 
					        // Cheeky initial update to refresh slug
 | 
				
			||||||
 | 
					        $this->asEditor()->put($book->getUrl(), ['name' => $book->name . '5', 'description' => $book->description]);
 | 
				
			||||||
 | 
					        $book->refresh();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $newName = $book->name . ' Updated';
 | 
				
			||||||
 | 
					        $newDesc = $book->description . ' with more content';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($book->getUrl('/edit'));
 | 
				
			||||||
 | 
					        $resp->assertSee($book->name);
 | 
				
			||||||
 | 
					        $resp->assertSee($book->description);
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action="' . $book->getUrl() . '"]', 'Save Book');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->put($book->getUrl(), ['name' => $newName, 'description' => $newDesc]);
 | 
				
			||||||
 | 
					        $resp->assertRedirect($book->getUrl() . '-updated');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($book->getUrl() . '-updated');
 | 
				
			||||||
 | 
					        $resp->assertSee($newName);
 | 
				
			||||||
 | 
					        $resp->assertSee($newDesc);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_delete()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $book = Book::query()->whereHas('pages')->whereHas('chapters')->first();
 | 
					        $book = Book::query()->whereHas('pages')->whereHas('chapters')->first();
 | 
				
			||||||
        $this->assertNull($book->deleted_at);
 | 
					        $this->assertNull($book->deleted_at);
 | 
				
			||||||
| 
						 | 
					@ -34,6 +96,20 @@ class BookTest extends TestCase
 | 
				
			||||||
        $redirectReq->assertNotificationContains('Book Successfully Deleted');
 | 
					        $redirectReq->assertNotificationContains('Book Successfully Deleted');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_cancel_on_create_page_leads_back_to_books_listing()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $resp = $this->asEditor()->get('/create-book');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form a[href="' . url('/books') . '"]', 'Cancel');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_cancel_on_edit_book_page_leads_back_to_book()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Book $book */
 | 
				
			||||||
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
 | 
					        $resp = $this->asEditor()->get($book->getUrl('/edit'));
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form a[href="' . $book->getUrl() . '"]', 'Cancel');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_next_previous_navigation_controls_show_within_book_content()
 | 
					    public function test_next_previous_navigation_controls_show_within_book_content()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $book = Book::query()->first();
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
| 
						 | 
					@ -48,4 +124,84 @@ class BookTest extends TestCase
 | 
				
			||||||
        $resp->assertElementContains('#sibling-navigation', 'Previous');
 | 
					        $resp->assertElementContains('#sibling-navigation', 'Previous');
 | 
				
			||||||
        $resp->assertElementContains('#sibling-navigation', substr($chapter->name, 0, 20));
 | 
					        $resp->assertElementContains('#sibling-navigation', substr($chapter->name, 0, 20));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_recently_viewed_books_updates_as_expected()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $books = Book::all()->take(2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asAdmin()->get('/books')
 | 
				
			||||||
 | 
					            ->assertElementNotContains('#recents', $books[0]->name)
 | 
				
			||||||
 | 
					            ->assertElementNotContains('#recents', $books[1]->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get($books[0]->getUrl());
 | 
				
			||||||
 | 
					        $this->get($books[1]->getUrl());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/books')
 | 
				
			||||||
 | 
					            ->assertElementContains('#recents', $books[0]->name)
 | 
				
			||||||
 | 
					            ->assertElementContains('#recents', $books[1]->name);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_popular_books_updates_upon_visits()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $books = Book::all()->take(2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asAdmin()->get('/books')
 | 
				
			||||||
 | 
					            ->assertElementNotContains('#popular', $books[0]->name)
 | 
				
			||||||
 | 
					            ->assertElementNotContains('#popular', $books[1]->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get($books[0]->getUrl());
 | 
				
			||||||
 | 
					        $this->get($books[1]->getUrl());
 | 
				
			||||||
 | 
					        $this->get($books[0]->getUrl());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/books')
 | 
				
			||||||
 | 
					            ->assertElementContains('#popular .book:nth-child(1)', $books[0]->name)
 | 
				
			||||||
 | 
					            ->assertElementContains('#popular .book:nth-child(2)', $books[1]->name);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_books_view_shows_view_toggle_option()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Book $book */
 | 
				
			||||||
 | 
					        $editor = $this->getEditor();
 | 
				
			||||||
 | 
					        setting()->putUser($editor, 'books_view_type', 'list');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->actingAs($editor)->get('/books');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'Grid View');
 | 
				
			||||||
 | 
					        $resp->assertElementExists('input[name="view_type"][value="grid"]');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->patch("/settings/users/{$editor->id}/switch-books-view", ['view_type' => 'grid']);
 | 
				
			||||||
 | 
					        $resp->assertRedirect();
 | 
				
			||||||
 | 
					        $this->assertEquals('grid', setting()->getUser($editor, 'books_view_type'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->actingAs($editor)->get('/books');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'List View');
 | 
				
			||||||
 | 
					        $resp->assertElementExists('input[name="view_type"][value="list"]');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->patch("/settings/users/{$editor->id}/switch-books-view", ['view_type' => 'list']);
 | 
				
			||||||
 | 
					        $resp->assertRedirect();
 | 
				
			||||||
 | 
					        $this->assertEquals('list', setting()->getUser($editor, 'books_view_type'));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_slug_multi_byte_url_safe()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $book = $this->newBook([
 | 
				
			||||||
 | 
					            'name' => 'информация',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertEquals('informatsiya', $book->slug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $book = $this->newBook([
 | 
				
			||||||
 | 
					            'name' => '¿Qué?',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertEquals('que', $book->slug);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_slug_format()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $book = $this->newBook([
 | 
				
			||||||
 | 
					            'name' => 'PartA / PartB / PartC',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertEquals('parta-partb-partc', $book->slug);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,12 +2,36 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Tests\Entity;
 | 
					namespace Tests\Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Book;
 | 
				
			||||||
use BookStack\Entities\Models\Chapter;
 | 
					use BookStack\Entities\Models\Chapter;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ChapterTest extends TestCase
 | 
					class ChapterTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public function test_chapter_delete()
 | 
					    public function test_create()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Book $book */
 | 
				
			||||||
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $chapter = factory(Chapter::class)->make([
 | 
				
			||||||
 | 
					            'name' => 'My First Chapter',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asEditor()->get($book->getUrl());
 | 
				
			||||||
 | 
					        $resp->assertElementContains('a[href="' . $book->getUrl('/create-chapter') . '"]', 'New Chapter');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($book->getUrl('/create-chapter'));
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action="' . $book->getUrl('/create-chapter') . '"][method="POST"]', 'Save Chapter');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->post($book->getUrl('/create-chapter'), $chapter->only('name', 'description'));
 | 
				
			||||||
 | 
					        $resp->assertRedirect($book->getUrl('/chapter/my-first-chapter'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($book->getUrl('/chapter/my-first-chapter'));
 | 
				
			||||||
 | 
					        $resp->assertSee($chapter->name);
 | 
				
			||||||
 | 
					        $resp->assertSee($chapter->description);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_delete()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $chapter = Chapter::query()->whereHas('pages')->first();
 | 
					        $chapter = Chapter::query()->whereHas('pages')->first();
 | 
				
			||||||
        $this->assertNull($chapter->deleted_at);
 | 
					        $this->assertNull($chapter->deleted_at);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,52 @@
 | 
				
			||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Tests\Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use BookStack\Auth\UserRepo;
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Entity;
 | 
				
			||||||
 | 
					use BookStack\Entities\Repos\PageRepo;
 | 
				
			||||||
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class EntityAccessTest extends TestCase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public function test_entities_viewable_after_creator_deletion()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Create required assets and revisions
 | 
				
			||||||
 | 
					        $creator = $this->getEditor();
 | 
				
			||||||
 | 
					        $updater = $this->getViewer();
 | 
				
			||||||
 | 
					        $entities = $this->createEntityChainBelongingToUser($creator, $updater);
 | 
				
			||||||
 | 
					        app()->make(UserRepo::class)->destroy($creator);
 | 
				
			||||||
 | 
					        app()->make(PageRepo::class)->update($entities['page'], ['html' => '<p>hello!</p>>']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->checkEntitiesViewable($entities);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_entities_viewable_after_updater_deletion()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Create required assets and revisions
 | 
				
			||||||
 | 
					        $creator = $this->getViewer();
 | 
				
			||||||
 | 
					        $updater = $this->getEditor();
 | 
				
			||||||
 | 
					        $entities = $this->createEntityChainBelongingToUser($creator, $updater);
 | 
				
			||||||
 | 
					        app()->make(UserRepo::class)->destroy($updater);
 | 
				
			||||||
 | 
					        app()->make(PageRepo::class)->update($entities['page'], ['html' => '<p>Hello there!</p>']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->checkEntitiesViewable($entities);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @param array<string, Entity> $entities
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private function checkEntitiesViewable(array $entities)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Check pages and books are visible.
 | 
				
			||||||
 | 
					        $this->asAdmin();
 | 
				
			||||||
 | 
					        foreach ($entities as $entity) {
 | 
				
			||||||
 | 
					            $this->get($entity->getUrl())
 | 
				
			||||||
 | 
					                ->assertStatus(200)
 | 
				
			||||||
 | 
					                ->assertSee($entity->name);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Check revision listing shows no errors.
 | 
				
			||||||
 | 
					        $this->get($entities['page']->getUrl('/revisions'))->assertStatus(200);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,319 +0,0 @@
 | 
				
			||||||
<?php
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Tests\Entity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use BookStack\Auth\UserRepo;
 | 
					 | 
				
			||||||
use BookStack\Entities\Models\Book;
 | 
					 | 
				
			||||||
use BookStack\Entities\Models\Bookshelf;
 | 
					 | 
				
			||||||
use BookStack\Entities\Models\Chapter;
 | 
					 | 
				
			||||||
use BookStack\Entities\Models\Page;
 | 
					 | 
				
			||||||
use BookStack\Entities\Repos\PageRepo;
 | 
					 | 
				
			||||||
use Carbon\Carbon;
 | 
					 | 
				
			||||||
use Tests\BrowserKitTest;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class EntityTest extends BrowserKitTest
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public function test_entity_creation()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // Test Creation
 | 
					 | 
				
			||||||
        $book = $this->bookCreation();
 | 
					 | 
				
			||||||
        $chapter = $this->chapterCreation($book);
 | 
					 | 
				
			||||||
        $this->pageCreation($chapter);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Test Updating
 | 
					 | 
				
			||||||
        $this->bookUpdate($book);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function bookUpdate(Book $book)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $newName = $book->name . ' Updated';
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            // Go to edit screen
 | 
					 | 
				
			||||||
            ->visit($book->getUrl() . '/edit')
 | 
					 | 
				
			||||||
            ->see($book->name)
 | 
					 | 
				
			||||||
            // Submit new name
 | 
					 | 
				
			||||||
            ->type($newName, '#name')
 | 
					 | 
				
			||||||
            ->press('Save Book')
 | 
					 | 
				
			||||||
            // Check page url and text
 | 
					 | 
				
			||||||
            ->seePageIs($book->getUrl() . '-updated')
 | 
					 | 
				
			||||||
            ->see($newName);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return Book::find($book->id);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_book_sort_page_shows()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $books = Book::all();
 | 
					 | 
				
			||||||
        $bookToSort = $books[0];
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit($bookToSort->getUrl())
 | 
					 | 
				
			||||||
            ->click('Sort')
 | 
					 | 
				
			||||||
            ->seePageIs($bookToSort->getUrl() . '/sort')
 | 
					 | 
				
			||||||
            ->seeStatusCode(200)
 | 
					 | 
				
			||||||
            ->see($bookToSort->name);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_book_sort_item_returns_book_content()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $books = Book::all();
 | 
					 | 
				
			||||||
        $bookToSort = $books[0];
 | 
					 | 
				
			||||||
        $firstPage = $bookToSort->pages[0];
 | 
					 | 
				
			||||||
        $firstChapter = $bookToSort->chapters[0];
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit($bookToSort->getUrl() . '/sort-item')
 | 
					 | 
				
			||||||
            // Ensure book details are returned
 | 
					 | 
				
			||||||
            ->see($bookToSort->name)
 | 
					 | 
				
			||||||
            ->see($firstPage->name)
 | 
					 | 
				
			||||||
            ->see($firstChapter->name);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_toggle_book_view()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $editor = $this->getEditor();
 | 
					 | 
				
			||||||
        setting()->putUser($editor, 'books_view_type', 'grid');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->actingAs($editor)
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            ->pageHasElement('.featured-image-container')
 | 
					 | 
				
			||||||
            ->submitForm('List View')
 | 
					 | 
				
			||||||
            // Check redirection.
 | 
					 | 
				
			||||||
            ->seePageIs('/books')
 | 
					 | 
				
			||||||
            ->pageNotHasElement('.featured-image-container');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->actingAs($editor)
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            ->submitForm('Grid View')
 | 
					 | 
				
			||||||
            ->seePageIs('/books')
 | 
					 | 
				
			||||||
            ->pageHasElement('.featured-image-container');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function pageCreation($chapter)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $page = factory(Page::class)->make([
 | 
					 | 
				
			||||||
            'name' => 'My First Page',
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            // Navigate to page create form
 | 
					 | 
				
			||||||
            ->visit($chapter->getUrl())
 | 
					 | 
				
			||||||
            ->click('New Page');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $draftPage = Page::where('draft', '=', true)->orderBy('created_at', 'desc')->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->seePageIs($draftPage->getUrl())
 | 
					 | 
				
			||||||
            // Fill out form
 | 
					 | 
				
			||||||
            ->type($page->name, '#name')
 | 
					 | 
				
			||||||
            ->type($page->html, '#html')
 | 
					 | 
				
			||||||
            ->press('Save Page')
 | 
					 | 
				
			||||||
            // Check redirect and page
 | 
					 | 
				
			||||||
            ->seePageIs($chapter->book->getUrl() . '/page/my-first-page')
 | 
					 | 
				
			||||||
            ->see($page->name);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $page = Page::where('slug', '=', 'my-first-page')->where('chapter_id', '=', $chapter->id)->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $page;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function chapterCreation(Book $book)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $chapter = factory(Chapter::class)->make([
 | 
					 | 
				
			||||||
            'name' => 'My First Chapter',
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            // Navigate to chapter create page
 | 
					 | 
				
			||||||
            ->visit($book->getUrl())
 | 
					 | 
				
			||||||
            ->click('New Chapter')
 | 
					 | 
				
			||||||
            ->seePageIs($book->getUrl() . '/create-chapter')
 | 
					 | 
				
			||||||
            // Fill out form
 | 
					 | 
				
			||||||
            ->type($chapter->name, '#name')
 | 
					 | 
				
			||||||
            ->type($chapter->description, '#description')
 | 
					 | 
				
			||||||
            ->press('Save Chapter')
 | 
					 | 
				
			||||||
            // Check redirect and landing page
 | 
					 | 
				
			||||||
            ->seePageIs($book->getUrl() . '/chapter/my-first-chapter')
 | 
					 | 
				
			||||||
            ->see($chapter->name)->see($chapter->description);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $chapter = Chapter::where('slug', '=', 'my-first-chapter')->where('book_id', '=', $book->id)->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $chapter;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function bookCreation()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $book = factory(Book::class)->make([
 | 
					 | 
				
			||||||
            'name' => 'My First Book',
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            // Choose to create a book
 | 
					 | 
				
			||||||
            ->click('Create New Book')
 | 
					 | 
				
			||||||
            ->seePageIs('/create-book')
 | 
					 | 
				
			||||||
            // Fill out form & save
 | 
					 | 
				
			||||||
            ->type($book->name, '#name')
 | 
					 | 
				
			||||||
            ->type($book->description, '#description')
 | 
					 | 
				
			||||||
            ->press('Save Book')
 | 
					 | 
				
			||||||
            // Check it redirects correctly
 | 
					 | 
				
			||||||
            ->seePageIs('/books/my-first-book')
 | 
					 | 
				
			||||||
            ->see($book->name)->see($book->description);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Ensure duplicate names are given different slugs
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit('/create-book')
 | 
					 | 
				
			||||||
            ->type($book->name, '#name')
 | 
					 | 
				
			||||||
            ->type($book->description, '#description')
 | 
					 | 
				
			||||||
            ->press('Save Book');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $expectedPattern = '/\/books\/my-first-book-[0-9a-zA-Z]{3}/';
 | 
					 | 
				
			||||||
        $this->assertMatchesRegularExpression($expectedPattern, $this->currentUri, "Did not land on expected page [$expectedPattern].\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $book = Book::where('slug', '=', 'my-first-book')->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $book;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_entities_viewable_after_creator_deletion()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // Create required assets and revisions
 | 
					 | 
				
			||||||
        $creator = $this->getEditor();
 | 
					 | 
				
			||||||
        $updater = $this->getEditor();
 | 
					 | 
				
			||||||
        $entities = $this->createEntityChainBelongingToUser($creator, $updater);
 | 
					 | 
				
			||||||
        $this->actingAs($creator);
 | 
					 | 
				
			||||||
        app(UserRepo::class)->destroy($creator);
 | 
					 | 
				
			||||||
        app(PageRepo::class)->update($entities['page'], ['html' => '<p>hello!</p>>']);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->checkEntitiesViewable($entities);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_entities_viewable_after_updater_deletion()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // Create required assets and revisions
 | 
					 | 
				
			||||||
        $creator = $this->getEditor();
 | 
					 | 
				
			||||||
        $updater = $this->getEditor();
 | 
					 | 
				
			||||||
        $entities = $this->createEntityChainBelongingToUser($creator, $updater);
 | 
					 | 
				
			||||||
        $this->actingAs($updater);
 | 
					 | 
				
			||||||
        app(UserRepo::class)->destroy($updater);
 | 
					 | 
				
			||||||
        app(PageRepo::class)->update($entities['page'], ['html' => '<p>Hello there!</p>']);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->checkEntitiesViewable($entities);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function checkEntitiesViewable($entities)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // Check pages and books are visible.
 | 
					 | 
				
			||||||
        $this->asAdmin();
 | 
					 | 
				
			||||||
        $this->visit($entities['book']->getUrl())->seeStatusCode(200)
 | 
					 | 
				
			||||||
            ->visit($entities['chapter']->getUrl())->seeStatusCode(200)
 | 
					 | 
				
			||||||
            ->visit($entities['page']->getUrl())->seeStatusCode(200);
 | 
					 | 
				
			||||||
        // Check revision listing shows no errors.
 | 
					 | 
				
			||||||
        $this->visit($entities['page']->getUrl())
 | 
					 | 
				
			||||||
            ->click('Revisions')->seeStatusCode(200);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_recently_updated_pages_view()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $user = $this->getEditor();
 | 
					 | 
				
			||||||
        $content = $this->createEntityChainBelongingToUser($user);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit('/pages/recently-updated')
 | 
					 | 
				
			||||||
            ->seeInNthElement('.entity-list .page', 0, $content['page']->name);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_old_page_slugs_redirect_to_new_pages()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $page = Page::first();
 | 
					 | 
				
			||||||
        $pageUrl = $page->getUrl();
 | 
					 | 
				
			||||||
        $newPageUrl = '/books/' . $page->book->slug . '/page/super-test-page';
 | 
					 | 
				
			||||||
        // Need to save twice since revisions are not generated in seeder.
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit($pageUrl)
 | 
					 | 
				
			||||||
            ->clickInElement('#content', 'Edit')
 | 
					 | 
				
			||||||
            ->type('super test', '#name')
 | 
					 | 
				
			||||||
            ->press('Save Page');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $page = Page::first();
 | 
					 | 
				
			||||||
        $pageUrl = $page->getUrl();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Second Save
 | 
					 | 
				
			||||||
        $this->visit($pageUrl)
 | 
					 | 
				
			||||||
            ->clickInElement('#content', 'Edit')
 | 
					 | 
				
			||||||
            ->type('super test page', '#name')
 | 
					 | 
				
			||||||
            ->press('Save Page')
 | 
					 | 
				
			||||||
            // Check redirect
 | 
					 | 
				
			||||||
            ->seePageIs($newPageUrl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->visit($pageUrl)
 | 
					 | 
				
			||||||
            ->seePageIs($newPageUrl);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_recently_updated_pages_on_home()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $page = Page::orderBy('updated_at', 'asc')->first();
 | 
					 | 
				
			||||||
        Page::where('id', '!=', $page->id)->update([
 | 
					 | 
				
			||||||
            'updated_at' => Carbon::now()->subSecond(1),
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit('/')
 | 
					 | 
				
			||||||
            ->dontSeeInElement('#recently-updated-pages', $page->name);
 | 
					 | 
				
			||||||
        $this->visit($page->getUrl() . '/edit')
 | 
					 | 
				
			||||||
            ->press('Save Page')
 | 
					 | 
				
			||||||
            ->visit('/')
 | 
					 | 
				
			||||||
            ->seeInElement('#recently-updated-pages', $page->name);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_slug_multi_byte_url_safe()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $book = $this->newBook([
 | 
					 | 
				
			||||||
            'name' => 'информация',
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->assertEquals('informatsiya', $book->slug);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $book = $this->newBook([
 | 
					 | 
				
			||||||
            'name' => '¿Qué?',
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->assertEquals('que', $book->slug);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_slug_format()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $book = $this->newBook([
 | 
					 | 
				
			||||||
            'name' => 'PartA / PartB / PartC',
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->assertEquals('parta-partb-partc', $book->slug);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_shelf_cancel_creation_returns_to_correct_place()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $shelf = Bookshelf::first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Cancel button from shelf goes back to shelf
 | 
					 | 
				
			||||||
        $this->asEditor()->visit($shelf->getUrl('/create-book'))
 | 
					 | 
				
			||||||
            ->see('Cancel')
 | 
					 | 
				
			||||||
            ->click('Cancel')
 | 
					 | 
				
			||||||
            ->seePageIs($shelf->getUrl());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Cancel button from books goes back to books
 | 
					 | 
				
			||||||
        $this->asEditor()->visit('/create-book')
 | 
					 | 
				
			||||||
            ->see('Cancel')
 | 
					 | 
				
			||||||
            ->click('Cancel')
 | 
					 | 
				
			||||||
            ->seePageIs('/books');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Cancel button from book edit goes back to book
 | 
					 | 
				
			||||||
        $book = Book::first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asEditor()->visit($book->getUrl('/edit'))
 | 
					 | 
				
			||||||
            ->see('Cancel')
 | 
					 | 
				
			||||||
            ->click('Cancel')
 | 
					 | 
				
			||||||
            ->seePageIs($book->getUrl());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_page_within_chapter_deletion_returns_to_chapter()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $chapter = Chapter::query()->first();
 | 
					 | 
				
			||||||
        $page = $chapter->pages()->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->asEditor()->visit($page->getUrl('/delete'))
 | 
					 | 
				
			||||||
            ->submitForm('Confirm')
 | 
					 | 
				
			||||||
            ->seePageIs($chapter->getUrl());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,53 +0,0 @@
 | 
				
			||||||
<?php
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Tests\Entity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use Tests\BrowserKitTest;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class MarkdownTest extends BrowserKitTest
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    protected $page;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function setUp(): void
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        parent::setUp();
 | 
					 | 
				
			||||||
        $this->page = \BookStack\Entities\Models\Page::first();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected function setMarkdownEditor()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->setSettings(['app-editor' => 'markdown']);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_default_editor_is_wysiwyg()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->assertEquals(setting('app-editor'), 'wysiwyg');
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl() . '/edit')
 | 
					 | 
				
			||||||
            ->pageHasElement('#html-editor');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_markdown_setting_shows_markdown_editor()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->setMarkdownEditor();
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl() . '/edit')
 | 
					 | 
				
			||||||
            ->pageNotHasElement('#html-editor')
 | 
					 | 
				
			||||||
            ->pageHasElement('#markdown-editor');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_markdown_content_given_to_editor()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->setMarkdownEditor();
 | 
					 | 
				
			||||||
        $mdContent = '# hello. This is a test';
 | 
					 | 
				
			||||||
        $this->page->markdown = $mdContent;
 | 
					 | 
				
			||||||
        $this->page->save();
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl() . '/edit')
 | 
					 | 
				
			||||||
            ->seeInField('markdown', $mdContent);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_html_content_given_to_editor_if_no_markdown()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->setMarkdownEditor();
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl() . '/edit')
 | 
					 | 
				
			||||||
            ->seeInField('markdown', $this->page->html);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -2,12 +2,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Tests\Entity;
 | 
					namespace Tests\Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Book;
 | 
				
			||||||
use BookStack\Entities\Models\Page;
 | 
					use BookStack\Entities\Models\Page;
 | 
				
			||||||
use BookStack\Entities\Repos\PageRepo;
 | 
					use BookStack\Entities\Repos\PageRepo;
 | 
				
			||||||
use Tests\BrowserKitTest;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PageDraftTest extends BrowserKitTest
 | 
					class PageDraftTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @var Page
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected $page;
 | 
					    protected $page;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -18,99 +22,101 @@ class PageDraftTest extends BrowserKitTest
 | 
				
			||||||
    public function setUp(): void
 | 
					    public function setUp(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        parent::setUp();
 | 
					        parent::setUp();
 | 
				
			||||||
        $this->page = \BookStack\Entities\Models\Page::first();
 | 
					        $this->page = Page::query()->first();
 | 
				
			||||||
        $this->pageRepo = app(PageRepo::class);
 | 
					        $this->pageRepo = app()->make(PageRepo::class);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_draft_content_shows_if_available()
 | 
					    public function test_draft_content_shows_if_available()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $addedContent = '<p>test message content</p>';
 | 
					        $addedContent = '<p>test message content</p>';
 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl('/edit'))
 | 
					
 | 
				
			||||||
            ->dontSeeInField('html', $addedContent);
 | 
					        $this->asAdmin()->get($this->page->getUrl('/edit'))
 | 
				
			||||||
 | 
					            ->assertElementNotContains('[name="html"]', $addedContent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $newContent = $this->page->html . $addedContent;
 | 
					        $newContent = $this->page->html . $addedContent;
 | 
				
			||||||
        $this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
 | 
					        $this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl('/edit'))
 | 
					        $this->asAdmin()->get($this->page->getUrl('/edit'))
 | 
				
			||||||
            ->seeInField('html', $newContent);
 | 
					            ->assertElementContains('[name="html"]', $newContent);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_draft_not_visible_by_others()
 | 
					    public function test_draft_not_visible_by_others()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $addedContent = '<p>test message content</p>';
 | 
					        $addedContent = '<p>test message content</p>';
 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl('/edit'))
 | 
					        $this->asAdmin()->get($this->page->getUrl('/edit'))
 | 
				
			||||||
            ->dontSeeInField('html', $addedContent);
 | 
					            ->assertElementNotContains('[name="html"]', $addedContent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $newContent = $this->page->html . $addedContent;
 | 
					        $newContent = $this->page->html . $addedContent;
 | 
				
			||||||
        $newUser = $this->getEditor();
 | 
					        $newUser = $this->getEditor();
 | 
				
			||||||
        $this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
 | 
					        $this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->actingAs($newUser)->visit($this->page->getUrl('/edit'))
 | 
					        $this->actingAs($newUser)->get($this->page->getUrl('/edit'))
 | 
				
			||||||
            ->dontSeeInField('html', $newContent);
 | 
					            ->assertElementNotContains('[name="html"]', $newContent);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_alert_message_shows_if_editing_draft()
 | 
					    public function test_alert_message_shows_if_editing_draft()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->asAdmin();
 | 
					        $this->asAdmin();
 | 
				
			||||||
        $this->pageRepo->updatePageDraft($this->page, ['html' => 'test content']);
 | 
					        $this->pageRepo->updatePageDraft($this->page, ['html' => 'test content']);
 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl('/edit'))
 | 
					        $this->asAdmin()->get($this->page->getUrl('/edit'))
 | 
				
			||||||
            ->see('You are currently editing a draft');
 | 
					            ->assertSee('You are currently editing a draft');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_alert_message_shows_if_someone_else_editing()
 | 
					    public function test_alert_message_shows_if_someone_else_editing()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $nonEditedPage = \BookStack\Entities\Models\Page::take(10)->get()->last();
 | 
					        $nonEditedPage = Page::query()->take(10)->get()->last();
 | 
				
			||||||
        $addedContent = '<p>test message content</p>';
 | 
					        $addedContent = '<p>test message content</p>';
 | 
				
			||||||
        $this->asAdmin()->visit($this->page->getUrl('/edit'))
 | 
					        $this->asAdmin()->get($this->page->getUrl('/edit'))
 | 
				
			||||||
            ->dontSeeInField('html', $addedContent);
 | 
					            ->assertElementNotContains('[name="html"]', $addedContent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $newContent = $this->page->html . $addedContent;
 | 
					        $newContent = $this->page->html . $addedContent;
 | 
				
			||||||
        $newUser = $this->getEditor();
 | 
					        $newUser = $this->getEditor();
 | 
				
			||||||
        $this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
 | 
					        $this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->actingAs($newUser)
 | 
					        $this->actingAs($newUser)
 | 
				
			||||||
            ->visit($this->page->getUrl('/edit'))
 | 
					            ->get($this->page->getUrl('/edit'))
 | 
				
			||||||
            ->see('Admin has started editing this page');
 | 
					            ->assertSee('Admin has started editing this page');
 | 
				
			||||||
        $this->flushSession();
 | 
					        $this->flushSession();
 | 
				
			||||||
        $this->visit($nonEditedPage->getUrl() . '/edit')
 | 
					        $this->get($nonEditedPage->getUrl() . '/edit')
 | 
				
			||||||
            ->dontSeeInElement('.notification', 'Admin has started editing this page');
 | 
					            ->assertElementNotContains('.notification', 'Admin has started editing this page');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_draft_pages_show_on_homepage()
 | 
					    public function test_draft_pages_show_on_homepage()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $book = \BookStack\Entities\Models\Book::first();
 | 
					        /** @var Book $book */
 | 
				
			||||||
        $this->asAdmin()->visit('/')
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
            ->dontSeeInElement('#recent-drafts', 'New Page')
 | 
					        $this->asAdmin()->get('/')
 | 
				
			||||||
            ->visit($book->getUrl() . '/create-page')
 | 
					            ->assertElementNotContains('#recent-drafts', 'New Page');
 | 
				
			||||||
            ->visit('/')
 | 
					
 | 
				
			||||||
            ->seeInElement('#recent-drafts', 'New Page');
 | 
					        $this->get($book->getUrl() . '/create-page');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/')->assertElementContains('#recent-drafts', 'New Page');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_draft_pages_not_visible_by_others()
 | 
					    public function test_draft_pages_not_visible_by_others()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $book = \BookStack\Entities\Models\Book::first();
 | 
					        /** @var Book $book */
 | 
				
			||||||
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
        $chapter = $book->chapters->first();
 | 
					        $chapter = $book->chapters->first();
 | 
				
			||||||
        $newUser = $this->getEditor();
 | 
					        $newUser = $this->getEditor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->actingAs($newUser)->visit('/')
 | 
					        $this->actingAs($newUser)->get($book->getUrl('/create-page'));
 | 
				
			||||||
            ->visit($book->getUrl('/create-page'))
 | 
					        $this->get($chapter->getUrl('/create-page'));
 | 
				
			||||||
            ->visit($chapter->getUrl('/create-page'))
 | 
					        $this->get($book->getUrl())
 | 
				
			||||||
            ->visit($book->getUrl())
 | 
					            ->assertElementContains('.book-contents', 'New Page');
 | 
				
			||||||
            ->seeInElement('.book-contents', 'New Page');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()
 | 
					        $this->asAdmin()->get($book->getUrl())
 | 
				
			||||||
            ->visit($book->getUrl())
 | 
					            ->assertElementNotContains('.book-contents', 'New Page');
 | 
				
			||||||
            ->dontSeeInElement('.book-contents', 'New Page')
 | 
					        $this->get($chapter->getUrl())
 | 
				
			||||||
            ->visit($chapter->getUrl())
 | 
					            ->assertElementNotContains('.book-contents', 'New Page');
 | 
				
			||||||
            ->dontSeeInElement('.book-contents', 'New Page');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_page_html_in_ajax_fetch_response()
 | 
					    public function test_page_html_in_ajax_fetch_response()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->asAdmin();
 | 
					        $this->asAdmin();
 | 
				
			||||||
 | 
					        /** @var Page $page */
 | 
				
			||||||
        $page = Page::query()->first();
 | 
					        $page = Page::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->getJson('/ajax/page/' . $page->id);
 | 
					        $this->getJson('/ajax/page/' . $page->id)->assertJson([
 | 
				
			||||||
        $this->seeJson([
 | 
					 | 
				
			||||||
            'html' => $page->html,
 | 
					            'html' => $page->html,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,77 @@
 | 
				
			||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Tests\Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Book;
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Page;
 | 
				
			||||||
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PageEditorTest extends TestCase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /** @var Page */
 | 
				
			||||||
 | 
					    protected $page;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function setUp(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        parent::setUp();
 | 
				
			||||||
 | 
					        $this->page = Page::query()->first();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_default_editor_is_wysiwyg()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->assertEquals('wysiwyg', setting('app-editor'));
 | 
				
			||||||
 | 
					        $this->asAdmin()->get($this->page->getUrl() . '/edit')
 | 
				
			||||||
 | 
					            ->assertElementExists('#html-editor');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_markdown_setting_shows_markdown_editor()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->setSettings(['app-editor' => 'markdown']);
 | 
				
			||||||
 | 
					        $this->asAdmin()->get($this->page->getUrl() . '/edit')
 | 
				
			||||||
 | 
					            ->assertElementNotExists('#html-editor')
 | 
				
			||||||
 | 
					            ->assertElementExists('#markdown-editor');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_markdown_content_given_to_editor()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->setSettings(['app-editor' => 'markdown']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $mdContent = '# hello. This is a test';
 | 
				
			||||||
 | 
					        $this->page->markdown = $mdContent;
 | 
				
			||||||
 | 
					        $this->page->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asAdmin()->get($this->page->getUrl() . '/edit')
 | 
				
			||||||
 | 
					            ->assertElementContains('[name="markdown"]', $mdContent);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_html_content_given_to_editor_if_no_markdown()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->setSettings(['app-editor' => 'markdown']);
 | 
				
			||||||
 | 
					        $this->asAdmin()->get($this->page->getUrl() . '/edit')
 | 
				
			||||||
 | 
					            ->assertElementContains('[name="markdown"]', $this->page->html);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_empty_markdown_still_saves_without_error()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->setSettings(['app-editor' => 'markdown']);
 | 
				
			||||||
 | 
					        /** @var Book $book */
 | 
				
			||||||
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asEditor()->get($book->getUrl('/create-page'));
 | 
				
			||||||
 | 
					        $draft = Page::query()->where('book_id', '=', $book->id)
 | 
				
			||||||
 | 
					            ->where('draft', '=', true)->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $details = [
 | 
				
			||||||
 | 
					            'name'     => 'my page',
 | 
				
			||||||
 | 
					            'markdown' => '',
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
 | 
				
			||||||
 | 
					        $resp->assertRedirect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('pages', [
 | 
				
			||||||
 | 
					            'markdown' => $details['markdown'],
 | 
				
			||||||
 | 
					            'id'       => $draft->id,
 | 
				
			||||||
 | 
					            'draft'    => false,
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -3,11 +3,40 @@
 | 
				
			||||||
namespace Tests\Entity;
 | 
					namespace Tests\Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use BookStack\Entities\Models\Book;
 | 
					use BookStack\Entities\Models\Book;
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Chapter;
 | 
				
			||||||
use BookStack\Entities\Models\Page;
 | 
					use BookStack\Entities\Models\Page;
 | 
				
			||||||
 | 
					use Carbon\Carbon;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PageTest extends TestCase
 | 
					class PageTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    public function test_create()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Chapter $chapter */
 | 
				
			||||||
 | 
					        $chapter = Chapter::query()->first();
 | 
				
			||||||
 | 
					        $page = factory(Page::class)->make([
 | 
				
			||||||
 | 
					            'name' => 'My First Page',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asEditor()->get($chapter->getUrl());
 | 
				
			||||||
 | 
					        $resp->assertElementContains('a[href="' . $chapter->getUrl('/create-page') . '"]', 'New Page');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($chapter->getUrl('/create-page'));
 | 
				
			||||||
 | 
					        /** @var Page $draftPage */
 | 
				
			||||||
 | 
					        $draftPage = Page::query()
 | 
				
			||||||
 | 
					            ->where('draft', '=', true)
 | 
				
			||||||
 | 
					            ->orderBy('created_at', 'desc')
 | 
				
			||||||
 | 
					            ->first();
 | 
				
			||||||
 | 
					        $resp->assertRedirect($draftPage->getUrl());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($draftPage->getUrl());
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action="' . $draftPage->getUrl() . '"][method="POST"]', 'Save Page');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->post($draftPage->getUrl(), $draftPage->only('name', 'html'));
 | 
				
			||||||
 | 
					        $draftPage->refresh();
 | 
				
			||||||
 | 
					        $resp->assertRedirect($draftPage->getUrl());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_page_view_when_creator_is_deleted_but_owner_exists()
 | 
					    public function test_page_view_when_creator_is_deleted_but_owner_exists()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $page = Page::query()->first();
 | 
					        $page = Page::query()->first();
 | 
				
			||||||
| 
						 | 
					@ -190,26 +219,65 @@ class PageTest extends TestCase
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_empty_markdown_still_saves_without_error()
 | 
					    public function test_old_page_slugs_redirect_to_new_pages()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->setSettings(['app-editor' => 'markdown']);
 | 
					        /** @var Page $page */
 | 
				
			||||||
        $book = Book::query()->first();
 | 
					        $page = Page::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asEditor()->get($book->getUrl('/create-page'));
 | 
					        // Need to save twice since revisions are not generated in seeder.
 | 
				
			||||||
        $draft = Page::query()->where('book_id', '=', $book->id)
 | 
					        $this->asAdmin()->put($page->getUrl(), [
 | 
				
			||||||
            ->where('draft', '=', true)->first();
 | 
					            'name' => 'super test',
 | 
				
			||||||
 | 
					            'html' => '<p></p>',
 | 
				
			||||||
        $details = [
 | 
					 | 
				
			||||||
            'name'     => 'my page',
 | 
					 | 
				
			||||||
            'markdown' => '',
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
        $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
 | 
					 | 
				
			||||||
        $resp->assertRedirect();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->assertDatabaseHas('pages', [
 | 
					 | 
				
			||||||
            'markdown' => $details['markdown'],
 | 
					 | 
				
			||||||
            'id'       => $draft->id,
 | 
					 | 
				
			||||||
            'draft'    => false,
 | 
					 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $page->refresh();
 | 
				
			||||||
 | 
					        $pageUrl = $page->getUrl();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->put($pageUrl, [
 | 
				
			||||||
 | 
					            'name' => 'super test page',
 | 
				
			||||||
 | 
					            'html' => '<p></p>',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get($pageUrl)
 | 
				
			||||||
 | 
					            ->assertRedirect("/books/{$page->book->slug}/page/super-test-page");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_page_within_chapter_deletion_returns_to_chapter()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Chapter $chapter */
 | 
				
			||||||
 | 
					        $chapter = Chapter::query()->first();
 | 
				
			||||||
 | 
					        $page = $chapter->pages()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asEditor()->delete($page->getUrl())
 | 
				
			||||||
 | 
					            ->assertRedirect($chapter->getUrl());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_recently_updated_pages_view()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $user = $this->getEditor();
 | 
				
			||||||
 | 
					        $content = $this->createEntityChainBelongingToUser($user);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asAdmin()->get('/pages/recently-updated')
 | 
				
			||||||
 | 
					            ->assertElementContains('.entity-list .page:nth-child(1)', $content['page']->name);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_recently_updated_pages_on_home()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Page $page */
 | 
				
			||||||
 | 
					        $page = Page::query()->orderBy('updated_at', 'asc')->first();
 | 
				
			||||||
 | 
					        Page::query()->where('id', '!=', $page->id)->update([
 | 
				
			||||||
 | 
					            'updated_at' => Carbon::now()->subSecond(1),
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asAdmin()->get('/')
 | 
				
			||||||
 | 
					            ->assertElementNotContains('#recently-updated-pages', $page->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->put($page->getUrl(), [
 | 
				
			||||||
 | 
					            'name' => $page->name,
 | 
				
			||||||
 | 
					            'html' => $page->html,
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/')
 | 
				
			||||||
 | 
					            ->assertElementContains('#recently-updated-pages', $page->name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -216,6 +216,19 @@ class SortTest extends TestCase
 | 
				
			||||||
        $this->assertEquals($newBook->id, $pageToCheck->book_id);
 | 
					        $this->assertEquals($newBook->id, $pageToCheck->book_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_book_sort_page_shows()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var Book $bookToSort */
 | 
				
			||||||
 | 
					        $bookToSort = Book::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->get($bookToSort->getUrl());
 | 
				
			||||||
 | 
					        $resp->assertElementExists('a[href="' . $bookToSort->getUrl('/sort') . '"]');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get($bookToSort->getUrl('/sort'));
 | 
				
			||||||
 | 
					        $resp->assertStatus(200);
 | 
				
			||||||
 | 
					        $resp->assertSee($bookToSort->name);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_book_sort()
 | 
					    public function test_book_sort()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $oldBook = Book::query()->first();
 | 
					        $oldBook = Book::query()->first();
 | 
				
			||||||
| 
						 | 
					@ -259,6 +272,21 @@ class SortTest extends TestCase
 | 
				
			||||||
        $checkResp->assertSee($newBook->name);
 | 
					        $checkResp->assertSee($newBook->name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_book_sort_item_returns_book_content()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $books = Book::all();
 | 
				
			||||||
 | 
					        $bookToSort = $books[0];
 | 
				
			||||||
 | 
					        $firstPage = $bookToSort->pages[0];
 | 
				
			||||||
 | 
					        $firstChapter = $bookToSort->chapters[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->get($bookToSort->getUrl() . '/sort-item');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Ensure book details are returned
 | 
				
			||||||
 | 
					        $resp->assertSee($bookToSort->name);
 | 
				
			||||||
 | 
					        $resp->assertSee($firstPage->name);
 | 
				
			||||||
 | 
					        $resp->assertSee($firstChapter->name);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_pages_in_book_show_sorted_by_priority()
 | 
					    public function test_pages_in_book_show_sorted_by_priority()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /** @var Book $book */
 | 
					        /** @var Book $book */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -89,7 +89,7 @@ trait SharedTestHelpers
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get a user that's not a system user such as the guest user.
 | 
					     * Get a user that's not a system user such as the guest user.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getNormalUser()
 | 
					    public function getNormalUser(): User
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return User::query()->where('system_name', '=', null)->get()->last();
 | 
					        return User::query()->where('system_name', '=', null)->get()->last();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -211,6 +211,27 @@ trait SharedTestHelpers
 | 
				
			||||||
        return $permissionRepo->saveNewRole($roleData);
 | 
					        return $permissionRepo->saveNewRole($roleData);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Create a group of entities that belong to a specific user.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return array{book: Book, chapter: Chapter, page: Page}
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function createEntityChainBelongingToUser(User $creatorUser, ?User $updaterUser = null): array
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (empty($updaterUser)) {
 | 
				
			||||||
 | 
					            $updaterUser = $creatorUser;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $userAttrs = ['created_by' => $creatorUser->id, 'owned_by' => $creatorUser->id, 'updated_by' => $updaterUser->id];
 | 
				
			||||||
 | 
					        $book = factory(Book::class)->create($userAttrs);
 | 
				
			||||||
 | 
					        $chapter = factory(Chapter::class)->create(array_merge(['book_id' => $book->id], $userAttrs));
 | 
				
			||||||
 | 
					        $page = factory(Page::class)->create(array_merge(['book_id' => $book->id, 'chapter_id' => $chapter->id], $userAttrs));
 | 
				
			||||||
 | 
					        $restrictionService = $this->app[PermissionService::class];
 | 
				
			||||||
 | 
					        $restrictionService->buildJointPermissionsForEntity($book);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return compact('book', 'chapter', 'page');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Mock the HttpFetcher service and return the given data on fetch.
 | 
					     * Mock the HttpFetcher service and return the given data on fetch.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,12 +3,112 @@
 | 
				
			||||||
namespace Tests\User;
 | 
					namespace Tests\User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use BookStack\Actions\ActivityType;
 | 
					use BookStack\Actions\ActivityType;
 | 
				
			||||||
 | 
					use BookStack\Auth\Role;
 | 
				
			||||||
use BookStack\Auth\User;
 | 
					use BookStack\Auth\User;
 | 
				
			||||||
use BookStack\Entities\Models\Page;
 | 
					use BookStack\Entities\Models\Page;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Hash;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UserManagementTest extends TestCase
 | 
					class UserManagementTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    public function test_user_creation()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /** @var User $user */
 | 
				
			||||||
 | 
					        $user = factory(User::class)->make();
 | 
				
			||||||
 | 
					        $adminRole = Role::getRole('admin');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->get('/settings/users');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('a[href="' . url('/settings/users/create') . '"]', 'Add New User');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get('/settings/users/create')
 | 
				
			||||||
 | 
					            ->assertElementContains('form[action="' . url('/settings/users/create') . '"]', 'Save');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->post('/settings/users/create', [
 | 
				
			||||||
 | 
					            'name'                          => $user->name,
 | 
				
			||||||
 | 
					            'email'                         => $user->email,
 | 
				
			||||||
 | 
					            'password'                      => $user->password,
 | 
				
			||||||
 | 
					            'password-confirm'              => $user->password,
 | 
				
			||||||
 | 
					            'roles[' . $adminRole->id . ']' => 'true',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					        $resp->assertRedirect('/settings/users');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get('/settings/users');
 | 
				
			||||||
 | 
					        $resp->assertSee($user->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('users', $user->only('name', 'email'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $user->refresh();
 | 
				
			||||||
 | 
					        $this->assertStringStartsWith(Str::slug($user->name), $user->slug);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_user_updating()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $user = $this->getNormalUser();
 | 
				
			||||||
 | 
					        $password = $user->password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->get('/settings/users/' . $user->id);
 | 
				
			||||||
 | 
					        $resp->assertSee($user->email);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->put($user->getEditUrl(), [
 | 
				
			||||||
 | 
					            'name' => 'Barry Scott',
 | 
				
			||||||
 | 
					        ])->assertRedirect('/settings/users');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password]);
 | 
				
			||||||
 | 
					        $this->assertDatabaseMissing('users', ['name' => $user->name]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $user->refresh();
 | 
				
			||||||
 | 
					        $this->assertStringStartsWith(Str::slug($user->name), $user->slug);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_user_password_update()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $user = $this->getNormalUser();
 | 
				
			||||||
 | 
					        $userProfilePage = '/settings/users/' . $user->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asAdmin()->get($userProfilePage);
 | 
				
			||||||
 | 
					        $this->put($userProfilePage, [
 | 
				
			||||||
 | 
					            'password' => 'newpassword',
 | 
				
			||||||
 | 
					        ])->assertRedirect($userProfilePage);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->get($userProfilePage)->assertSee('Password confirmation required');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->put($userProfilePage, [
 | 
				
			||||||
 | 
					            'password'         => 'newpassword',
 | 
				
			||||||
 | 
					            'password-confirm' => 'newpassword',
 | 
				
			||||||
 | 
					        ])->assertRedirect('/settings/users');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $userPassword = User::query()->find($user->id)->password;
 | 
				
			||||||
 | 
					        $this->assertTrue(Hash::check('newpassword', $userPassword));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_user_cannot_be_deleted_if_last_admin()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $adminRole = Role::getRole('admin');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Delete all but one admin user if there are more than one
 | 
				
			||||||
 | 
					        $adminUsers = $adminRole->users;
 | 
				
			||||||
 | 
					        if (count($adminUsers) > 1) {
 | 
				
			||||||
 | 
					            /** @var User $user */
 | 
				
			||||||
 | 
					            foreach ($adminUsers->splice(1) as $user) {
 | 
				
			||||||
 | 
					                $user->delete();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Ensure we currently only have 1 admin user
 | 
				
			||||||
 | 
					        $this->assertEquals(1, $adminRole->users()->count());
 | 
				
			||||||
 | 
					        /** @var User $user */
 | 
				
			||||||
 | 
					        $user = $adminRole->users->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->delete('/settings/users/' . $user->id);
 | 
				
			||||||
 | 
					        $resp->assertRedirect('/settings/users/' . $user->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->get('/settings/users/' . $user->id);
 | 
				
			||||||
 | 
					        $resp->assertSee('You cannot delete the only admin');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('users', ['id' => $user->id]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_delete()
 | 
					    public function test_delete()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $editor = $this->getEditor();
 | 
					        $editor = $this->getEditor();
 | 
				
			||||||
| 
						 | 
					@ -42,4 +142,26 @@ class UserManagementTest extends TestCase
 | 
				
			||||||
            'owned_by' => $newOwner->id,
 | 
					            'owned_by' => $newOwner->id,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_guest_profile_shows_limited_form()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $guest = User::getDefault();
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->get('/settings/users/' . $guest->id);
 | 
				
			||||||
 | 
					        $resp->assertSee('Guest');
 | 
				
			||||||
 | 
					        $resp->assertElementNotExists('#password');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_guest_profile_cannot_be_deleted()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $guestUser = User::getDefault();
 | 
				
			||||||
 | 
					        $resp = $this->asAdmin()->get('/settings/users/' . $guestUser->id . '/delete');
 | 
				
			||||||
 | 
					        $resp->assertSee('Delete User');
 | 
				
			||||||
 | 
					        $resp->assertSee('Guest');
 | 
				
			||||||
 | 
					        $resp->assertElementContains('form[action$="/settings/users/' . $guestUser->id . '"] button', 'Confirm');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $resp = $this->delete('/settings/users/' . $guestUser->id);
 | 
				
			||||||
 | 
					        $resp->assertRedirect('/settings/users/' . $guestUser->id);
 | 
				
			||||||
 | 
					        $resp = $this->followRedirects($resp);
 | 
				
			||||||
 | 
					        $resp->assertSee('cannot delete the guest user');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Tests\User;
 | 
					namespace Tests\User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Bookshelf;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UserPreferencesTest extends TestCase
 | 
					class UserPreferencesTest extends TestCase
 | 
				
			||||||
| 
						 | 
					@ -106,4 +107,44 @@ class UserPreferencesTest extends TestCase
 | 
				
			||||||
        $home = $this->get('/login');
 | 
					        $home = $this->get('/login');
 | 
				
			||||||
        $home->assertElementExists('.dark-mode');
 | 
					        $home->assertElementExists('.dark-mode');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_books_view_type_preferences_when_list()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $editor = $this->getEditor();
 | 
				
			||||||
 | 
					        setting()->putUser($editor, 'books_view_type', 'list');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->actingAs($editor)->get('/books')
 | 
				
			||||||
 | 
					            ->assertElementNotExists('.featured-image-container')
 | 
				
			||||||
 | 
					            ->assertElementExists('.content-wrap .entity-list-item');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_books_view_type_preferences_when_grid()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $editor = $this->getEditor();
 | 
				
			||||||
 | 
					        setting()->putUser($editor, 'books_view_type', 'grid');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->actingAs($editor)->get('/books')
 | 
				
			||||||
 | 
					            ->assertElementExists('.featured-image-container');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function test_shelf_view_type_change()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $editor = $this->getEditor();
 | 
				
			||||||
 | 
					        /** @var Bookshelf $shelf */
 | 
				
			||||||
 | 
					        $shelf = Bookshelf::query()->first();
 | 
				
			||||||
 | 
					        setting()->putUser($editor, 'bookshelf_view_type', 'list');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->actingAs($editor)->get($shelf->getUrl())
 | 
				
			||||||
 | 
					            ->assertElementNotExists('.featured-image-container')
 | 
				
			||||||
 | 
					            ->assertElementExists('.content-wrap .entity-list-item')
 | 
				
			||||||
 | 
					            ->assertSee('Grid View');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $req = $this->patch("/settings/users/{$editor->id}/switch-shelf-view", ['view_type' => 'grid']);
 | 
				
			||||||
 | 
					        $req->assertRedirect($shelf->getUrl());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->actingAs($editor)->get($shelf->getUrl())
 | 
				
			||||||
 | 
					            ->assertElementExists('.featured-image-container')
 | 
				
			||||||
 | 
					            ->assertElementNotExists('.content-wrap .entity-list-item')
 | 
				
			||||||
 | 
					            ->assertSee('List View');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,11 +5,13 @@ namespace Tests\User;
 | 
				
			||||||
use Activity;
 | 
					use Activity;
 | 
				
			||||||
use BookStack\Actions\ActivityType;
 | 
					use BookStack\Actions\ActivityType;
 | 
				
			||||||
use BookStack\Auth\User;
 | 
					use BookStack\Auth\User;
 | 
				
			||||||
use BookStack\Entities\Models\Bookshelf;
 | 
					use Tests\TestCase;
 | 
				
			||||||
use Tests\BrowserKitTest;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UserProfileTest extends BrowserKitTest
 | 
					class UserProfileTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @var User
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected $user;
 | 
					    protected $user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function setUp(): void
 | 
					    public function setUp(): void
 | 
				
			||||||
| 
						 | 
					@ -21,74 +23,73 @@ class UserProfileTest extends BrowserKitTest
 | 
				
			||||||
    public function test_profile_page_shows_name()
 | 
					    public function test_profile_page_shows_name()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->asAdmin()
 | 
					        $this->asAdmin()
 | 
				
			||||||
            ->visit('/user/' . $this->user->slug)
 | 
					            ->get('/user/' . $this->user->slug)
 | 
				
			||||||
            ->see($this->user->name);
 | 
					            ->assertSee($this->user->name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_profile_page_shows_recent_entities()
 | 
					    public function test_profile_page_shows_recent_entities()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $content = $this->createEntityChainBelongingToUser($this->user, $this->user);
 | 
					        $content = $this->createEntityChainBelongingToUser($this->user, $this->user);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()
 | 
					        $resp = $this->asAdmin()->get('/user/' . $this->user->slug);
 | 
				
			||||||
            ->visit('/user/' . $this->user->slug)
 | 
					 | 
				
			||||||
        // Check the recently created page is shown
 | 
					        // Check the recently created page is shown
 | 
				
			||||||
            ->see($content['page']->name)
 | 
					        $resp->assertSee($content['page']->name);
 | 
				
			||||||
        // Check the recently created chapter is shown
 | 
					        // Check the recently created chapter is shown
 | 
				
			||||||
            ->see($content['chapter']->name)
 | 
					        $resp->assertSee($content['chapter']->name);
 | 
				
			||||||
        // Check the recently created book is shown
 | 
					        // Check the recently created book is shown
 | 
				
			||||||
            ->see($content['book']->name);
 | 
					        $resp->assertSee($content['book']->name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_profile_page_shows_created_content_counts()
 | 
					    public function test_profile_page_shows_created_content_counts()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $newUser = $this->getNewBlankUser();
 | 
					        $newUser = factory(User::class)->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()->visit('/user/' . $newUser->slug)
 | 
					        $this->asAdmin()->get('/user/' . $newUser->slug)
 | 
				
			||||||
            ->see($newUser->name)
 | 
					            ->assertSee($newUser->name)
 | 
				
			||||||
            ->seeInElement('#content-counts', '0 Books')
 | 
					            ->assertElementContains('#content-counts', '0 Books')
 | 
				
			||||||
            ->seeInElement('#content-counts', '0 Chapters')
 | 
					            ->assertElementContains('#content-counts', '0 Chapters')
 | 
				
			||||||
            ->seeInElement('#content-counts', '0 Pages');
 | 
					            ->assertElementContains('#content-counts', '0 Pages');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->createEntityChainBelongingToUser($newUser, $newUser);
 | 
					        $this->createEntityChainBelongingToUser($newUser, $newUser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()->visit('/user/' . $newUser->slug)
 | 
					        $this->asAdmin()->get('/user/' . $newUser->slug)
 | 
				
			||||||
            ->see($newUser->name)
 | 
					            ->assertSee($newUser->name)
 | 
				
			||||||
            ->seeInElement('#content-counts', '1 Book')
 | 
					            ->assertElementContains('#content-counts', '1 Book')
 | 
				
			||||||
            ->seeInElement('#content-counts', '1 Chapter')
 | 
					            ->assertElementContains('#content-counts', '1 Chapter')
 | 
				
			||||||
            ->seeInElement('#content-counts', '1 Page');
 | 
					            ->assertElementContains('#content-counts', '1 Page');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_profile_page_shows_recent_activity()
 | 
					    public function test_profile_page_shows_recent_activity()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $newUser = $this->getNewBlankUser();
 | 
					        $newUser = factory(User::class)->create();
 | 
				
			||||||
        $this->actingAs($newUser);
 | 
					        $this->actingAs($newUser);
 | 
				
			||||||
        $entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
 | 
					        $entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
 | 
				
			||||||
        Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
 | 
					        Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
 | 
				
			||||||
        Activity::addForEntity($entities['page'], ActivityType::PAGE_CREATE);
 | 
					        Activity::addForEntity($entities['page'], ActivityType::PAGE_CREATE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()->visit('/user/' . $newUser->slug)
 | 
					        $this->asAdmin()->get('/user/' . $newUser->slug)
 | 
				
			||||||
            ->seeInElement('#recent-user-activity', 'updated book')
 | 
					            ->assertElementContains('#recent-user-activity', 'updated book')
 | 
				
			||||||
            ->seeInElement('#recent-user-activity', 'created page')
 | 
					            ->assertElementContains('#recent-user-activity', 'created page')
 | 
				
			||||||
            ->seeInElement('#recent-user-activity', $entities['page']->name);
 | 
					            ->assertElementContains('#recent-user-activity', $entities['page']->name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_clicking_user_name_in_activity_leads_to_profile_page()
 | 
					    public function test_user_activity_has_link_leading_to_profile()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $newUser = $this->getNewBlankUser();
 | 
					        $newUser = factory(User::class)->create();
 | 
				
			||||||
        $this->actingAs($newUser);
 | 
					        $this->actingAs($newUser);
 | 
				
			||||||
        $entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
 | 
					        $entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
 | 
				
			||||||
        Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
 | 
					        Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
 | 
				
			||||||
        Activity::addForEntity($entities['page'], ActivityType::PAGE_CREATE);
 | 
					        Activity::addForEntity($entities['page'], ActivityType::PAGE_CREATE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->asAdmin()->visit('/')->clickInElement('#recent-activity', $newUser->name)
 | 
					        $linkSelector = '#recent-activity a[href$="/user/' . $newUser->slug . '"]';
 | 
				
			||||||
            ->seePageIs('/user/' . $newUser->slug)
 | 
					        $this->asAdmin()->get('/')
 | 
				
			||||||
            ->see($newUser->name);
 | 
					            ->assertElementContains($linkSelector, $newUser->name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_profile_has_search_links_in_created_entity_lists()
 | 
					    public function test_profile_has_search_links_in_created_entity_lists()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $user = $this->getEditor();
 | 
					        $user = $this->getEditor();
 | 
				
			||||||
        $resp = $this->actingAs($this->getAdmin())->visit('/user/' . $user->slug);
 | 
					        $resp = $this->actingAs($this->getAdmin())->get('/user/' . $user->slug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $expectedLinks = [
 | 
					        $expectedLinks = [
 | 
				
			||||||
            '/search?term=%7Bcreated_by%3A' . $user->slug . '%7D+%7Btype%3Apage%7D',
 | 
					            '/search?term=%7Bcreated_by%3A' . $user->slug . '%7D+%7Btype%3Apage%7D',
 | 
				
			||||||
| 
						 | 
					@ -98,66 +99,7 @@ class UserProfileTest extends BrowserKitTest
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach ($expectedLinks as $link) {
 | 
					        foreach ($expectedLinks as $link) {
 | 
				
			||||||
            $resp->seeInElement('[href$="' . $link . '"]', 'View All');
 | 
					            $resp->assertElementContains('[href$="' . $link . '"]', 'View All');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_guest_profile_shows_limited_form()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->asAdmin()
 | 
					 | 
				
			||||||
            ->visit('/settings/users')
 | 
					 | 
				
			||||||
            ->click('Guest')
 | 
					 | 
				
			||||||
            ->dontSeeElement('#password');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_guest_profile_cannot_be_deleted()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $guestUser = User::getDefault();
 | 
					 | 
				
			||||||
        $this->asAdmin()->visit('/settings/users/' . $guestUser->id . '/delete')
 | 
					 | 
				
			||||||
            ->see('Delete User')->see('Guest')
 | 
					 | 
				
			||||||
            ->press('Confirm')
 | 
					 | 
				
			||||||
            ->seePageIs('/settings/users/' . $guestUser->id)
 | 
					 | 
				
			||||||
            ->see('cannot delete the guest user');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_books_view_is_list()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $editor = $this->getEditor();
 | 
					 | 
				
			||||||
        setting()->putUser($editor, 'books_view_type', 'list');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->actingAs($editor)
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            ->pageNotHasElement('.featured-image-container')
 | 
					 | 
				
			||||||
            ->pageHasElement('.content-wrap .entity-list-item');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_books_view_is_grid()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $editor = $this->getEditor();
 | 
					 | 
				
			||||||
        setting()->putUser($editor, 'books_view_type', 'grid');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->actingAs($editor)
 | 
					 | 
				
			||||||
            ->visit('/books')
 | 
					 | 
				
			||||||
            ->pageHasElement('.featured-image-container');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function test_shelf_view_type_change()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $editor = $this->getEditor();
 | 
					 | 
				
			||||||
        $shelf = Bookshelf::query()->first();
 | 
					 | 
				
			||||||
        setting()->putUser($editor, 'bookshelf_view_type', 'list');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->actingAs($editor)->visit($shelf->getUrl())
 | 
					 | 
				
			||||||
            ->pageNotHasElement('.featured-image-container')
 | 
					 | 
				
			||||||
            ->pageHasElement('.content-wrap .entity-list-item')
 | 
					 | 
				
			||||||
            ->see('Grid View');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $req = $this->patch("/settings/users/{$editor->id}/switch-shelf-view", ['view_type' => 'grid']);
 | 
					 | 
				
			||||||
        $req->assertRedirectedTo($shelf->getUrl());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->actingAs($editor)->visit($shelf->getUrl())
 | 
					 | 
				
			||||||
            ->pageHasElement('.featured-image-container')
 | 
					 | 
				
			||||||
            ->pageNotHasElement('.content-wrap .entity-list-item')
 | 
					 | 
				
			||||||
            ->see('List View');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue