diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f350d32be..61efca708 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,4 +50,4 @@ jobs: run: php artisan key:generate - name: Tests - run: ./vendor/bin/pest --ci + run: ./vendor/bin/phpunit diff --git a/composer.json b/composer.json index 74f2ef8ce..1a9f16b92 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,7 @@ "laravel/sail": "^1.26", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.1", - "pestphp/pest": "^3.7", - "pestphp/pest-plugin-laravel": "^3.0" + "phpunit/phpunit": "^11.5" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index d26017c2c..2d62ac5d6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5c0eafaa52c26cf9d8a6c188682e3c86", + "content-hash": "4399f31c1ce614e0c04233715e10ec3f", "packages": [ { "name": "brick/math", @@ -5347,130 +5347,6 @@ } ], "packages-dev": [ - { - "name": "brianium/paratest", - "version": "v7.7.0", - "source": { - "type": "git", - "url": "https://github.com/paratestphp/paratest.git", - "reference": "4fb3f73bc5a4c3146bac2850af7dc72435a32daf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/4fb3f73bc5a4c3146bac2850af7dc72435a32daf", - "reference": "4fb3f73bc5a4c3146bac2850af7dc72435a32daf", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-simplexml": "*", - "fidry/cpu-core-counter": "^1.2.0", - "jean85/pretty-package-versions": "^2.1.0", - "php": "~8.2.0 || ~8.3.0 || ~8.4.0", - "phpunit/php-code-coverage": "^11.0.8", - "phpunit/php-file-iterator": "^5.1.0", - "phpunit/php-timer": "^7.0.1", - "phpunit/phpunit": "^11.5.1", - "sebastian/environment": "^7.2.0", - "symfony/console": "^6.4.14 || ^7.2.1", - "symfony/process": "^6.4.14 || ^7.2.0" - }, - "require-dev": { - "doctrine/coding-standard": "^12.0.0", - "ext-pcov": "*", - "ext-posix": "*", - "phpstan/phpstan": "^2.0.3", - "phpstan/phpstan-deprecation-rules": "^2.0.1", - "phpstan/phpstan-phpunit": "^2.0.1", - "phpstan/phpstan-strict-rules": "^2", - "squizlabs/php_codesniffer": "^3.11.1", - "symfony/filesystem": "^6.4.13 || ^7.2.0" - }, - "bin": ["bin/paratest", "bin/paratest_for_phpstorm"], - "type": "library", - "autoload": { - "psr-4": { - "ParaTest\\": ["src/"] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Brian Scaturro", - "email": "scaturrob@gmail.com", - "role": "Developer" - }, - { - "name": "Filippo Tessarotto", - "email": "zoeslam@gmail.com", - "role": "Developer" - } - ], - "description": "Parallel testing for PHP", - "homepage": "https://github.com/paratestphp/paratest", - "keywords": ["concurrent", "parallel", "phpunit", "testing"], - "support": { - "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.7.0" - }, - "funding": [ - { - "url": "https://github.com/sponsors/Slamdunk", - "type": "github" - }, - { - "url": "https://paypal.me/filippotessarotto", - "type": "paypal" - } - ], - "time": "2024-12-11T14:50:44+00:00" - }, - { - "name": "doctrine/deprecations", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9 || ^12", - "phpstan/phpstan": "1.4.10 || 2.0.3", - "phpstan/phpstan-phpunit": "^1.0 || ^2", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psr/log": "^1 || ^2 || ^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.4" - }, - "time": "2024-12-07T21:18:45+00:00" - }, { "name": "fakerphp/faker", "version": "v1.24.1", @@ -5528,62 +5404,6 @@ }, "time": "2024-11-21T13:46:39+00:00" }, - { - "name": "fidry/cpu-core-counter", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "8520451a140d3f46ac33042715115e290cf5785f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f", - "reference": "8520451a140d3f46ac33042715115e290cf5785f", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "fidry/makefile": "^0.2.0", - "fidry/php-cs-fixer-config": "^1.1.2", - "phpstan/extension-installer": "^1.2.0", - "phpstan/phpstan": "^1.9.2", - "phpstan/phpstan-deprecation-rules": "^1.0.0", - "phpstan/phpstan-phpunit": "^1.2.2", - "phpstan/phpstan-strict-rules": "^1.4.4", - "phpunit/phpunit": "^8.5.31 || ^9.5.26", - "webmozarts/strict-phpunit": "^7.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Fidry\\CpuCoreCounter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Théo FIDRY", - "email": "theo.fidry@gmail.com" - } - ], - "description": "Tiny utility to get the number of CPU cores.", - "keywords": ["CPU", "core"], - "support": { - "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0" - }, - "funding": [ - { - "url": "https://github.com/theofidry", - "type": "github" - } - ], - "time": "2024-08-06T10:04:20+00:00" - }, { "name": "filp/whoops", "version": "2.16.0", @@ -5691,58 +5511,6 @@ }, "time": "2020-07-09T08:09:16+00:00" }, - { - "name": "jean85/pretty-package-versions", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", - "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", - "shasum": "" - }, - "require": { - "composer-runtime-api": "^2.1.0", - "php": "^7.4|^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.2", - "jean85/composer-provided-replaced-stub-package": "^1.0", - "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^7.5|^8.5|^9.6", - "vimeo/psalm": "^4.3 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Jean85\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Alessandro Lai", - "email": "alessandro.lai85@gmail.com" - } - ], - "description": "A library to get pretty versions strings of installed dependencies", - "keywords": ["composer", "package", "release", "versions"], - "support": { - "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0" - }, - "time": "2024-11-18T16:19:46+00:00" - }, { "name": "larastan/larastan", "version": "v3.0.2", @@ -6199,333 +5967,6 @@ ], "time": "2024-10-15T16:06:32+00:00" }, - { - "name": "pestphp/pest", - "version": "v3.7.1", - "source": { - "type": "git", - "url": "https://github.com/pestphp/pest.git", - "reference": "bf3178473dcaa53b0458f21dfdb271306ea62512" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/bf3178473dcaa53b0458f21dfdb271306ea62512", - "reference": "bf3178473dcaa53b0458f21dfdb271306ea62512", - "shasum": "" - }, - "require": { - "brianium/paratest": "^7.7.0", - "nunomaduro/collision": "^8.5.0", - "nunomaduro/termwind": "^2.3.0", - "pestphp/pest-plugin": "^3.0.0", - "pestphp/pest-plugin-arch": "^3.0.0", - "pestphp/pest-plugin-mutate": "^3.0.5", - "php": "^8.2.0", - "phpunit/phpunit": "^11.5.1" - }, - "conflict": { - "filp/whoops": "<2.16.0", - "phpunit/phpunit": ">11.5.1", - "sebastian/exporter": "<6.0.0", - "webmozart/assert": "<1.11.0" - }, - "require-dev": { - "pestphp/pest-dev-tools": "^3.3.0", - "pestphp/pest-plugin-type-coverage": "^3.2.0", - "symfony/process": "^7.2.0" - }, - "bin": ["bin/pest"], - "type": "library", - "extra": { - "pest": { - "plugins": [ - "Pest\\Mutate\\Plugins\\Mutate", - "Pest\\Plugins\\Configuration", - "Pest\\Plugins\\Bail", - "Pest\\Plugins\\Cache", - "Pest\\Plugins\\Coverage", - "Pest\\Plugins\\Init", - "Pest\\Plugins\\Environment", - "Pest\\Plugins\\Help", - "Pest\\Plugins\\Memory", - "Pest\\Plugins\\Only", - "Pest\\Plugins\\Printer", - "Pest\\Plugins\\ProcessIsolation", - "Pest\\Plugins\\Profile", - "Pest\\Plugins\\Retry", - "Pest\\Plugins\\Snapshot", - "Pest\\Plugins\\Verbose", - "Pest\\Plugins\\Version", - "Pest\\Plugins\\Parallel" - ] - }, - "phpstan": { - "includes": ["extension.neon"] - } - }, - "autoload": { - "files": ["src/Functions.php", "src/Pest.php"], - "psr-4": { - "Pest\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "The elegant PHP Testing Framework.", - "keywords": ["framework", "pest", "php", "test", "testing", "unit"], - "support": { - "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v3.7.1" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - } - ], - "time": "2024-12-12T11:52:01+00:00" - }, - { - "name": "pestphp/pest-plugin", - "version": "v3.0.0", - "source": { - "type": "git", - "url": "https://github.com/pestphp/pest-plugin.git", - "reference": "e79b26c65bc11c41093b10150c1341cc5cdbea83" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/e79b26c65bc11c41093b10150c1341cc5cdbea83", - "reference": "e79b26c65bc11c41093b10150c1341cc5cdbea83", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^2.0.0", - "composer-runtime-api": "^2.2.2", - "php": "^8.2" - }, - "conflict": { - "pestphp/pest": "<3.0.0" - }, - "require-dev": { - "composer/composer": "^2.7.9", - "pestphp/pest": "^3.0.0", - "pestphp/pest-dev-tools": "^3.0.0" - }, - "type": "composer-plugin", - "extra": { - "class": "Pest\\Plugin\\Manager" - }, - "autoload": { - "psr-4": { - "Pest\\Plugin\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "description": "The Pest plugin manager", - "keywords": ["framework", "manager", "pest", "php", "plugin", "test", "testing", "unit"], - "support": { - "source": "https://github.com/pestphp/pest-plugin/tree/v3.0.0" - }, - "funding": [ - { - "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" - } - ], - "time": "2024-09-08T23:21:41+00:00" - }, - { - "name": "pestphp/pest-plugin-arch", - "version": "v3.0.0", - "source": { - "type": "git", - "url": "https://github.com/pestphp/pest-plugin-arch.git", - "reference": "0a27e55a270cfe73d8cb70551b91002ee2cb64b0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/0a27e55a270cfe73d8cb70551b91002ee2cb64b0", - "reference": "0a27e55a270cfe73d8cb70551b91002ee2cb64b0", - "shasum": "" - }, - "require": { - "pestphp/pest-plugin": "^3.0.0", - "php": "^8.2", - "ta-tikoma/phpunit-architecture-test": "^0.8.4" - }, - "require-dev": { - "pestphp/pest": "^3.0.0", - "pestphp/pest-dev-tools": "^3.0.0" - }, - "type": "library", - "extra": { - "pest": { - "plugins": ["Pest\\Arch\\Plugin"] - } - }, - "autoload": { - "files": ["src/Autoload.php"], - "psr-4": { - "Pest\\Arch\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "description": "The Arch plugin for Pest PHP.", - "keywords": ["arch", "architecture", "framework", "pest", "php", "plugin", "test", "testing", "unit"], - "support": { - "source": "https://github.com/pestphp/pest-plugin-arch/tree/v3.0.0" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - } - ], - "time": "2024-09-08T23:23:55+00:00" - }, - { - "name": "pestphp/pest-plugin-laravel", - "version": "v3.0.0", - "source": { - "type": "git", - "url": "https://github.com/pestphp/pest-plugin-laravel.git", - "reference": "7dd98c0c3b3542970ec21fce80ec5c88916ac469" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/7dd98c0c3b3542970ec21fce80ec5c88916ac469", - "reference": "7dd98c0c3b3542970ec21fce80ec5c88916ac469", - "shasum": "" - }, - "require": { - "laravel/framework": "^11.22.0", - "pestphp/pest": "^3.0.0", - "php": "^8.2.0" - }, - "require-dev": { - "laravel/dusk": "^8.2.5", - "orchestra/testbench": "^9.4.0", - "pestphp/pest-dev-tools": "^3.0.0" - }, - "type": "library", - "extra": { - "pest": { - "plugins": ["Pest\\Laravel\\Plugin"] - }, - "laravel": { - "providers": ["Pest\\Laravel\\PestServiceProvider"] - } - }, - "autoload": { - "files": ["src/Autoload.php"], - "psr-4": { - "Pest\\Laravel\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "description": "The Pest Laravel Plugin", - "keywords": ["framework", "laravel", "pest", "php", "test", "testing", "unit"], - "support": { - "source": "https://github.com/pestphp/pest-plugin-laravel/tree/v3.0.0" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - } - ], - "time": "2024-09-08T23:32:52+00:00" - }, - { - "name": "pestphp/pest-plugin-mutate", - "version": "v3.0.5", - "source": { - "type": "git", - "url": "https://github.com/pestphp/pest-plugin-mutate.git", - "reference": "e10dbdc98c9e2f3890095b4fe2144f63a5717e08" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/e10dbdc98c9e2f3890095b4fe2144f63a5717e08", - "reference": "e10dbdc98c9e2f3890095b4fe2144f63a5717e08", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^5.2.0", - "pestphp/pest-plugin": "^3.0.0", - "php": "^8.2", - "psr/simple-cache": "^3.0.0" - }, - "require-dev": { - "pestphp/pest": "^3.0.8", - "pestphp/pest-dev-tools": "^3.0.0", - "pestphp/pest-plugin-type-coverage": "^3.0.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Pest\\Mutate\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Sandro Gehri", - "email": "sandrogehri@gmail.com" - } - ], - "description": "Mutates your code to find untested cases", - "keywords": ["framework", "mutate", "mutation", "pest", "php", "plugin", "test", "testing", "unit"], - "support": { - "source": "https://github.com/pestphp/pest-plugin-mutate/tree/v3.0.5" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/gehrisandro", - "type": "github" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - } - ], - "time": "2024-09-22T07:54:40+00:00" - }, { "name": "phar-io/manifest", "version": "2.0.4", @@ -6636,169 +6077,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": ["FQSEN", "phpDocumentor", "phpdoc", "reflection", "static analysis"], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.1", - "ext-filter": "*", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7|^2.0", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.5 || ~1.6.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.5", - "psalm/phar": "^5.26" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" - }, - "time": "2024-12-07T09:39:29+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.3 || ^8.0", - "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.18|^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "rector/rector": "^0.13.9", - "vimeo/psalm": "^4.25" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0" - }, - "time": "2024-11-09T15:12:26+00:00" - }, { "name": "phpmyadmin/sql-parser", "version": "5.10.2", @@ -6879,49 +6157,6 @@ ], "time": "2024-12-05T15:04:09+00:00" }, - { - "name": "phpstan/phpdoc-parser", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/c00d78fb6b29658347f9d37ebe104bffadf36299", - "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^5.3.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^2.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpstan/phpstan-strict-rules": "^2.0", - "phpunit/phpunit": "^9.6", - "symfony/process": "^5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": ["src/"] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/2.0.0" - }, - "time": "2024-10-13T11:29:49+00:00" - }, { "name": "phpstan/phpstan", "version": "2.1.0", @@ -7262,16 +6497,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.1", + "version": "11.5.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2b94d4f2450b9869fa64a46fd8a6a41997aef56a" + "reference": "e1cb706f019e2547039ca2c839898cd5f557ee5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2b94d4f2450b9869fa64a46fd8a6a41997aef56a", - "reference": "2b94d4f2450b9869fa64a46fd8a6a41997aef56a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e1cb706f019e2547039ca2c839898cd5f557ee5d", + "reference": "e1cb706f019e2547039ca2c839898cd5f557ee5d", "shasum": "" }, "require": { @@ -7285,14 +6520,14 @@ "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.2", - "phpunit/php-code-coverage": "^11.0.7", + "phpunit/php-code-coverage": "^11.0.8", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", - "sebastian/code-unit": "^3.0.1", - "sebastian/comparator": "^6.2.1", + "sebastian/code-unit": "^3.0.2", + "sebastian/comparator": "^6.3.0", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.0", "sebastian/exporter": "^6.3.0", @@ -7331,7 +6566,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.1" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.7" }, "funding": [ { @@ -7347,7 +6582,7 @@ "type": "tidelift" } ], - "time": "2024-12-11T10:52:48+00:00" + "time": "2025-02-06T16:10:05+00:00" }, { "name": "sebastian/cli-parser", @@ -7509,16 +6744,16 @@ }, { "name": "sebastian/comparator", - "version": "6.2.1", + "version": "6.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "43d129d6a0f81c78bee378b46688293eb7ea3739" + "reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/43d129d6a0f81c78bee378b46688293eb7ea3739", - "reference": "43d129d6a0f81c78bee378b46688293eb7ea3739", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d4e47a769525c4dd38cea90e5dcd435ddbbc7115", + "reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115", "shasum": "" }, "require": { @@ -7531,6 +6766,9 @@ "require-dev": { "phpunit/phpunit": "^11.4" }, + "suggest": { + "ext-bcmath": "For comparing BcMath\\Number objects" + }, "type": "library", "extra": { "branch-alias": { @@ -7566,7 +6804,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.2.1" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.0" }, "funding": [ { @@ -7574,7 +6812,7 @@ "type": "github" } ], - "time": "2024-10-31T05:30:08+00:00" + "time": "2025-01-06T10:28:19+00:00" }, { "name": "sebastian/complexity", @@ -8306,57 +7544,6 @@ ], "time": "2024-10-23T06:56:12+00:00" }, - { - "name": "ta-tikoma/phpunit-architecture-test", - "version": "0.8.4", - "source": { - "type": "git", - "url": "https://github.com/ta-tikoma/phpunit-architecture-test.git", - "reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/89f0dea1cb0f0d5744d3ec1764a286af5e006636", - "reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.18.0 || ^5.0.0", - "php": "^8.1.0", - "phpdocumentor/reflection-docblock": "^5.3.0", - "phpunit/phpunit": "^10.5.5 || ^11.0.0", - "symfony/finder": "^6.4.0 || ^7.0.0" - }, - "require-dev": { - "laravel/pint": "^1.13.7", - "phpstan/phpstan": "^1.10.52" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPUnit\\Architecture\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": ["MIT"], - "authors": [ - { - "name": "Ni Shi", - "email": "futik0ma011@gmail.com" - }, - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "Methods for testing application architecture", - "keywords": ["architecture", "phpunit", "stucture", "test", "testing"], - "support": { - "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", - "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.4" - }, - "time": "2024-01-05T14:10:56+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.3", @@ -8405,7 +7592,7 @@ } ], "aliases": [], - "minimum-stability": "stable", + "minimum-stability": "dev", "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, diff --git a/phpunit.xml b/phpunit.xml index 506b9a38e..61c031c47 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -22,8 +22,8 @@ - - + + diff --git a/tests/Feature/Auth/AuthenticationTest.php b/tests/Feature/Auth/AuthenticationTest.php index 4baea5158..c59d166a8 100644 --- a/tests/Feature/Auth/AuthenticationTest.php +++ b/tests/Feature/Auth/AuthenticationTest.php @@ -1,41 +1,54 @@ get('/login'); + public function test_login_screen_can_be_rendered() + { + $response = $this->get('/login'); - $response->assertStatus(200); -}); + $response->assertStatus(200); + } -test('users can authenticate using the login screen', function () { - $user = User::factory()->create(); + public function test_users_can_authenticate_using_the_login_screen() + { + $user = User::factory()->create(); - $response = $this->post('/login', [ - 'email' => $user->email, - 'password' => 'password', - ]); + $response = $this->post('/login', [ + 'email' => $user->email, + 'password' => 'password', + ]); - $this->assertAuthenticated(); - $response->assertRedirect(route('dashboard', absolute: false)); -}); + $this->assertAuthenticated(); + $response->assertRedirect(route('dashboard', absolute: false)); + } -test('users can not authenticate with an invalid password', function () { - $user = User::factory()->create(); + public function test_users_can_not_authenticate_with_invalid_password() + { + $user = User::factory()->create(); - $this->post('/login', [ - 'email' => $user->email, - 'password' => 'wrong-password', - ]); + $this->post('/login', [ + 'email' => $user->email, + 'password' => 'wrong-password', + ]); - $this->assertGuest(); -}); + $this->assertGuest(); + } -test('users can logout', function () { - $user = User::factory()->create(); + public function test_users_can_logout() + { + $user = User::factory()->create(); - $response = $this->actingAs($user)->post('/logout'); + $response = $this->actingAs($user)->post('/logout'); - $this->assertGuest(); - $response->assertRedirect('/'); -}); + $this->assertGuest(); + $response->assertRedirect('/'); + } +} diff --git a/tests/Feature/Auth/EmailVerificationTest.php b/tests/Feature/Auth/EmailVerificationTest.php index 2bb2aeaeb..627fe709d 100644 --- a/tests/Feature/Auth/EmailVerificationTest.php +++ b/tests/Feature/Auth/EmailVerificationTest.php @@ -1,47 +1,58 @@ unverified()->create(); +class EmailVerificationTest extends TestCase +{ + use RefreshDatabase; - $response = $this->actingAs($user)->get('/verify-email'); + public function test_email_verification_screen_can_be_rendered() + { + $user = User::factory()->unverified()->create(); - $response->assertStatus(200); -}); + $response = $this->actingAs($user)->get('/verify-email'); -test('email can be verified', function () { - $user = User::factory()->unverified()->create(); + $response->assertStatus(200); + } - Event::fake(); + public function test_email_can_be_verified() + { + $user = User::factory()->unverified()->create(); - $verificationUrl = URL::temporarySignedRoute( - 'verification.verify', - now()->addMinutes(60), - ['id' => $user->id, 'hash' => sha1($user->email)] - ); + Event::fake(); - $response = $this->actingAs($user)->get($verificationUrl); + $verificationUrl = URL::temporarySignedRoute( + 'verification.verify', + now()->addMinutes(60), + ['id' => $user->id, 'hash' => sha1($user->email)] + ); - Event::assertDispatched(Verified::class); + $response = $this->actingAs($user)->get($verificationUrl); - expect($user->fresh()->hasVerifiedEmail())->toBeTrue(); - $response->assertRedirect(route('dashboard', absolute: false).'?verified=1'); -}); + Event::assertDispatched(Verified::class); + $this->assertTrue($user->fresh()->hasVerifiedEmail()); + $response->assertRedirect(route('dashboard', absolute: false).'?verified=1'); + } -test('email is not verified with invalid hash', function () { - $user = User::factory()->unverified()->create(); + public function test_email_is_not_verified_with_invalid_hash() + { + $user = User::factory()->unverified()->create(); - $verificationUrl = URL::temporarySignedRoute( - 'verification.verify', - now()->addMinutes(60), - ['id' => $user->id, 'hash' => sha1('wrong-email')] - ); + $verificationUrl = URL::temporarySignedRoute( + 'verification.verify', + now()->addMinutes(60), + ['id' => $user->id, 'hash' => sha1('wrong-email')] + ); - $this->actingAs($user)->get($verificationUrl); + $this->actingAs($user)->get($verificationUrl); - expect($user->fresh()->hasVerifiedEmail())->toBeFalse(); -}); + $this->assertFalse($user->fresh()->hasVerifiedEmail()); + } +} diff --git a/tests/Feature/Auth/PasswordConfirmationTest.php b/tests/Feature/Auth/PasswordConfirmationTest.php index 8a42902e3..d2072ffd4 100644 --- a/tests/Feature/Auth/PasswordConfirmationTest.php +++ b/tests/Feature/Auth/PasswordConfirmationTest.php @@ -1,32 +1,44 @@ create(); + public function test_confirm_password_screen_can_be_rendered() + { + $user = User::factory()->create(); - $response = $this->actingAs($user)->get('/confirm-password'); + $response = $this->actingAs($user)->get('/confirm-password'); - $response->assertStatus(200); -}); + $response->assertStatus(200); + } -test('password can be confirmed', function () { - $user = User::factory()->create(); + public function test_password_can_be_confirmed() + { + $user = User::factory()->create(); - $response = $this->actingAs($user)->post('/confirm-password', [ - 'password' => 'password', - ]); + $response = $this->actingAs($user)->post('/confirm-password', [ + 'password' => 'password', + ]); - $response->assertRedirect(); - $response->assertSessionHasNoErrors(); -}); + $response->assertRedirect(); + $response->assertSessionHasNoErrors(); + } -test('password is not confirmed with invalid password', function () { - $user = User::factory()->create(); + public function test_password_is_not_confirmed_with_invalid_password() + { + $user = User::factory()->create(); - $response = $this->actingAs($user)->post('/confirm-password', [ - 'password' => 'wrong-password', - ]); + $response = $this->actingAs($user)->post('/confirm-password', [ + 'password' => 'wrong-password', + ]); - $response->assertSessionHasErrors(); -}); + $response->assertSessionHasErrors(); + } +} diff --git a/tests/Feature/Auth/PasswordResetTest.php b/tests/Feature/Auth/PasswordResetTest.php index 0504276a6..3c7441f78 100644 --- a/tests/Feature/Auth/PasswordResetTest.php +++ b/tests/Feature/Auth/PasswordResetTest.php @@ -1,60 +1,73 @@ get('/forgot-password'); + public function test_reset_password_link_screen_can_be_rendered() + { + $response = $this->get('/forgot-password'); - $response->assertStatus(200); -}); + $response->assertStatus(200); + } -test('reset password link can be requested', function () { - Notification::fake(); + public function test_reset_password_link_can_be_requested() + { + Notification::fake(); - $user = User::factory()->create(); + $user = User::factory()->create(); - $this->post('/forgot-password', ['email' => $user->email]); + $this->post('/forgot-password', ['email' => $user->email]); - Notification::assertSentTo($user, ResetPassword::class); -}); + Notification::assertSentTo($user, ResetPassword::class); + } -test('reset password screen can be rendered', function () { - Notification::fake(); + public function test_reset_password_screen_can_be_rendered() + { + Notification::fake(); - $user = User::factory()->create(); + $user = User::factory()->create(); - $this->post('/forgot-password', ['email' => $user->email]); + $this->post('/forgot-password', ['email' => $user->email]); - Notification::assertSentTo($user, ResetPassword::class, function ($notification) { - $response = $this->get('/reset-password/'.$notification->token); + Notification::assertSentTo($user, ResetPassword::class, function ($notification) { + $response = $this->get('/reset-password/'.$notification->token); - $response->assertStatus(200); + $response->assertStatus(200); - return true; - }); -}); + return true; + }); + } -test('password can be reset with valid token', function () { - Notification::fake(); + public function test_password_can_be_reset_with_valid_token() + { + Notification::fake(); - $user = User::factory()->create(); + $user = User::factory()->create(); - $this->post('/forgot-password', ['email' => $user->email]); + $this->post('/forgot-password', ['email' => $user->email]); - Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { - $response = $this->post('/reset-password', [ - 'token' => $notification->token, - 'email' => $user->email, - 'password' => 'password', - 'password_confirmation' => 'password', - ]); + Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { + $response = $this->post('/reset-password', [ + 'token' => $notification->token, + 'email' => $user->email, + 'password' => 'password', + 'password_confirmation' => 'password', + ]); - $response - ->assertSessionHasNoErrors() - ->assertRedirect(route('login')); + $response + ->assertSessionHasNoErrors() + ->assertRedirect(route('login')); - return true; - }); -}); + return true; + }); + } +} diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 352ca7879..d0c3ea257 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -1,19 +1,31 @@ get('/register'); +namespace Tests\Feature\Auth; - $response->assertStatus(200); -}); +use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\TestCase; -test('new users can register', function () { - $response = $this->post('/register', [ - 'name' => 'Test User', - 'email' => 'test@example.com', - 'password' => 'password', - 'password_confirmation' => 'password', - ]); +class RegistrationTest extends TestCase +{ + use RefreshDatabase; - $this->assertAuthenticated(); - $response->assertRedirect(route('dashboard', absolute: false)); -}); + public function test_registration_screen_can_be_rendered() + { + $response = $this->get('/register'); + + $response->assertStatus(200); + } + + public function test_new_users_can_register() + { + $response = $this->post('/register', [ + 'name' => 'Test User', + 'email' => 'test@example.com', + 'password' => 'password', + 'password_confirmation' => 'password', + ]); + + $this->assertAuthenticated(); + $response->assertRedirect(route('dashboard', absolute: false)); + } +} diff --git a/tests/Feature/DashboardTest.php b/tests/Feature/DashboardTest.php index 9beacda08..5903f8f20 100644 --- a/tests/Feature/DashboardTest.php +++ b/tests/Feature/DashboardTest.php @@ -1,13 +1,27 @@ get('/dashboard')->assertRedirect('/login'); -}); + public function test_guests_are_redirected_to_the_login_page() + { + $response = $this->get('/dashboard'); + $response->assertRedirect('/login'); + } -test('authenticated users can visit the dashboard', function () { - $this->actingAs($user = User::factory()->create()); + public function test_authenticated_users_can_visit_the_dashboard() + { + $user = User::factory()->create(); + $this->actingAs($user); - $this->get('/dashboard')->assertStatus(200); -}); + $response = $this->get('/dashboard'); + $response->assertStatus(200); + } +} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 8b5843f49..c3dd53d0c 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -1,7 +1,18 @@ get('/'); +namespace Tests\Feature; - $response->assertStatus(200); -}); +use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\TestCase; + +class ExampleTest extends TestCase +{ + use RefreshDatabase; + + public function test_returns_a_successful_response() + { + $response = $this->get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Feature/Settings/PasswordUpdateTest.php b/tests/Feature/Settings/PasswordUpdateTest.php index 213e0a161..64e9189b3 100644 --- a/tests/Feature/Settings/PasswordUpdateTest.php +++ b/tests/Feature/Settings/PasswordUpdateTest.php @@ -1,40 +1,51 @@ create(); - - $response = $this - ->actingAs($user) - ->from('/settings/password') - ->put('/settings/password', [ - 'current_password' => 'password', - 'password' => 'new-password', - 'password_confirmation' => 'new-password', - ]); - - $response - ->assertSessionHasNoErrors() - ->assertRedirect('/settings/password'); - - $this->assertTrue(Hash::check('new-password', $user->refresh()->password)); -}); - -test('correct password must be provided to update password', function () { - $user = User::factory()->create(); - - $response = $this - ->actingAs($user) - ->from('/settings/password') - ->put('/settings/password', [ - 'current_password' => 'wrong-password', - 'password' => 'new-password', - 'password_confirmation' => 'new-password', - ]); - - $response - ->assertSessionHasErrors('current_password') - ->assertRedirect('/settings/password'); -}); +use Tests\TestCase; + +class PasswordUpdateTest extends TestCase +{ + use RefreshDatabase; + + public function test_password_can_be_updated() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->from('/settings/password') + ->put('/settings/password', [ + 'current_password' => 'password', + 'password' => 'new-password', + 'password_confirmation' => 'new-password', + ]); + + $response + ->assertSessionHasNoErrors() + ->assertRedirect('/settings/password'); + + $this->assertTrue(Hash::check('new-password', $user->refresh()->password)); + } + + public function test_correct_password_must_be_provided_to_update_password() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->from('/settings/password') + ->put('/settings/password', [ + 'current_password' => 'wrong-password', + 'password' => 'new-password', + 'password_confirmation' => 'new-password', + ]); + + $response + ->assertSessionHasErrors('current_password') + ->assertRedirect('/settings/password'); + } +} diff --git a/tests/Feature/Settings/ProfileUpdateTest.php b/tests/Feature/Settings/ProfileUpdateTest.php index bcb77986e..7d5121441 100644 --- a/tests/Feature/Settings/ProfileUpdateTest.php +++ b/tests/Feature/Settings/ProfileUpdateTest.php @@ -1,85 +1,99 @@ create(); - - $response = $this - ->actingAs($user) - ->get('/settings/profile'); - - $response->assertOk(); -}); - -test('profile information can be updated', function () { - $user = User::factory()->create(); - - $response = $this - ->actingAs($user) - ->patch('/settings/profile', [ - 'name' => 'Test User', - 'email' => 'test@example.com', - ]); - - $response - ->assertSessionHasNoErrors() - ->assertRedirect('/settings/profile'); - - $user->refresh(); - - $this->assertSame('Test User', $user->name); - $this->assertSame('test@example.com', $user->email); - $this->assertNull($user->email_verified_at); -}); - -test('email verification status is unchanged when the email address is unchanged', function () { - $user = User::factory()->create(); - - $response = $this - ->actingAs($user) - ->patch('/settings/profile', [ - 'name' => 'Test User', - 'email' => $user->email, - ]); +namespace Tests\Feature\Settings; - $response - ->assertSessionHasNoErrors() - ->assertRedirect('/settings/profile'); - - $this->assertNotNull($user->refresh()->email_verified_at); -}); - -test('users can delete their account', function () { - $user = User::factory()->create(); - - $response = $this - ->actingAs($user) - ->delete('/settings/profile', [ - 'password' => 'password', - ]); - - $response - ->assertSessionHasNoErrors() - ->assertRedirect('/'); - - $this->assertGuest(); - $this->assertNull($user->fresh()); -}); - -test('correct password must be provided to delete account', function () { - $user = User::factory()->create(); - - $response = $this - ->actingAs($user) - ->from('/settings/profile') - ->delete('/settings/profile', [ - 'password' => 'wrong-password', - ]); - - $response - ->assertSessionHasErrors('password') - ->assertRedirect('/settings/profile'); - - $this->assertNotNull($user->fresh()); -}); +use App\Models\User; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\TestCase; + +class ProfileUpdateTest extends TestCase +{ + use RefreshDatabase; + + public function test_profile_page_is_displayed() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->get('/settings/profile'); + + $response->assertOk(); + } + + public function test_profile_information_can_be_updated() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->patch('/settings/profile', [ + 'name' => 'Test User', + 'email' => 'test@example.com', + ]); + + $response + ->assertSessionHasNoErrors() + ->assertRedirect('/settings/profile'); + + $user->refresh(); + + $this->assertSame('Test User', $user->name); + $this->assertSame('test@example.com', $user->email); + $this->assertNull($user->email_verified_at); + } + + public function test_email_verification_status_is_unchanged_when_the_email_address_is_unchanged() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->patch('/settings/profile', [ + 'name' => 'Test User', + 'email' => $user->email, + ]); + + $response + ->assertSessionHasNoErrors() + ->assertRedirect('/settings/profile'); + + $this->assertNotNull($user->refresh()->email_verified_at); + } + + public function test_user_can_delete_their_account() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->delete('/settings/profile', [ + 'password' => 'password', + ]); + + $response + ->assertSessionHasNoErrors() + ->assertRedirect('/'); + + $this->assertGuest(); + $this->assertNull($user->fresh()); + } + + public function test_correct_password_must_be_provided_to_delete_account() + { + $user = User::factory()->create(); + + $response = $this + ->actingAs($user) + ->from('/settings/profile') + ->delete('/settings/profile', [ + 'password' => 'wrong-password', + ]); + + $response + ->assertSessionHasErrors('password') + ->assertRedirect('/settings/profile'); + + $this->assertNotNull($user->fresh()); + } +} diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 44a4f337a..2cc6866ff 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -1,5 +1,16 @@ toBeTrue(); -}); +namespace Tests\Unit; + +use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\TestCase; + +class ExampleTest extends TestCase +{ + use RefreshDatabase; + + public function test_that_true_is_true() + { + $this->assertTrue(true); + } +}