From adcc7563360e9268e77e374a89248f5d19d02f6a Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Mon, 6 Jan 2025 18:17:17 -0500 Subject: [PATCH] Laravel 11.x Compatibility (#20) Co-authored-by: Michael Dyrynda --- .github/workflows/run-tests.yml | 13 +++-- composer.json | 96 +++++++++++++++++---------------- phpunit.xml | 12 ++--- tests/MakeUserTest.php | 47 +++++++--------- tests/Pest.php | 3 ++ 5 files changed, 87 insertions(+), 84 deletions(-) create mode 100644 tests/Pest.php diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 55dd3ab..1b73916 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,16 +3,19 @@ name: run-tests on: push: pull_request: - types: [opened, edited] + types: + - opened + - edited jobs: test: runs-on: ubuntu-latest + strategy: fail-fast: true matrix: - php: [8.2,8.1] - laravel: [10.0] + php: [8.4, 8.3, 8.2] + laravel: [11.0] name: P${{ matrix.php }} - L${{ matrix.laravel }} @@ -21,7 +24,7 @@ jobs: uses: actions/checkout@v2 - name: Cache dependencies - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} @@ -44,4 +47,4 @@ jobs: composer update --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit --coverage-clover=coverage.clover + run: vendor/bin/pest diff --git a/composer.json b/composer.json index ced9371..d32bb87 100644 --- a/composer.json +++ b/composer.json @@ -1,48 +1,54 @@ { - "name": "dyrynda/laravel-make-user", - "description": "An Artisan console command to create users in your Laravel application.", - "license": "MIT", - "keywords": [ - "laravel", - "artisan", - "console" - ], - "authors": [ - { - "name": "Michael Dyrynda", - "email": "michael@dyrynda.com.au", - "homepage": "https://dyrynda.com.au" - } - ], - "require": { - "php": "^8.1", - "illuminate/support": "^10.0", - "illuminate/console": "^10.0", - "illuminate/database": "^10.0", - "illuminate/auth": "^10.0", - "illuminate/notifications": "^10.0" - }, - "autoload": { - "psr-4": { - "Dyrynda\\Artisan\\": "src/" - } - }, - "require-dev": { - "mockery/mockery": "^1.4.4", - "phpunit/phpunit": "^9.6.0 || ^10.0.7", - "orchestra/testbench": "^8.0" - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } - }, - "minimum-stability": "dev", - "extra": { - "laravel": { - "providers": [ - "Dyrynda\\Artisan\\MakeUserServiceProvider" - ] - } + "name": "dyrynda/laravel-make-user", + "description": "An Artisan console command to create users in your Laravel application.", + "license": "MIT", + "keywords": [ + "laravel", + "artisan", + "console" + ], + "authors": [ + { + "name": "Michael Dyrynda", + "email": "michael@dyrynda.com.au", + "homepage": "https://dyrynda.com.au" } + ], + "require": { + "php": "^8.1", + "illuminate/support": "^10.0 || ^11.0", + "illuminate/console": "^10.0 || ^11.0", + "illuminate/database": "^10.0 || ^11.0", + "illuminate/auth": "^10.0 || ^11.0", + "illuminate/notifications": "^10.0 || ^11.0" + }, + "autoload": { + "psr-4": { + "Dyrynda\\Artisan\\": "src/" + } + }, + "require-dev": { + "mockery/mockery": "^1.4.4", + "orchestra/testbench": "^8.0 || ^9.0", + "pestphp/pest": "^3.0" + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "extra": { + "laravel": { + "providers": [ + "Dyrynda\\Artisan\\MakeUserServiceProvider" + ] + } + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + } } diff --git a/phpunit.xml b/phpunit.xml index e03e9d8..01772c6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,10 +1,5 @@ - - - - src/ - - + ./tests/ @@ -13,4 +8,9 @@ + + + src/ + + diff --git a/tests/MakeUserTest.php b/tests/MakeUserTest.php index 9f01e7d..3277de2 100644 --- a/tests/MakeUserTest.php +++ b/tests/MakeUserTest.php @@ -1,31 +1,22 @@ artisan('make:user') + ->expectsQuestion("What is the new user's email address?", 'user@example.com') + ->expectsQuestion("What is the new user's name?", 'Test User') + ->expectsQuestion("What is the new user's password? (blank generates a random one)", '') + ->expectsQuestion('Should the password be encrypted?', 'yes') + ->expectsQuestion('Do you want to send a password reset email?', 'no') + ->expectsQuestion('Do you have any custom user fields to add? Field=Value (blank continues)', ''); +}); -class MakeUserTest extends TestCase -{ - /** @test */ - public function it_creates_a_new_user() - { - $this->artisan('make:user') - ->expectsQuestion("What is the new user's email address?", 'user@example.com') - ->expectsQuestion("What is the new user's name?", 'Test User') - ->expectsQuestion("What is the new user's password? (blank generates a random one)", '') - ->expectsQuestion('Should the password be encrypted?', 'yes') - ->expectsQuestion('Do you want to send a password reset email?', 'no') - ->expectsQuestion('Do you have any custom user fields to add? Field=Value (blank continues)', ''); - } - - /** @test */ - public function it_creates_a_new_user_with_additional_fields() - { - $this->artisan('make:user') - ->expectsQuestion("What is the new user's email address?", 'user@example.com') - ->expectsQuestion("What is the new user's name?", 'Test User') - ->expectsQuestion("What is the new user's password? (blank generates a random one)", '') - ->expectsQuestion('Should the password be encrypted?', 'yes') - ->expectsQuestion('Do you want to send a password reset email?', 'no') - ->expectsQuestion('Do you have any custom user fields to add? Field=Value (blank continues)', 'field=value') - ->expectsQuestion('Do you have any custom user fields to add? Field=Value (blank continues)', ''); - } -} +it('creates a new user with additional fields', function () { + $this->artisan('make:user') + ->expectsQuestion("What is the new user's email address?", 'user@example.com') + ->expectsQuestion("What is the new user's name?", 'Test User') + ->expectsQuestion("What is the new user's password? (blank generates a random one)", '') + ->expectsQuestion('Should the password be encrypted?', 'yes') + ->expectsQuestion('Do you want to send a password reset email?', 'no') + ->expectsQuestion('Do you have any custom user fields to add? Field=Value (blank continues)', 'field=value') + ->expectsQuestion('Do you have any custom user fields to add? Field=Value (blank continues)', ''); +}); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..8523fe2 --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,3 @@ +in(__DIR__);