diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index cd9976f..2f4d3f9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -78,7 +78,157 @@ jobs: echo "MYSQL_PORT=3306" >> .env - name: Run Tests - run: ./vendor/bin/phpunit --testdox + run: make run-tests + + phpunit-with-laravel: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - laravel: 8.* + php: 8.0 + - laravel: 9.* + php: 8.0 + - laravel: 10.* + php: 8.1 + - laravel: 11.* + php: 8.2 + - laravel: 11.* + php: 8.3 + - laravel: 11.* + php: 8.4 + - laravel: 12.* + php: 8.2 + - laravel: 12.* + php: 8.3 + - laravel: 12.* + php: 8.4 + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: test_db + MYSQL_USER: test_user + MYSQL_PASSWORD: test_password + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping --silent" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + postgres: + image: postgres:14 + env: + POSTGRES_USER: test_user + POSTGRES_PASSWORD: test_password + POSTGRES_DB: test_db + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, pdo, mysql, pgsql + coverage: none + + - name: Checkout target branch + uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + + - name: Checkout PR + uses: actions/checkout@v4 + + - name: Preparing Laravel project + run: | + cd ${{ runner.workspace }} + composer create-project --prefer-dist laravel/laravel laravel ${{ matrix.laravel }} + cd ${{ runner.workspace }}/laravel + composer config repositories.local path ${{ runner.workspace }}/laravel-bulk-upsert + composer require lapaliv/laravel-bulk-upsert:@dev + echo "DB_HOST=127.0.0.1" >> .env + echo "DB_DATABASE=test_db" >> .env + echo "DB_USERNAME=test_user" >> .env + echo "DB_PASSWORD=test_password" >> .env + php artisan key:generate + cp .env .env.testing + mv ${{ runner.workspace }}/laravel/tests/Unit ${{ runner.workspace }}/laravel/tests/Unit_old + cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/App ${{ runner.workspace }}/laravel/tests/ + cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/Database ${{ runner.workspace }}/laravel/tests/ + cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/Unit ${{ runner.workspace }}/laravel/tests/ + cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/TestCaseWrapper.php ${{ runner.workspace }}/laravel/tests/ + sed -i '/^[[:space:]]*> .env + echo "DB_CONNECTION=mysql" >> .env.testing + php artisan config:show database.default + + - name: Run tests (MySQL) + run: | + cd ${{ runner.workspace }}/laravel + ./vendor/bin/phpunit + + - name: Wait for PostgreSQL + run: | + echo "Waiting for PostgreSQL..." + until pg_isready -h 127.0.0.1 -p 5432; do + sleep 2 + done + echo "PostgreSQL is up!" + + - name: Preparing PostgreSQL + run: | + cd ${{ runner.workspace }}/laravel + sed -i 's/^DB_CONNECTION=.*/# &/' .env + sed -i 's/^DB_CONNECTION=.*/# &/' .env.testing + echo "DB_CONNECTION=pgsql" >> .env + echo "DB_CONNECTION=pgsql" >> .env.testing + php artisan config:show database.default + + - name: Run tests (PostgreSQL) + run: | + cd ${{ runner.workspace }}/laravel + ./vendor/bin/phpunit + + - name: Preparing SQLite + run: | + cd ${{ runner.workspace }}/laravel + sed -i 's/^DB_CONNECTION=.*/# &/' .env + sed -i 's/^DB_CONNECTION=.*/# &/' .env.testing + sed -i 's/^DB_DATABASE=.*/# &/' .env + sed -i 's/^DB_DATABASE=.*/# &/' .env.testing + echo "DB_CONNECTION=sqlite" >> .env + echo "DB_CONNECTION=sqlite" >> .env.testing + rm ${{ runner.workspace }}/laravel/database/migrations/* + php artisan config:show database.default + + - name: Run tests (SQLite) + run: | + cd ${{ runner.workspace }}/laravel + ./vendor/bin/phpunit + psalm: runs-on: ubuntu-22.04 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5ed9077 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +run-mysql-tests: + env DB_CONNECTION=mysql DB_HOST=${MYSQL_HOST} DB_PORT=${MYSQL_PORT} DB_DATABASE=${MYSQL_DATABASE} DB_USERNAME=${MYSQL_USERNAME} DB_PASSWORD=${MYSQL_PASSWORD} ./vendor/bin/phpunit + +run-pgsql-tests: + env DB_CONNECTION=pgsql DB_HOST=${POSTGRESQL_HOST} DB_PORT=${POSTGRESQL_PORT} DB_DATABASE=${POSTGRESQL_DATABASE} DB_USERNAME=${POSTGRESQL_USERNAME} DB_PASSWORD=${POSTGRESQL_PASSWORD} ./vendor/bin/phpunit + +run-sqlite-tests: + env DB_CONNECTION=sqlite ./vendor/bin/phpunit + +run-tests: + $(MAKE) run-mysql-tests && $(MAKE) run-pgsql-tests && $(MAKE) run-sqlite-tests diff --git a/composer.json b/composer.json index 983bdbc..9f8fd16 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,7 @@ }, "autoload-dev": { "psr-4": { - "Lapaliv\\BulkUpsert\\Tests\\": "tests", - "Lapaliv\\BulkUpsert\\Tests\\App\\": "tests/app" + "Tests\\": "tests" } }, "authors": [ @@ -40,7 +39,7 @@ "friendsofphp/php-cs-fixer": "^3.13", "orchestra/testbench": "^7.0|^8.0|^9.0", "phpunit/phpunit": "^9.0|^10.0", - "vimeo/psalm": "^5.13", + "vimeo/psalm": "^6.10", "vlucas/phpdotenv": "^5.6" }, "extra": { diff --git a/composer.lock b/composer.lock index 59aab9e..d943d7e 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": "e3b3ecb84935b5cd97781fdffd1ebd58", + "content-hash": "956d83e94618e7a2a146861711ddc382", "packages": [ { "name": "brick/math", @@ -1034,16 +1034,16 @@ }, { "name": "league/commonmark", - "version": "2.6.2", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "06c3b0bf2540338094575612f4a1778d0d2d5e94" + "reference": "6fbb36d44824ed4091adbcf4c7d4a3923cdb3405" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/06c3b0bf2540338094575612f4a1778d0d2d5e94", - "reference": "06c3b0bf2540338094575612f4a1778d0d2d5e94", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/6fbb36d44824ed4091adbcf4c7d4a3923cdb3405", + "reference": "6fbb36d44824ed4091adbcf4c7d4a3923cdb3405", "shasum": "" }, "require": { @@ -1080,7 +1080,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.7-dev" + "dev-main": "2.8-dev" } }, "autoload": { @@ -1137,7 +1137,7 @@ "type": "tidelift" } ], - "time": "2025-04-18T21:09:27+00:00" + "time": "2025-05-05T12:20:28+00:00" }, { "name": "league/config", @@ -2363,23 +2363,24 @@ }, { "name": "symfony/console", - "version": "v6.0.19", + "version": "v6.4.21", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c3ebc83d031b71c39da318ca8b7a07ecc67507ed" + "reference": "a3011c7b7adb58d89f6c0d822abb641d7a5f9719" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c3ebc83d031b71c39da318ca8b7a07ecc67507ed", - "reference": "c3ebc83d031b71c39da318ca8b7a07ecc67507ed", + "url": "https://api.github.com/repos/symfony/console/zipball/a3011c7b7adb58d89f6c0d822abb641d7a5f9719", + "reference": "a3011c7b7adb58d89f6c0d822abb641d7a5f9719", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.4|^6.0" + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^5.4|^6.0|^7.0" }, "conflict": { "symfony/dependency-injection": "<5.4", @@ -2393,18 +2394,16 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/lock": "^5.4|^6.0", - "symfony/process": "^5.4|^6.0", - "symfony/var-dumper": "^5.4|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -2433,12 +2432,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.19" + "source": "https://github.com/symfony/console/tree/v6.4.21" }, "funding": [ { @@ -2454,7 +2453,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:36:10+00:00" + "time": "2025-04-07T15:42:41+00:00" }, { "name": "symfony/css-selector", @@ -2523,20 +2522,20 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.0.2", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "type": "library", "extra": { @@ -2545,7 +2544,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.5-dev" } }, "autoload": { @@ -2570,7 +2569,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -2586,7 +2585,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/error-handler", @@ -2744,25 +2743,22 @@ }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.0.2", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "7bc61cc2db649b4637d331240c5346dcc7708051" + "reference": "7642f5e970b672283b7823222ae8ef8bbc160b9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/7bc61cc2db649b4637d331240c5346dcc7708051", - "reference": "7bc61cc2db649b4637d331240c5346dcc7708051", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/7642f5e970b672283b7823222ae8ef8bbc160b9f", + "reference": "7642f5e970b672283b7823222ae8ef8bbc160b9f", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "psr/event-dispatcher": "^1" }, - "suggest": { - "symfony/event-dispatcher-implementation": "" - }, "type": "library", "extra": { "thanks": { @@ -2770,7 +2766,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.5-dev" } }, "autoload": { @@ -2803,7 +2799,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.1" }, "funding": [ { @@ -2819,7 +2815,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/finder", @@ -3224,7 +3220,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -3283,7 +3279,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0" }, "funding": [ { @@ -3303,7 +3299,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -3361,7 +3357,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.32.0" }, "funding": [ { @@ -3381,16 +3377,16 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "c36586dcf89a12315939e00ec9b4474adcb1d773" + "reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/c36586dcf89a12315939e00ec9b4474adcb1d773", - "reference": "c36586dcf89a12315939e00ec9b4474adcb1d773", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3", + "reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3", "shasum": "" }, "require": { @@ -3444,7 +3440,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.32.0" }, "funding": [ { @@ -3460,11 +3456,11 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2024-09-10T14:38:51+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -3525,7 +3521,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.32.0" }, "funding": [ { @@ -3545,19 +3541,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", "shasum": "" }, "require": { + "ext-iconv": "*", "php": ">=7.2" }, "provide": { @@ -3605,7 +3602,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" }, "funding": [ { @@ -3621,20 +3618,20 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2024-12-23T08:48:59+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", "shasum": "" }, "require": { @@ -3685,7 +3682,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" }, "funding": [ { @@ -3701,11 +3698,11 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-01-02T08:10:11+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", @@ -3761,7 +3758,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.32.0" }, "funding": [ { @@ -3781,7 +3778,7 @@ }, { "name": "symfony/polyfill-uuid", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-uuid.git", @@ -3840,7 +3837,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.32.0" }, "funding": [ { @@ -3860,20 +3857,20 @@ }, { "name": "symfony/process", - "version": "v6.0.19", + "version": "v6.4.20", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "2114fd60f26a296cc403a7939ab91478475a33d4" + "reference": "e2a61c16af36c9a07e5c9906498b73e091949a20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/2114fd60f26a296cc403a7939ab91478475a33d4", - "reference": "2114fd60f26a296cc403a7939ab91478475a33d4", + "url": "https://api.github.com/repos/symfony/process/zipball/e2a61c16af36c9a07e5c9906498b73e091949a20", + "reference": "e2a61c16af36c9a07e5c9906498b73e091949a20", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "type": "library", "autoload": { @@ -3901,7 +3898,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.0.19" + "source": "https://github.com/symfony/process/tree/v6.4.20" }, "funding": [ { @@ -3917,7 +3914,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:36:10+00:00" + "time": "2025-03-10T17:11:00+00:00" }, { "name": "symfony/routing", @@ -4009,28 +4006,26 @@ }, { "name": "symfony/service-contracts", - "version": "v3.0.2", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66" + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d78d39c1599bd1188b8e26bb341da52c3c6d8a66", - "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", "shasum": "" }, "require": { - "php": ">=8.0.2", - "psr/container": "^2.0" + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "type": "library", "extra": { "thanks": { @@ -4038,13 +4033,16 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.5-dev" } }, "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4071,7 +4069,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" }, "funding": [ { @@ -4087,37 +4085,38 @@ "type": "tidelift" } ], - "time": "2022-05-30T19:17:58+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/string", - "version": "v6.0.19", + "version": "v6.4.21", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "d9e72497367c23e08bf94176d2be45b00a9d232a" + "reference": "73e2c6966a5aef1d4892873ed5322245295370c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/d9e72497367c23e08bf94176d2be45b00a9d232a", - "reference": "d9e72497367c23e08bf94176d2be45b00a9d232a", + "url": "https://api.github.com/repos/symfony/string/zipball/73e2c6966a5aef1d4892873ed5322245295370c6", + "reference": "73e2c6966a5aef1d4892873ed5322245295370c6", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": "<2.0" + "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/translation-contracts": "^2.0|^3.0", - "symfony/var-exporter": "^5.4|^6.0" + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -4156,7 +4155,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.19" + "source": "https://github.com/symfony/string/tree/v6.4.21" }, "funding": [ { @@ -4172,7 +4171,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:36:10+00:00" + "time": "2025-04-18T15:23:29+00:00" }, { "name": "symfony/translation", @@ -4271,23 +4270,20 @@ }, { "name": "symfony/translation-contracts", - "version": "v3.0.2", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "acbfbb274e730e5a0236f619b6168d9dedb3e282" + "reference": "4667ff3bd513750603a09c8dedbea942487fb07c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/acbfbb274e730e5a0236f619b6168d9dedb3e282", - "reference": "acbfbb274e730e5a0236f619b6168d9dedb3e282", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/4667ff3bd513750603a09c8dedbea942487fb07c", + "reference": "4667ff3bd513750603a09c8dedbea942487fb07c", "shasum": "" }, "require": { - "php": ">=8.0.2" - }, - "suggest": { - "symfony/translation-implementation": "" + "php": ">=8.1" }, "type": "library", "extra": { @@ -4296,13 +4292,16 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.5-dev" } }, "autoload": { "psr-4": { "Symfony\\Contracts\\Translation\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4329,7 +4328,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/translation-contracts/tree/v3.5.1" }, "funding": [ { @@ -4345,7 +4344,7 @@ "type": "tidelift" } ], - "time": "2022-06-27T17:10:44+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/uid", @@ -4566,16 +4565,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v5.6.1", + "version": "v5.6.2", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" + "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/24ac4c74f91ee2c193fa1aaa5c249cb0822809af", + "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af", "shasum": "" }, "require": { @@ -4634,7 +4633,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.2" }, "funding": [ { @@ -4646,7 +4645,7 @@ "type": "tidelift" } ], - "time": "2024-07-20T21:52:34+00:00" + "time": "2025-04-30T23:37:27+00:00" }, { "name": "voku/portable-ascii", @@ -4784,43 +4783,36 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.6.4", + "version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d" + "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", - "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "url": "https://api.github.com/repos/amphp/amp/zipball/7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9", + "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" }, "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "ext-json": "*", - "jetbrains/phpstorm-stubs": "^2019.3", - "phpunit/phpunit": "^7 | ^8 | ^9", - "react/promise": "^2", - "vimeo/psalm": "^3.12" + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "5.23.1" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, "autoload": { "files": [ - "lib/functions.php", - "lib/Internal/functions.php" + "src/functions.php", + "src/Future/functions.php", + "src/Internal/functions.php" ], "psr-4": { - "Amp\\": "lib" + "Amp\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4828,10 +4820,6 @@ "MIT" ], "authors": [ - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - }, { "name": "Aaron Piotrowski", "email": "aaron@trowski.com" @@ -4843,6 +4831,10 @@ { "name": "Niklas Keller", "email": "me@kelunik.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" } ], "description": "A non-blocking concurrency framework for PHP applications.", @@ -4859,9 +4851,8 @@ "promise" ], "support": { - "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.6.4" + "source": "https://github.com/amphp/amp/tree/v3.1.0" }, "funding": [ { @@ -4869,41 +4860,45 @@ "type": "github" } ], - "time": "2024-03-21T18:52:26+00:00" + "time": "2025-01-26T16:07:39+00:00" }, { "name": "amphp/byte-stream", - "version": "v1.8.2", + "version": "v2.1.2", "source": { "type": "git", "url": "https://github.com/amphp/byte-stream.git", - "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc" + "reference": "55a6bd071aec26fa2a3e002618c20c35e3df1b46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc", - "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/55a6bd071aec26fa2a3e002618c20c35e3df1b46", + "reference": "55a6bd071aec26fa2a3e002618c20c35e3df1b46", "shasum": "" }, "require": { - "amphp/amp": "^2", - "php": ">=7.1" + "amphp/amp": "^3", + "amphp/parser": "^1.1", + "amphp/pipeline": "^1", + "amphp/serialization": "^1", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2.3" }, "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1.4", - "friendsofphp/php-cs-fixer": "^2.3", - "jetbrains/phpstorm-stubs": "^2019.3", - "phpunit/phpunit": "^6 || ^7 || ^8", - "psalm/phar": "^3.11.4" + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "5.22.1" }, "type": "library", "autoload": { "files": [ - "lib/functions.php" + "src/functions.php", + "src/Internal/functions.php" ], "psr-4": { - "Amp\\ByteStream\\": "lib" + "Amp\\ByteStream\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4932,7 +4927,7 @@ ], "support": { "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/v1.8.2" + "source": "https://github.com/amphp/byte-stream/tree/v2.1.2" }, "funding": [ { @@ -4940,34 +4935,39 @@ "type": "github" } ], - "time": "2024-04-13T18:00:56+00:00" + "time": "2025-03-16T17:10:27+00:00" }, { - "name": "clue/ndjson-react", - "version": "v1.3.0", + "name": "amphp/cache", + "version": "v2.0.1", "source": { "type": "git", - "url": "https://github.com/clue/reactphp-ndjson.git", - "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" + "url": "https://github.com/amphp/cache.git", + "reference": "46912e387e6aa94933b61ea1ead9cf7540b7797c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", - "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", + "url": "https://api.github.com/repos/amphp/cache/zipball/46912e387e6aa94933b61ea1ead9cf7540b7797c", + "reference": "46912e387e6aa94933b61ea1ead9cf7540b7797c", "shasum": "" }, "require": { - "php": ">=5.3", - "react/stream": "^1.2" + "amphp/amp": "^3", + "amphp/serialization": "^1", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" }, "require-dev": { - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", - "react/event-loop": "^1.2" + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" }, "type": "library", "autoload": { "psr-4": { - "Clue\\React\\NDJson\\": "src/" + "Amp\\Cache\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4976,75 +4976,71 @@ ], "authors": [ { - "name": "Christian Lück", - "email": "christian@clue.engineering" + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" } ], - "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", - "homepage": "https://github.com/clue/reactphp-ndjson", - "keywords": [ - "NDJSON", - "json", - "jsonlines", - "newline", - "reactphp", - "streaming" - ], + "description": "A fiber-aware cache API based on Amp and Revolt.", + "homepage": "https://amphp.org/cache", "support": { - "issues": "https://github.com/clue/reactphp-ndjson/issues", - "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" + "issues": "https://github.com/amphp/cache/issues", + "source": "https://github.com/amphp/cache/tree/v2.0.1" }, "funding": [ { - "url": "https://clue.engineering/support", - "type": "custom" - }, - { - "url": "https://github.com/clue", + "url": "https://github.com/amphp", "type": "github" } ], - "time": "2022-12-23T10:58:28+00:00" + "time": "2024-04-19T03:38:06+00:00" }, { - "name": "composer/pcre", - "version": "3.3.2", + "name": "amphp/dns", + "version": "v2.4.0", "source": { "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + "url": "https://github.com/amphp/dns.git", + "reference": "78eb3db5fc69bf2fc0cb503c4fcba667bc223c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", - "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "url": "https://api.github.com/repos/amphp/dns/zipball/78eb3db5fc69bf2fc0cb503c4fcba667bc223c71", + "reference": "78eb3db5fc69bf2fc0cb503c4fcba667bc223c71", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0" - }, - "conflict": { - "phpstan/phpstan": "<1.11.10" + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/cache": "^2", + "amphp/parser": "^1", + "amphp/process": "^2", + "daverandom/libdns": "^2.0.2", + "ext-filter": "*", + "ext-json": "*", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" }, "require-dev": { - "phpstan/phpstan": "^1.12 || ^2", - "phpstan/phpstan-strict-rules": "^1 || ^2", - "phpunit/phpunit": "^8 || ^9" + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "5.20" }, "type": "library", - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - }, - "branch-alias": { - "dev-main": "3.x-dev" - } - }, "autoload": { + "files": [ + "src/functions.php" + ], "psr-4": { - "Composer\\Pcre\\": "src" + "Amp\\Dns\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -5053,68 +5049,91 @@ ], "authors": [ { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" + "name": "Chris Wright", + "email": "addr@daverandom.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" } ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "description": "Async DNS resolution for Amp.", + "homepage": "https://github.com/amphp/dns", "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" + "amp", + "amphp", + "async", + "client", + "dns", + "resolve" ], "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.2" + "issues": "https://github.com/amphp/dns/issues", + "source": "https://github.com/amphp/dns/tree/v2.4.0" }, "funding": [ { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", + "url": "https://github.com/amphp", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" } ], - "time": "2024-11-12T16:29:46+00:00" + "time": "2025-01-19T15:43:40+00:00" }, { - "name": "composer/semver", - "version": "3.4.3", + "name": "amphp/parallel", + "version": "v2.3.1", "source": { "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12" + "url": "https://github.com/amphp/parallel.git", + "reference": "5113111de02796a782f5d90767455e7391cca190" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", - "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "url": "https://api.github.com/repos/amphp/parallel/zipball/5113111de02796a782f5d90767455e7391cca190", + "reference": "5113111de02796a782f5d90767455e7391cca190", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/cache": "^2", + "amphp/parser": "^1", + "amphp/pipeline": "^1", + "amphp/process": "^2", + "amphp/serialization": "^1", + "amphp/socket": "^2", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1" }, "require-dev": { - "phpstan/phpstan": "^1.11", - "symfony/phpunit-bridge": "^3 || ^7" + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.18" }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, "autoload": { + "files": [ + "src/Context/functions.php", + "src/Context/Internal/functions.php", + "src/Ipc/functions.php", + "src/Worker/functions.php" + ], "psr-4": { - "Composer\\Semver\\": "src" + "Amp\\Parallel\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -5123,77 +5142,65 @@ ], "authors": [ { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" }, { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" + "name": "Niklas Keller", + "email": "me@kelunik.com" }, { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" + "name": "Stephen Coakley", + "email": "me@stephencoakley.com" } ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", + "description": "Parallel processing component for Amp.", + "homepage": "https://github.com/amphp/parallel", "keywords": [ - "semantic", - "semver", - "validation", - "versioning" + "async", + "asynchronous", + "concurrent", + "multi-processing", + "multi-threading" ], "support": { - "irc": "ircs://irc.libera.chat:6697/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.3" + "issues": "https://github.com/amphp/parallel/issues", + "source": "https://github.com/amphp/parallel/tree/v2.3.1" }, "funding": [ { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", + "url": "https://github.com/amphp", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" } ], - "time": "2024-09-19T14:15:21+00:00" + "time": "2024-12-21T01:56:09+00:00" }, { - "name": "composer/xdebug-handler", - "version": "3.0.5", + "name": "amphp/parser", + "version": "v1.1.1", "source": { "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" + "url": "https://github.com/amphp/parser.git", + "reference": "3cf1f8b32a0171d4b1bed93d25617637a77cded7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", - "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", + "url": "https://api.github.com/repos/amphp/parser/zipball/3cf1f8b32a0171d4b1bed93d25617637a77cded7", + "reference": "3cf1f8b32a0171d4b1bed93d25617637a77cded7", "shasum": "" }, "require": { - "composer/pcre": "^1 || ^2 || ^3", - "php": "^7.2.5 || ^8.0", - "psr/log": "^1 || ^2 || ^3" + "php": ">=7.4" }, "require-dev": { - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-strict-rules": "^1.1", - "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" }, "type": "library", "autoload": { "psr-4": { - "Composer\\XdebugHandler\\": "src" + "Amp\\Parser\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -5202,10 +5209,650 @@ ], "authors": [ { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A generator parser to make streaming parsers simple.", + "homepage": "https://github.com/amphp/parser", + "keywords": [ + "async", + "non-blocking", + "parser", + "stream" + ], + "support": { + "issues": "https://github.com/amphp/parser/issues", + "source": "https://github.com/amphp/parser/tree/v1.1.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-03-21T19:16:53+00:00" + }, + { + "name": "amphp/pipeline", + "version": "v1.2.3", + "source": { + "type": "git", + "url": "https://github.com/amphp/pipeline.git", + "reference": "7b52598c2e9105ebcddf247fc523161581930367" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/pipeline/zipball/7b52598c2e9105ebcddf247fc523161581930367", + "reference": "7b52598c2e9105ebcddf247fc523161581930367", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "php": ">=8.1", + "revolt/event-loop": "^1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.18" + }, + "type": "library", + "autoload": { + "psr-4": { + "Amp\\Pipeline\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Asynchronous iterators and operators.", + "homepage": "https://amphp.org/pipeline", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "iterator", + "non-blocking" + ], + "support": { + "issues": "https://github.com/amphp/pipeline/issues", + "source": "https://github.com/amphp/pipeline/tree/v1.2.3" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2025-03-16T16:33:53+00:00" + }, + { + "name": "amphp/process", + "version": "v2.0.3", + "source": { + "type": "git", + "url": "https://github.com/amphp/process.git", + "reference": "52e08c09dec7511d5fbc1fb00d3e4e79fc77d58d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/process/zipball/52e08c09dec7511d5fbc1fb00d3e4e79fc77d58d", + "reference": "52e08c09dec7511d5fbc1fb00d3e4e79fc77d58d", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Process\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A fiber-aware process manager based on Amp and Revolt.", + "homepage": "https://amphp.org/process", + "support": { + "issues": "https://github.com/amphp/process/issues", + "source": "https://github.com/amphp/process/tree/v2.0.3" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-04-19T03:13:44+00:00" + }, + { + "name": "amphp/serialization", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/serialization.git", + "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/serialization/zipball/693e77b2fb0b266c3c7d622317f881de44ae94a1", + "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "phpunit/phpunit": "^9 || ^8 || ^7" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Serialization\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Serialization tools for IPC and data storage in PHP.", + "homepage": "https://github.com/amphp/serialization", + "keywords": [ + "async", + "asynchronous", + "serialization", + "serialize" + ], + "support": { + "issues": "https://github.com/amphp/serialization/issues", + "source": "https://github.com/amphp/serialization/tree/master" + }, + "time": "2020-03-25T21:39:07+00:00" + }, + { + "name": "amphp/socket", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/socket.git", + "reference": "58e0422221825b79681b72c50c47a930be7bf1e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/socket/zipball/58e0422221825b79681b72c50c47a930be7bf1e1", + "reference": "58e0422221825b79681b72c50c47a930be7bf1e1", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/dns": "^2", + "ext-openssl": "*", + "kelunik/certificate": "^1.1", + "league/uri": "^6.5 | ^7", + "league/uri-interfaces": "^2.3 | ^7", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "amphp/process": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "5.20" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php", + "src/Internal/functions.php", + "src/SocketAddress/functions.php" + ], + "psr-4": { + "Amp\\Socket\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Lowrey", + "email": "rdlowrey@gmail.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Non-blocking socket connection / server implementations based on Amp and Revolt.", + "homepage": "https://github.com/amphp/socket", + "keywords": [ + "amp", + "async", + "encryption", + "non-blocking", + "sockets", + "tcp", + "tls" + ], + "support": { + "issues": "https://github.com/amphp/socket/issues", + "source": "https://github.com/amphp/socket/tree/v2.3.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-04-21T14:33:03+00:00" + }, + { + "name": "amphp/sync", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/sync.git", + "reference": "217097b785130d77cfcc58ff583cf26cd1770bf1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/sync/zipball/217097b785130d77cfcc58ff583cf26cd1770bf1", + "reference": "217097b785130d77cfcc58ff583cf26cd1770bf1", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/pipeline": "^1", + "amphp/serialization": "^1", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "5.23" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Sync\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Stephen Coakley", + "email": "me@stephencoakley.com" + } + ], + "description": "Non-blocking synchronization primitives for PHP based on Amp and Revolt.", + "homepage": "https://github.com/amphp/sync", + "keywords": [ + "async", + "asynchronous", + "mutex", + "semaphore", + "synchronization" + ], + "support": { + "issues": "https://github.com/amphp/sync/issues", + "source": "https://github.com/amphp/sync/tree/v2.3.0" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-08-03T19:31:26+00:00" + }, + { + "name": "clue/ndjson-react", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/clue/reactphp-ndjson.git", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\React\\NDJson\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", + "homepage": "https://github.com/clue/reactphp-ndjson", + "keywords": [ + "NDJSON", + "json", + "jsonlines", + "newline", + "reactphp", + "streaming" + ], + "support": { + "issues": "https://github.com/clue/reactphp-ndjson/issues", + "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-12-23T10:58:28+00:00" + }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.3", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-09-19T14:15:21+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], "description": "Restarts a process without Xdebug.", "keywords": [ "Xdebug", @@ -5232,6 +5879,102 @@ ], "time": "2024-05-06T16:37:16+00:00" }, + { + "name": "danog/advanced-json-rpc", + "version": "v3.2.2", + "source": { + "type": "git", + "url": "https://github.com/danog/php-advanced-json-rpc.git", + "reference": "aadb1c4068a88c3d0530cfe324b067920661efcb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/danog/php-advanced-json-rpc/zipball/aadb1c4068a88c3d0530cfe324b067920661efcb", + "reference": "aadb1c4068a88c3d0530cfe324b067920661efcb", + "shasum": "" + }, + "require": { + "netresearch/jsonmapper": "^5", + "php": ">=8.1", + "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" + }, + "replace": { + "felixfbecker/php-advanced-json-rpc": "^3" + }, + "require-dev": { + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-4": { + "AdvancedJsonRpc\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + }, + { + "name": "Daniil Gentili", + "email": "daniil@daniil.it" + } + ], + "description": "A more advanced JSONRPC implementation", + "support": { + "issues": "https://github.com/danog/php-advanced-json-rpc/issues", + "source": "https://github.com/danog/php-advanced-json-rpc/tree/v3.2.2" + }, + "time": "2025-02-14T10:55:15+00:00" + }, + { + "name": "daverandom/libdns", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/DaveRandom/LibDNS.git", + "reference": "b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DaveRandom/LibDNS/zipball/b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a", + "reference": "b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "Required for IDN support" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "LibDNS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "DNS protocol implementation written in pure PHP", + "keywords": [ + "dns" + ], + "support": { + "issues": "https://github.com/DaveRandom/LibDNS/issues", + "source": "https://github.com/DaveRandom/LibDNS/tree/v2.1.0" + }, + "time": "2024-04-12T12:12:48+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "v0.1.1", @@ -5449,51 +6192,6 @@ }, "time": "2024-11-21T13:46:39+00:00" }, - { - "name": "felixfbecker/advanced-json-rpc", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447", - "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447", - "shasum": "" - }, - "require": { - "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", - "php": "^7.1 || ^8.0", - "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" - }, - "require-dev": { - "phpunit/phpunit": "^7.0 || ^8.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "AdvancedJsonRpc\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "ISC" - ], - "authors": [ - { - "name": "Felix Becker", - "email": "felix.b@outlook.com" - } - ], - "description": "A more advanced JSONRPC implementation", - "support": { - "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", - "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1" - }, - "time": "2021-06-11T22:34:44+00:00" - }, { "name": "felixfbecker/language-server-protocol", "version": "v1.5.3", @@ -5787,20 +6485,20 @@ }, { "name": "hamcrest/hamcrest-php", - "version": "v2.0.1", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", - "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487", + "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487", "shasum": "" }, "require": { - "php": "^5.3|^7.0|^8.0" + "php": "^7.4|^8.0" }, "replace": { "cordoval/hamcrest-php": "*", @@ -5808,8 +6506,8 @@ "kodova/hamcrest-php": "*" }, "require-dev": { - "phpunit/php-file-iterator": "^1.4 || ^2.0", - "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + "phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { @@ -5832,51 +6530,260 @@ ], "support": { "issues": "https://github.com/hamcrest/hamcrest-php/issues", - "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.1.1" + }, + "time": "2025-04-30T06:54:44+00:00" + }, + { + "name": "kelunik/certificate", + "version": "v1.1.3", + "source": { + "type": "git", + "url": "https://github.com/kelunik/certificate.git", + "reference": "7e00d498c264d5eb4f78c69f41c8bd6719c0199e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kelunik/certificate/zipball/7e00d498c264d5eb4f78c69f41c8bd6719c0199e", + "reference": "7e00d498c264d5eb4f78c69f41c8bd6719c0199e", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "php": ">=7.0" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^6 | 7 | ^8 | ^9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Kelunik\\Certificate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Access certificate details and transform between different formats.", + "keywords": [ + "DER", + "certificate", + "certificates", + "openssl", + "pem", + "x509" + ], + "support": { + "issues": "https://github.com/kelunik/certificate/issues", + "source": "https://github.com/kelunik/certificate/tree/v1.1.3" }, - "time": "2020-07-09T08:09:16+00:00" + "time": "2023-02-03T21:26:53+00:00" }, { "name": "laravel/tinker", "version": "v2.10.1", "source": { "type": "git", - "url": "https://github.com/laravel/tinker.git", - "reference": "22177cc71807d38f2810c6204d8f7183d88a57d3" + "url": "https://github.com/laravel/tinker.git", + "reference": "22177cc71807d38f2810c6204d8f7183d88a57d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/tinker/zipball/22177cc71807d38f2810c6204d8f7183d88a57d3", + "reference": "22177cc71807d38f2810c6204d8f7183d88a57d3", + "shasum": "" + }, + "require": { + "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", + "php": "^7.2.5|^8.0", + "psy/psysh": "^0.11.1|^0.12.0", + "symfony/var-dumper": "^4.3.4|^5.0|^6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": "~1.3.3|^1.4.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8.5.8|^9.3.3|^10.0" + }, + "suggest": { + "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0)." + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Tinker\\TinkerServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Tinker\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Powerful REPL for the Laravel framework.", + "keywords": [ + "REPL", + "Tinker", + "laravel", + "psysh" + ], + "support": { + "issues": "https://github.com/laravel/tinker/issues", + "source": "https://github.com/laravel/tinker/tree/v2.10.1" + }, + "time": "2025-01-27T14:24:01+00:00" + }, + { + "name": "league/uri", + "version": "7.5.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri.git", + "reference": "81fb5145d2644324614cc532b28efd0215bda430" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430", + "reference": "81fb5145d2644324614cc532b28efd0215bda430", + "shasum": "" + }, + "require": { + "league/uri-interfaces": "^7.5", + "php": "^8.1" + }, + "conflict": { + "league/uri-schemes": "^1.0" + }, + "suggest": { + "ext-bcmath": "to improve IPV4 host parsing", + "ext-fileinfo": "to create Data URI from file contennts", + "ext-gmp": "to improve IPV4 host parsing", + "ext-intl": "to handle IDN host with the best performance", + "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", + "league/uri-components": "Needed to easily manipulate URI objects components", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" + } + ], + "description": "URI manipulation library", + "homepage": "https://uri.thephpleague.com", + "keywords": [ + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "middleware", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "uri-template", + "url", + "ws" + ], + "support": { + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri-src/issues", + "source": "https://github.com/thephpleague/uri/tree/7.5.1" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2024-12-08T08:40:02+00:00" + }, + { + "name": "league/uri-interfaces", + "version": "7.5.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri-interfaces.git", + "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/22177cc71807d38f2810c6204d8f7183d88a57d3", - "reference": "22177cc71807d38f2810c6204d8f7183d88a57d3", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", + "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", "shasum": "" }, "require": { - "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "php": "^7.2.5|^8.0", - "psy/psysh": "^0.11.1|^0.12.0", - "symfony/var-dumper": "^4.3.4|^5.0|^6.0|^7.0" - }, - "require-dev": { - "mockery/mockery": "~1.3.3|^1.4.2", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.5.8|^9.3.3|^10.0" + "ext-filter": "*", + "php": "^8.1", + "psr/http-factory": "^1", + "psr/http-message": "^1.1 || ^2.0" }, "suggest": { - "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0)." + "ext-bcmath": "to improve IPV4 host parsing", + "ext-gmp": "to improve IPV4 host parsing", + "ext-intl": "to handle IDN host with the best performance", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" }, "type": "library", "extra": { - "laravel": { - "providers": [ - "Laravel\\Tinker\\TinkerServiceProvider" - ] + "branch-alias": { + "dev-master": "7.x-dev" } }, "autoload": { "psr-4": { - "Laravel\\Tinker\\": "src/" + "League\\Uri\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -5885,22 +6792,45 @@ ], "authors": [ { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" } ], - "description": "Powerful REPL for the Laravel framework.", + "description": "Common interfaces and classes for URI representation and interaction", + "homepage": "https://uri.thephpleague.com", "keywords": [ - "REPL", - "Tinker", - "laravel", - "psysh" + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "url", + "ws" ], "support": { - "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v2.10.1" + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri-src/issues", + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.5.0" }, - "time": "2025-01-27T14:24:01+00:00" + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2024-12-08T08:18:47+00:00" }, { "name": "mockery/mockery", @@ -5987,16 +6917,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.0", + "version": "1.13.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414" + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c", + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c", "shasum": "" }, "require": { @@ -6035,7 +6965,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.1" }, "funding": [ { @@ -6043,20 +6973,20 @@ "type": "tidelift" } ], - "time": "2025-02-12T12:17:51+00:00" + "time": "2025-04-29T12:36:36+00:00" }, { "name": "netresearch/jsonmapper", - "version": "v4.5.0", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5" + "reference": "8c64d8d444a5d764c641ebe97e0e3bc72b25bf6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8e76efb98ee8b6afc54687045e1b8dba55ac76e5", - "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8c64d8d444a5d764c641ebe97e0e3bc72b25bf6c", + "reference": "8c64d8d444a5d764c641ebe97e0e3bc72b25bf6c", "shasum": "" }, "require": { @@ -6092,31 +7022,33 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.5.0" + "source": "https://github.com/cweiske/jsonmapper/tree/v5.0.0" }, - "time": "2024-09-08T10:13:13+00:00" + "time": "2024-09-08T10:20:00+00:00" }, { "name": "nikic/php-parser", - "version": "v4.19.4", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/715f4d25e225bc47b293a8b997fe6ce99bf987d2", - "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -6124,7 +7056,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -6148,9 +7080,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.4" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-09-29T15:01:53+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "nunomaduro/collision", @@ -7315,16 +8247,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.22", + "version": "9.6.23", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c" + "reference": "43d2cb18d0675c38bd44982a5d1d88f6d53d8d95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c", - "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/43d2cb18d0675c38bd44982a5d1d88f6d53d8d95", + "reference": "43d2cb18d0675c38bd44982a5d1d88f6d53d8d95", "shasum": "" }, "require": { @@ -7335,7 +8267,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.1", + "myclabs/deep-copy": "^1.13.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=7.3", @@ -7398,7 +8330,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.23" }, "funding": [ { @@ -7409,12 +8341,128 @@ "url": "https://github.com/sebastianbergmann", "type": "github" }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, { "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", "type": "tidelift" } ], - "time": "2024-12-05T13:48:26+00:00" + "time": "2025-05-02T06:40:34+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" }, { "name": "psy/psysh", @@ -8021,6 +9069,78 @@ ], "time": "2024-06-11T12:45:25+00:00" }, + { + "name": "revolt/event-loop", + "version": "v1.0.7", + "source": { + "type": "git", + "url": "https://github.com/revoltphp/event-loop.git", + "reference": "09bf1bf7f7f574453efe43044b06fafe12216eb3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/revoltphp/event-loop/zipball/09bf1bf7f7f574453efe43044b06fafe12216eb3", + "reference": "09bf1bf7f7f574453efe43044b06fafe12216eb3", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "ext-json": "*", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.15" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Revolt\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Rock-solid event loop for concurrent PHP applications.", + "keywords": [ + "async", + "asynchronous", + "concurrency", + "event", + "event-loop", + "non-blocking", + "scheduler" + ], + "support": { + "issues": "https://github.com/revoltphp/event-loop/issues", + "source": "https://github.com/revoltphp/event-loop/tree/v1.0.7" + }, + "time": "2025-01-25T19:27:39+00:00" + }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -9054,23 +10174,26 @@ }, { "name": "symfony/filesystem", - "version": "v6.0.19", + "version": "v6.4.13", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "3d49eec03fda1f0fc19b7349fbbe55ebc1004214" + "reference": "4856c9cf585d5a0313d8d35afd681a526f038dd3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/3d49eec03fda1f0fc19b7349fbbe55ebc1004214", - "reference": "3d49eec03fda1f0fc19b7349fbbe55ebc1004214", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/4856c9cf585d5a0313d8d35afd681a526f038dd3", + "reference": "4856c9cf585d5a0313d8d35afd681a526f038dd3", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.8" }, + "require-dev": { + "symfony/process": "^5.4|^6.4|^7.0" + }, "type": "library", "autoload": { "psr-4": { @@ -9097,7 +10220,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.0.19" + "source": "https://github.com/symfony/filesystem/tree/v6.4.13" }, "funding": [ { @@ -9113,7 +10236,7 @@ "type": "tidelift" } ], - "time": "2023-01-20T17:44:14+00:00" + "time": "2024-10-25T15:07:50+00:00" }, { "name": "symfony/options-resolver", @@ -9184,7 +10307,7 @@ }, { "name": "symfony/polyfill-php83", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php83.git", @@ -9240,7 +10363,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php83/tree/v1.32.0" }, "funding": [ { @@ -9258,6 +10381,82 @@ ], "time": "2024-09-09T11:45:10+00:00" }, + { + "name": "symfony/polyfill-php84", + "version": "v1.32.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "000df7860439609837bbe28670b0be15783b7fbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/000df7860439609837bbe28670b0be15783b7fbf", + "reference": "000df7860439609837bbe28670b0be15783b7fbf", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-02-20T12:04:08+00:00" + }, { "name": "symfony/stopwatch", "version": "v6.0.19", @@ -9446,24 +10645,26 @@ }, { "name": "vimeo/psalm", - "version": "5.26.1", + "version": "6.10.3", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "d747f6500b38ac4f7dfc5edbcae6e4b637d7add0" + "reference": "90b5b9f5e7c8e441b191d3c82c58214753d7c7c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/d747f6500b38ac4f7dfc5edbcae6e4b637d7add0", - "reference": "d747f6500b38ac4f7dfc5edbcae6e4b637d7add0", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/90b5b9f5e7c8e441b191d3c82c58214753d7c7c1", + "reference": "90b5b9f5e7c8e441b191d3c82c58214753d7c7c1", "shasum": "" }, "require": { - "amphp/amp": "^2.4.2", - "amphp/byte-stream": "^1.5", + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/parallel": "^2.3", "composer-runtime-api": "^2", "composer/semver": "^1.4 || ^2.0 || ^3.0", "composer/xdebug-handler": "^2.0 || ^3.0", + "danog/advanced-json-rpc": "^3.1", "dnoegel/php-xdg-base-dir": "^0.1.1", "ext-ctype": "*", "ext-dom": "*", @@ -9472,27 +10673,26 @@ "ext-mbstring": "*", "ext-simplexml": "*", "ext-tokenizer": "*", - "felixfbecker/advanced-json-rpc": "^3.1", - "felixfbecker/language-server-protocol": "^1.5.2", + "felixfbecker/language-server-protocol": "^1.5.3", "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", - "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", - "nikic/php-parser": "^4.17", - "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", - "sebastian/diff": "^4.0 || ^5.0 || ^6.0", + "netresearch/jsonmapper": "^5.0", + "nikic/php-parser": "^5.0.0", + "php": "~8.1.31 || ~8.2.27 || ~8.3.16 || ~8.4.3", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0 || ^7.0", "spatie/array-to-xml": "^2.17.0 || ^3.0", - "symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" - }, - "conflict": { - "nikic/php-parser": "4.17.0" + "symfony/console": "^6.0 || ^7.0", + "symfony/filesystem": "~6.3.12 || ~6.4.3 || ^7.0.3", + "symfony/polyfill-php84": "^1.31.0" }, "provide": { "psalm/psalm": "self.version" }, "require-dev": { - "amphp/phpunit-util": "^2.0", + "amphp/phpunit-util": "^3", "bamarni/composer-bin-plugin": "^1.4", "brianium/paratest": "^6.9", + "danog/class-finder": "^0.4.8", + "dg/bypass-finals": "^1.5", "ext-curl": "*", "mockery/mockery": "^1.5", "nunomaduro/mock-final-classes": "^1.1", @@ -9500,10 +10700,10 @@ "phpstan/phpdoc-parser": "^1.6", "phpunit/phpunit": "^9.6", "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18", + "psalm/plugin-phpunit": "^0.19", "slevomat/coding-standard": "^8.4", "squizlabs/php_codesniffer": "^3.6", - "symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0" + "symfony/process": "^6.0 || ^7.0" }, "suggest": { "ext-curl": "In order to send data to shepherd", @@ -9514,6 +10714,7 @@ "psalm-language-server", "psalm-plugin", "psalm-refactor", + "psalm-review", "psalter" ], "type": "project", @@ -9523,7 +10724,9 @@ "dev-2.x": "2.x-dev", "dev-3.x": "3.x-dev", "dev-4.x": "4.x-dev", - "dev-master": "5.x-dev" + "dev-5.x": "5.x-dev", + "dev-6.x": "6.x-dev", + "dev-master": "7.x-dev" } }, "autoload": { @@ -9538,6 +10741,10 @@ "authors": [ { "name": "Matthew Brown" + }, + { + "name": "Daniil Gentili", + "email": "daniil@daniil.it" } ], "description": "A static analysis tool for finding errors in PHP applications", @@ -9552,7 +10759,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-09-08T18:53:08+00:00" + "time": "2025-05-05T18:23:39+00:00" } ], "aliases": [], diff --git a/tests/app/Builders/ArticleBuilder.php b/tests/App/Builders/ArticleBuilder.php similarity index 76% rename from tests/app/Builders/ArticleBuilder.php rename to tests/App/Builders/ArticleBuilder.php index e594a2c..6c692ad 100644 --- a/tests/app/Builders/ArticleBuilder.php +++ b/tests/App/Builders/ArticleBuilder.php @@ -1,10 +1,10 @@ + */ + public function definition(): array + { + return [ + 'uuid' => $this->faker->uuid(), + 'title' => $this->faker->text(50), + 'user_id' => User::factory(), + ]; + } +} diff --git a/tests/App/Factories/CommentFactory.php b/tests/App/Factories/CommentFactory.php new file mode 100644 index 0000000..1e025fe --- /dev/null +++ b/tests/App/Factories/CommentFactory.php @@ -0,0 +1,36 @@ + + */ + public function definition(): array + { + return [ + 'user_id' => User::factory(), + 'post_id' => Post::factory(), + 'text' => $this->faker->text(), + ]; + } +} diff --git a/tests/app/Factories/PostFactory.php b/tests/App/Factories/PostFactory.php similarity index 75% rename from tests/app/Factories/PostFactory.php rename to tests/App/Factories/PostFactory.php index 0365b57..1e331df 100644 --- a/tests/app/Factories/PostFactory.php +++ b/tests/App/Factories/PostFactory.php @@ -1,11 +1,11 @@ + */ + public function definition(): array + { + return [ + 'uuid' => $this->faker->uuid(), + 'title' => $this->faker->text(50), + 'content' => $this->faker->text(200), + ]; + } +} diff --git a/tests/app/Factories/UserFactory.php b/tests/App/Factories/UserFactory.php similarity index 73% rename from tests/app/Factories/UserFactory.php rename to tests/App/Factories/UserFactory.php index d378ec9..fbb1112 100644 --- a/tests/app/Factories/UserFactory.php +++ b/tests/App/Factories/UserFactory.php @@ -1,15 +1,24 @@ - */ - private string $model = MySqlUser::class; - - public function setModel(string $model): self - { - $this->model = $model; - - return $this; - } - public function makeCollection(int $count, array $attributes = []): UserCollection { - return $this->model::factory() + return User::factory() ->count($count) ->make($attributes); } public function makeOne(array $attributes = []): User { - return $this->model::factory()->make($attributes); + return User::factory()->make($attributes); } public function createOne(array $attributes = []): User { - return $this->model::factory()->create($attributes); + return User::factory()->create($attributes); } public function createOneAndDirty(array $creatingAttributes = [], array $dirtyAttributes = []): User { - $result = $this->model::factory()->create($creatingAttributes); + $result = User::factory()->create($creatingAttributes); $result->created_at = Carbon::now()->subYears(2); $result->updated_at = Carbon::now()->subYear(); @@ -75,7 +62,8 @@ public function createCollectionAndDirty( int $count, array $creatingAttributes = [], array $dirtyAttributes = [], - ): UserCollection { + ): UserCollection + { $result = new UserCollection(); for ($i = 0; $i < $count; ++$i) { diff --git a/tests/app/Models/Article.php b/tests/App/Models/Article.php similarity index 77% rename from tests/app/Models/Article.php rename to tests/App/Models/Article.php index 137b65a..b218140 100644 --- a/tests/app/Models/Article.php +++ b/tests/App/Models/Article.php @@ -1,14 +1,16 @@ belongsTo(User::class); + } + + public static function newFactory(): ArticleFactory + { + return new ArticleFactory(); + } } diff --git a/tests/app/Models/Comment.php b/tests/App/Models/Comment.php similarity index 71% rename from tests/app/Models/Comment.php rename to tests/App/Models/Comment.php index fe4e77d..45d603e 100644 --- a/tests/app/Models/Comment.php +++ b/tests/App/Models/Comment.php @@ -1,16 +1,17 @@ belongsTo(User::class, 'user_id'); + } - abstract public function post(): BelongsTo|PostBuilder; + public function post(): BelongsTo|PostBuilder + { + return $this->belongsTo(Post::class, 'post_id', 'id'); + } + + public static function newFactory(): CommentFactory + { + return new CommentFactory(); + } } diff --git a/tests/app/Models/Model.php b/tests/App/Models/Model.php similarity index 81% rename from tests/app/Models/Model.php rename to tests/App/Models/Model.php index 7eef027..1cea1ba 100644 --- a/tests/app/Models/Model.php +++ b/tests/App/Models/Model.php @@ -1,12 +1,14 @@ make(static::class)->getConnectionName() - ); + return DB::getSchemaBuilder(); } } diff --git a/tests/app/Models/Post.php b/tests/App/Models/Post.php similarity index 69% rename from tests/app/Models/Post.php rename to tests/App/Models/Post.php index 2dee64a..3c04052 100644 --- a/tests/app/Models/Post.php +++ b/tests/App/Models/Post.php @@ -1,16 +1,17 @@ hasMany(Comment::class, 'post_id', 'id'); + } + + public static function newFactory(): PostFactory + { + return new PostFactory(); + } } diff --git a/tests/app/Models/Story.php b/tests/App/Models/Story.php similarity index 82% rename from tests/app/Models/Story.php rename to tests/App/Models/Story.php index 7a49d88..c0edbdc 100644 --- a/tests/app/Models/Story.php +++ b/tests/App/Models/Story.php @@ -1,13 +1,14 @@ hasMany(Comment::class, 'user_id'); + } + + public function articles(): HasMany|ArticleBuilder + { + return $this->hasMany(Article::class, 'user_id'); + } + + protected static function newFactory(): UserFactory + { + return new UserFactory(); + } } diff --git a/tests/app/Observers/Observer.php b/tests/App/Observers/Observer.php similarity index 99% rename from tests/app/Observers/Observer.php rename to tests/App/Observers/Observer.php index 076c0d6..5195eae 100644 --- a/tests/app/Observers/Observer.php +++ b/tests/App/Observers/Observer.php @@ -1,6 +1,6 @@ load(); - $sqlitePath = self::getSqLitePath(); - - if (file_exists($sqlitePath)) { - unlink($sqlitePath); - } - - if (!is_dir(dirname($sqlitePath))) { - mkdir(dirname($sqlitePath), 0777, true); - } - - if (!touch($sqlitePath)) { - throw new RuntimeException('SQLite database was not created'); - } - self::configureManager(); - - // deleting tables - $modelPrefixes = ['MySql', 'PostgreSql', 'SqLite']; - - foreach ($modelPrefixes as $modelPrefix) { - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Comment', 'dropTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Post', 'dropTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Story', 'dropTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Article', 'dropTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'User', 'dropTable']); - } - - // creating tables - foreach ($modelPrefixes as $modelPrefix) { - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'User', 'createTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Post', 'createTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Comment', 'createTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Story', 'createTable']); - call_user_func(['Lapaliv\BulkUpsert\Tests\App\Models\\' . $modelPrefix . 'Article', 'createTable']); - } } /** @@ -83,141 +41,14 @@ protected function setUp(): void self::$manager->setAsGlobal(); self::$manager->bootEloquent(); - $this->app->bind('db', fn () => self::$manager->getDatabaseManager()); + $this->app->bind('db', fn() => self::$manager->getDatabaseManager()); $this->app->register(BulkUpsertServiceProvider::class); } - public function assertDatabaseMissing($table, array $data = [], $connection = null): void - { - $filters = []; - $jsons = []; - - foreach ($data as $key => $value) { - if (is_array($value)) { - $jsons[$key] = json_encode($value); - } else { - $filters[$key] = $value; - } - } - - parent::assertDatabaseMissing($table, $filters, $connection); - - if (empty($jsons)) { - return; - } - - foreach ($jsons as $key => $json) { - $hasRows = false; - DB::connection($connection) - ->table($table) - ->where($filters) - ->orderBy('id') - ->select('id', $key) - ->each( - function (stdClass $row) use ($json, $key, &$hasRows): bool { - if ($row->{$key} === $json) { - $hasRows = true; - } - - return !$hasRows; - } - ); - - if ($hasRows) { - $this->fail( - sprintf( - 'Failed asserting that a row in the table [%s] matches the attributes %s', - $table, - json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) - ) - ); - } - } - } - - protected function spyShouldHaveReceived(LegacyMockInterface|MockInterface $spy): VerificationDirector - { - return $spy->shouldHaveReceived('__invoke'); - } - - protected function spyShouldNotHaveReceived(LegacyMockInterface|MockInterface $spy): void - { - $spy->shouldNotHaveReceived('__invoke'); - } - - protected function assertDatabaseHas($table, array $data = [], $connection = null): void - { - $filters = []; - $jsons = []; - - foreach ($data as $key => $value) { - if (is_array($value)) { - $jsons[$key] = json_encode($value); - } else { - $filters[$key] = $value; - } - } - - parent::assertDatabaseHas($table, $filters, $connection); - - if (empty($jsons)) { - return; - } - - foreach ($jsons as $key => $json) { - $hasRows = false; - - DB::connection($connection) - ->table($table) - ->where($filters) - ->orderBy('id') - ->select('id', $key) - ->each( - function (stdClass $model) use (&$hasRows, $key, $json): bool { - if ($model->{$key} === $json) { - $hasRows = true; - - return false; - } - - return true; - } - ); - - if (!$hasRows) { - $this->fail( - sprintf( - 'Failed asserting that a row in the table [%s] matches the attributes %s', - $table, - json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) - ) - ); - } - } - } - - /** - * @template T - * - * @param string $id - * - * @psalm-param class-string $id - * - * @return mixed - * - * @psalm-return T - * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface - */ - protected function getFromContainer(string $id): mixed - { - return Container::getInstance()->get($id); - } - private static function configureManager(): void { $manager = new Manager(); + $manager->addConnection([ 'driver' => 'mysql', 'url' => env('MYSQL_URL'), @@ -257,17 +88,35 @@ private static function configureManager(): void 'driver' => 'sqlite', 'database' => self::getSqLitePath(), 'prefix' => '', - // 'foreign_key_constraints' => true, ], 'sqlite'); + $connection = env('DB_CONNECTION', 'mysql'); + self::$manager = $manager; self::$manager->setAsGlobal(); self::$manager->bootEloquent(); + self::$manager->getDatabaseManager()->setDefaultConnection($connection); + + if ($connection === 'sqlite') { + $sqlitePath = self::getSqLitePath(); + + if (file_exists($sqlitePath)) { + unlink($sqlitePath); + } + + if (!is_dir(dirname($sqlitePath))) { + mkdir(dirname($sqlitePath), 0777, true); + } + + if (!touch($sqlitePath)) { + throw new RuntimeException('SQLite database was not created'); + } + } } private static function getSqLitePath(): string { - return __DIR__ . '/database/database.sqlite'; + return __DIR__ . '/Database/database.sqlite'; } } diff --git a/tests/TestCaseWrapper.php b/tests/TestCaseWrapper.php new file mode 100644 index 0000000..f95e011 --- /dev/null +++ b/tests/TestCaseWrapper.php @@ -0,0 +1,171 @@ + $value) { + if (is_array($value)) { + $jsons[$key] = json_encode($value); + } else { + $filters[$key] = $value; + } + } + + parent::assertDatabaseMissing($table, $filters, $connection); + + if (empty($jsons)) { + return; + } + + foreach ($jsons as $key => $json) { + $hasRows = false; + DB::connection($connection) + ->table($table) + ->where($filters) + ->orderBy('id') + ->select('id', $key) + ->each( + function (stdClass $row) use ($json, $key, &$hasRows): bool { + if ($row->{$key} === $json) { + $hasRows = true; + } + + return !$hasRows; + } + ); + + if ($hasRows) { + $this->fail( + sprintf( + 'Failed asserting that a row in the table [%s] matches the attributes %s', + $table, + json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) + ) + ); + } + } + } + + protected static function spyShouldHaveReceived(LegacyMockInterface|MockInterface $spy): VerificationDirector + { + return $spy->shouldHaveReceived('__invoke'); + } + + protected static function spyShouldNotHaveReceived(LegacyMockInterface|MockInterface $spy): void + { + $spy->shouldNotHaveReceived('__invoke'); + } + + protected function assertDatabaseHas($table, array $data = [], $connection = null): void + { + $filters = []; + $jsons = []; + + foreach ($data as $key => $value) { + if (is_array($value)) { + $jsons[$key] = json_encode($value); + } else { + $filters[$key] = $value; + } + } + + parent::assertDatabaseHas($table, $filters, $connection); + + if (empty($jsons)) { + return; + } + + foreach ($jsons as $key => $json) { + $hasRows = false; + + DB::connection($connection) + ->table($table) + ->where($filters) + ->orderBy('id') + ->select('id', $key) + ->each( + function (stdClass $model) use (&$hasRows, $key, $json): bool { + if ($model->{$key} === $json) { + $hasRows = true; + + return false; + } + + return true; + } + ); + + if (!$hasRows) { + $this->fail( + sprintf( + 'Failed asserting that a row in the table [%s] matches the attributes %s', + $table, + json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) + ) + ); + } + } + } + + /** + * @template T + * + * @param string $id + * + * @psalm-param class-string $id + * + * @return mixed + * + * @psalm-return T + * + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + protected function getFromContainer(string $id): mixed + { + return Container::getInstance()->get($id); + } +} diff --git a/tests/Unit/ArticleTestTrait.php b/tests/Unit/ArticleTestTrait.php deleted file mode 100644 index 4f984f3..0000000 --- a/tests/Unit/ArticleTestTrait.php +++ /dev/null @@ -1,47 +0,0 @@ - [MySqlArticle::class], - 'psql' => [PostgreSqlArticle::class], - 'sqlite' => [SqLiteArticle::class], - ]; - } - - protected function makeArticleCollection(string $model, int $count, array $data = []): ArticleCollection - { - return call_user_func([$model, 'factory'])->count($count)->make($data); - } - - protected function createArticleCollection(string $model, int $count, array $data = []): ArticleCollection - { - return call_user_func([$model, 'factory'])->count($count)->create($data); - } - - protected function createDirtyArticleCollection(string $model, int $count, array $data = []): ArticleCollection - { - $users = $this->createArticleCollection($model, $count); - $result = $this->makeArticleCollection($model, $count, $data); - - foreach ($result as $key => $user) { - $user->email = $users->get($key)->email; - } - - return $result; - } -} diff --git a/tests/Unit/Bulk/Create/CreateAndReturnTest.php b/tests/Unit/Bulk/Create/CreateAndReturnTest.php index 1cbf481..6c29809 100644 --- a/tests/Unit/Bulk/Create/CreateAndReturnTest.php +++ b/tests/Unit/Bulk/Create/CreateAndReturnTest.php @@ -1,47 +1,33 @@ $model - * * @return void * - * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDatabase(string $model): void + public function testDatabase(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -69,19 +55,15 @@ public function testDatabase(string $model): void } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testResult(string $model): void + public function testResult(): void { // arrange $users = $this->userGenerator->makeCollection(2); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -107,15 +89,11 @@ public function testResult(string $model): void } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testSelectColumns(string $model): void + public function testSelectColumns(): void { // arrange $users = [ @@ -128,7 +106,7 @@ public function testSelectColumns(string $model): void ['email', 'name', 'gender', 'posts_count', 'is_admin'] ), ]; - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -151,21 +129,17 @@ public function testSelectColumns(string $model): void } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider storyModelsDataProvider */ - public function testWithoutIncrementing(string $model): void + public function testWithoutIncrementing(): void { // arrange - $stories = $model::factory() + $stories = Story::factory() ->count(10) ->make(); - $sut = $model::query() + $sut = Story::query() ->bulk() ->uniqueBy(['uuid']); @@ -187,22 +161,4 @@ function (Story $story) use ($result): void { } ); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } - - public function storyModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlStory::class], - 'pgsql' => [PostgreSqlStory::class], - 'sqlite' => [SqLiteStory::class], - ]; - } } diff --git a/tests/Unit/Bulk/Create/CreateAndTouchTest.php b/tests/Unit/Bulk/Create/CreateAndTouchTest.php index ff29604..af75cb3 100644 --- a/tests/Unit/Bulk/Create/CreateAndTouchTest.php +++ b/tests/Unit/Bulk/Create/CreateAndTouchTest.php @@ -1,67 +1,52 @@ $userModel - * @param class-string $postModel - * @param class-string $commentModel - * * @return void * * @throws BulkException - * - * @dataProvider modelsDataProvider */ - public function test(string $userModel, string $postModel, string $commentModel): void + public function test(): void { // arrange $now = Carbon::now(); Carbon::setTestNow(Carbon::now()->subYear()); - $posts = $postModel::factory()->count(2)->create(); - $users = $userModel::factory()->count(2)->create(); + $posts = Post::factory()->count(2)->create(); + $users = User::factory()->count(2)->create(); $comments = new CommentCollection([ - $commentModel::factory()->make([ + Comment::factory()->make([ 'post_id' => $posts->get(0)->id, 'user_id' => $users->get(0)->id, ]), - $commentModel::factory()->make([ + Comment::factory()->make([ 'post_id' => $posts->get(1)->id, 'user_id' => $users->get(1)->id, ]), ]); - $sut = $commentModel::query() + $sut = Comment::query() ->bulk() ->uniqueBy(['post_id', 'user_id']); Carbon::setTestNow($now); - $commentModel::setGlobalTouchedRelations(['user', 'post']); - $postModel::setGlobalTouchedRelations([]); + Comment::setGlobalTouchedRelations(['user', 'post']); + Post::setGlobalTouchedRelations([]); // act $sut->create($comments); @@ -82,25 +67,4 @@ public function test(string $userModel, string $postModel, string $commentModel) ], $user->getConnectionName()); } } - - public function modelsDataProvider(): array - { - return [ - 'mysql' => [ - MySqlUser::class, - MySqlPost::class, - MySqlComment::class, - ], - 'pgsql' => [ - PostgreSqlUser::class, - PostgreSqlPost::class, - PostgreSqlComment::class, - ], - 'sqlite' => [ - SqLiteUser::class, - SqLitePost::class, - SqLiteComment::class, - ], - ]; - } } diff --git a/tests/Unit/Bulk/Create/CreateBeforeWritingEventDependenciesTest.php b/tests/Unit/Bulk/Create/CreateBeforeWritingEventDependenciesTest.php index 9735a2c..5a651e1 100644 --- a/tests/Unit/Bulk/Create/CreateBeforeWritingEventDependenciesTest.php +++ b/tests/Unit/Bulk/Create/CreateBeforeWritingEventDependenciesTest.php @@ -1,6 +1,6 @@ $model * @param Closure $data * @param string $event * @param array $dependencies @@ -43,11 +39,11 @@ final class CreateBeforeWritingEventDependenciesTest extends TestCase * * @dataProvider modelDataProvider */ - public function testModelEventReturnsFalseSometimes(string $model, Closure $data, string $event, array $dependencies): void + public function testModelEventReturnsFalseSometimes(Closure $data, string $event, array $dependencies): void { // arrange $users = $data(); - $model::observe(Observer::class); + User::observe(Observer::class); /** @var array $spies */ $spies = [ $event => Mockery::mock(TestCallback::class), @@ -65,7 +61,7 @@ public function testModelEventReturnsFalseSometimes(string $model, Closure $data } } - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -74,7 +70,7 @@ public function testModelEventReturnsFalseSometimes(string $model, Closure $data // assert foreach ($dependencies['model'] as $dependency) { - $this->spyShouldHaveReceived($spies[$dependency]) + self::spyShouldHaveReceived($spies[$dependency]) ->once() ->withArgs( static function (User $user) use ($users): bool { @@ -84,7 +80,7 @@ static function (User $user) use ($users): bool { } foreach ($dependencies['collection'] as $dependency) { - $this->spyShouldHaveReceived($spies[$dependency]) + self::spyShouldHaveReceived($spies[$dependency]) ->once() ->withArgs( static function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { @@ -101,7 +97,6 @@ static function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): /** * If one of model events always returns false then its dependencies have not been called. * - * @param class-string $model * @param Closure $data * @param string $event * @param array $dependencies @@ -112,11 +107,11 @@ static function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): * * @dataProvider modelDataProvider */ - public function testModelEventReturnsFalseAlways(string $model, Closure $data, string $event, array $dependencies): void + public function testModelEventReturnsFalseAlways(Closure $data, string $event, array $dependencies): void { // arrange $users = $data(); - $model::observe(Observer::class); + User::observe(Observer::class); /** @var array $spies */ $spies = [ $event => Mockery::mock(TestCallback::class), @@ -134,7 +129,7 @@ public function testModelEventReturnsFalseAlways(string $model, Closure $data, s } } - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -143,18 +138,17 @@ public function testModelEventReturnsFalseAlways(string $model, Closure $data, s // assert foreach ($dependencies['model'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } foreach ($dependencies['collection'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } } /** * When one of collection events returns false then its dependencies have not been called. * - * @param class-string $model * @param Closure $data * @param string $event * @param array $dependencies @@ -165,11 +159,11 @@ public function testModelEventReturnsFalseAlways(string $model, Closure $data, s * * @dataProvider collectionDataProvider */ - public function testCollectionEventReturnsFalse(string $model, Closure $data, string $event, array $dependencies): void + public function testCollectionEventReturnsFalse(Closure $data, string $event, array $dependencies): void { // arrange $users = $data(); - $model::observe(Observer::class); + User::observe(Observer::class); /** @var array $spies */ $spies = [ $event => Mockery::mock(TestCallback::class), @@ -187,7 +181,7 @@ public function testCollectionEventReturnsFalse(string $model, Closure $data, st } } - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -196,17 +190,17 @@ public function testCollectionEventReturnsFalse(string $model, Closure $data, st // assert foreach ($dependencies['model'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } foreach ($dependencies['collection'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } } - public function modelDataProvider(): array + public static function modelDataProvider(): array { - $target = [ + return [ 'saving' => [ function () { return App::make(UserGenerator::class) @@ -304,29 +298,11 @@ function () { ], ], ]; - - $result = []; - $models = [ - 'mysql' => MySqlUser::class, - 'pgsql' => PostgreSqlUser::class, - 'sqlite' => SqLiteUser::class, - ]; - - foreach ($target as $key => $value) { - foreach ($models as $type => $model) { - $result[$key . '&& ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; } - public function collectionDataProvider(): array + public static function collectionDataProvider(): array { - $target = [ + return [ 'saving many' => [ function () { $firstUser = App::make(UserGenerator::class)->makeOne(); @@ -399,23 +375,5 @@ function () { ], ], ]; - - $result = []; - $models = [ - 'mysql' => MySqlUser::class, - 'pgsql' => PostgreSqlUser::class, - 'sqlite' => SqLiteUser::class, - ]; - - foreach ($target as $key => $value) { - foreach ($models as $type => $model) { - $result[$key . '&& ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; } } diff --git a/tests/Unit/Bulk/Create/CreateBuilderCallbacksTest.php b/tests/Unit/Bulk/Create/CreateBuilderCallbacksTest.php index e869241..d739f89 100644 --- a/tests/Unit/Bulk/Create/CreateBuilderCallbacksTest.php +++ b/tests/Unit/Bulk/Create/CreateBuilderCallbacksTest.php @@ -1,6 +1,6 @@ $model * @param string $method * @param Closure $callback * @@ -37,12 +33,12 @@ final class CreateBuilderCallbacksTest extends TestCase * * @throws BulkException */ - public function testModel(string $model, string $method, Closure $callback): void + public function testModel(string $method, Closure $callback): void { // arrange $users = $callback(); $spy = Mockery::spy(TestCallback::class, $method); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); $sut->{$method}($spy); @@ -51,7 +47,7 @@ public function testModel(string $model, string $method, Closure $callback): voi $sut->create($users); // arrange - $this->spyShouldHaveReceived($spy) + self::spyShouldHaveReceived($spy) ->once() ->withArgs( function (User $user) use ($users): bool { @@ -61,7 +57,6 @@ function (User $user) use ($users): bool { } /** - * @param class-string $model * @param string $method * @param Closure $callback * @@ -71,13 +66,13 @@ function (User $user) use ($users): bool { * * @throws BulkException */ - public function testCollection(string $model, string $method, Closure $callback): void + public function testCollection(string $method, Closure $callback): void { // arrange /** @var UserCollection $users */ $users = $callback(); $spy = Mockery::spy(TestCallback::class, $method); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); $sut->{$method . 'Many'}($spy); @@ -86,7 +81,7 @@ public function testCollection(string $model, string $method, Closure $callback) $sut->create($users); // arrange - $this->spyShouldHaveReceived($spy) + self::spyShouldHaveReceived($spy) ->once() ->withArgs( function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { @@ -100,16 +95,14 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testCallUndefinedListener(string $model): void + public function testCallUndefinedListener(): void { // arrange - $sut = $model::query()->bulk(); + $sut = User::query()->bulk(); // assert $this->expectException(BadMethodCallException::class); @@ -118,9 +111,9 @@ public function testCallUndefinedListener(string $model): void $sut->onFake(); } - public function dataProvider(): array + public static function dataProvider(): array { - $target = [ + return [ 'onCreating' => [ 'onCreating', function () { @@ -164,27 +157,5 @@ function () { }, ], ]; - - $result = []; - - foreach ($target as $key => $value) { - foreach ($this->userModelsDataProvider() as $type => $model) { - $result[$key . '&& ' . $type] = [ - $model[0], - ...$value, - ]; - } - } - - return $result; - } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; } } diff --git a/tests/Unit/Bulk/Create/CreateDifferentUniqueByTest.php b/tests/Unit/Bulk/Create/CreateDifferentUniqueByTest.php index 80735e4..7fc7ce1 100644 --- a/tests/Unit/Bulk/Create/CreateDifferentUniqueByTest.php +++ b/tests/Unit/Bulk/Create/CreateDifferentUniqueByTest.php @@ -1,36 +1,27 @@ $model - * * @return void * - * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function test(string $model): void + public function test(): void { // arrange $userWithEmail = Arr::except( @@ -42,10 +33,9 @@ public function test(string $model): void ['email'] ); $connectionName = $this->userGenerator - ->setModel($model) ->makeOne() ->getConnectionName(); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy('email') ->orUniqueBy('avatar'); @@ -54,7 +44,7 @@ public function test(string $model): void $sut->create([$userWithEmail, $userWithAvatar]); // assert - $this->assertDatabaseHas($model::table(), [ + $this->assertDatabaseHas(User::table(), [ 'name' => $userWithAvatar['name'], 'gender' => $userWithAvatar['gender']->value, 'avatar' => $userWithAvatar['avatar'], @@ -69,7 +59,7 @@ public function test(string $model): void 'deleted_at' => null, ], $connectionName); - $this->assertDatabaseHas($model::table(), [ + $this->assertDatabaseHas(User::table(), [ 'email' => $userWithEmail['email'], 'name' => $userWithEmail['name'], 'gender' => $userWithEmail['gender']->value, @@ -84,13 +74,4 @@ public function test(string $model): void 'deleted_at' => null, ], $connectionName); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/Create/CreateEventsTest.php b/tests/Unit/Bulk/Create/CreateEventsTest.php index f8cb0dd..2d6a406 100644 --- a/tests/Unit/Bulk/Create/CreateEventsTest.php +++ b/tests/Unit/Bulk/Create/CreateEventsTest.php @@ -1,61 +1,51 @@ $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testDisableAllEvents(string $model): void + public function testDisableAllEvents(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->disableEvents() ->uniqueBy(['email']); $spy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($spy); // act $sut->create($users); // assert - $this->spyShouldNotHaveReceived($spy); + self::spyShouldNotHaveReceived($spy); } /** - * @param class-string $model * @param string $disabledEvent * * @return void @@ -64,13 +54,11 @@ public function testDisableAllEvents(string $model): void * * @dataProvider eventsDataProvider */ - public function testDisableSomeEvents(string $model, string $disabledEvent): void + public function testDisableSomeEvents(string $disabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->disableEvents([$disabledEvent]) ->uniqueBy(['email']); @@ -78,7 +66,7 @@ public function testDisableSomeEvents(string $model, string $disabledEvent): voi $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); Observer::listen($disabledEvent, $notCallingSpy); @@ -86,29 +74,23 @@ public function testDisableSomeEvents(string $model, string $disabledEvent): voi $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy) + self::spyShouldHaveReceived($callingSpy) ->atLeast() ->once(); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDisableModelEndEvents(string $model): void + public function testDisableModelEndEvents(): void { // arrange $modelEndEvents = BulkEventEnum::modelEnd(); - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->disableModelEndEvents() ->uniqueBy(['email']); @@ -116,7 +98,7 @@ public function testDisableModelEndEvents(string $model): void $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); foreach ($modelEndEvents as $event) { @@ -127,14 +109,13 @@ public function testDisableModelEndEvents(string $model): void $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy) + self::spyShouldHaveReceived($callingSpy) ->atLeast() ->once(); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model * @param string $disabledEvent * * @return void @@ -143,13 +124,11 @@ public function testDisableModelEndEvents(string $model): void * * @dataProvider eventsDataProvider */ - public function testDisableOneEvent(string $model, string $disabledEvent): void + public static function testDisableOneEvent(string $disabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = User::factory()->count(2)->make(); + $sut = User::query() ->bulk() ->disableEvent($disabledEvent) ->uniqueBy(['email']); @@ -157,7 +136,7 @@ public function testDisableOneEvent(string $model, string $disabledEvent): void $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); Observer::listen($disabledEvent, $notCallingSpy); @@ -165,37 +144,32 @@ public function testDisableOneEvent(string $model, string $disabledEvent): void $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy) + self::spyShouldHaveReceived($callingSpy) ->atLeast() ->once(); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testEnableAllEvents(string $model): void + public function testEnableAllEvents(): void { // arrange $users = $this->userGenerator - ->setModel($model) ->makeCollection(1, [ 'deleted_at' => Carbon::now(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->enableEvents() ->uniqueBy(['email']); $callingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); // 4 for saving @@ -207,13 +181,12 @@ public function testEnableAllEvents(string $model): void $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy)->times( + self::spyShouldHaveReceived($callingSpy)->times( $countEventsPerModel * $users->count() ); } /** - * @param class-string $model * @param string $enabledEvent * * @return void @@ -222,13 +195,11 @@ public function testEnableAllEvents(string $model): void * * @dataProvider eventsDataProvider */ - public function testEnableSomeDisabledEvents(string $model, string $enabledEvent): void + public function testEnableSomeDisabledEvents(string $enabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->enableEvents() ->disableEvents([$enabledEvent]) @@ -237,18 +208,17 @@ public function testEnableSomeDisabledEvents(string $model, string $enabledEvent $callingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listen($enabledEvent, $callingSpy); // act $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy); + self::spyShouldHaveReceived($callingSpy); } /** - * @param class-string $model * @param string $enabledEvent * * @return void @@ -257,13 +227,11 @@ public function testEnableSomeDisabledEvents(string $model, string $enabledEvent * * @dataProvider eventsDataProvider */ - public function testEnableSomeEvents(string $model, string $enabledEvent): void + public function testEnableSomeEvents(string $enabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->disableEvents() ->enableEvents([$enabledEvent]) @@ -272,7 +240,7 @@ public function testEnableSomeEvents(string $model, string $enabledEvent): void $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($notCallingSpy, [$enabledEvent]); Observer::listen($enabledEvent, $callingSpy); @@ -280,12 +248,11 @@ public function testEnableSomeEvents(string $model, string $enabledEvent): void $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldHaveReceived($callingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model * @param string $enabledEvent * * @return void @@ -294,13 +261,11 @@ public function testEnableSomeEvents(string $model, string $enabledEvent): void * * @dataProvider eventsDataProvider */ - public function testEnableOneEvent(string $model, string $enabledEvent): void + public function testEnableOneEvent(string $enabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->disableEvents() ->enableEvent($enabledEvent) @@ -309,7 +274,7 @@ public function testEnableOneEvent(string $model, string $enabledEvent): void $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($notCallingSpy, [$enabledEvent]); Observer::listen($enabledEvent, $callingSpy); @@ -317,34 +282,18 @@ public function testEnableOneEvent(string $model, string $enabledEvent): void $sut->create($users); // assert - $this->spyShouldHaveReceived($callingSpy); - $this->spyShouldNotHaveReceived($notCallingSpy); - } - - public function eventsDataProvider(): array - { - $targetEvents = [ - ...BulkEventEnum::save(), - ...BulkEventEnum::create(), - ]; - - $result = []; - - foreach ($this->userModelsDataProvider() as $key => [$model]) { - foreach ($targetEvents as $targetEvent) { - $result[$targetEvent . ' && ' . $key] = [$model, $targetEvent]; - } - } - - return $result; + self::spyShouldHaveReceived($callingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } - public function userModelsDataProvider(): array + public static function eventsDataProvider(): array { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; + return array_map( + static fn(string $event) => [$event], + [ + ...BulkEventEnum::save(), + ...BulkEventEnum::create(), + ] + ); } } diff --git a/tests/Unit/Bulk/Create/CreateOrAccumulateTest.php b/tests/Unit/Bulk/Create/CreateOrAccumulateTest.php index 900cfbe..ec5cc30 100644 --- a/tests/Unit/Bulk/Create/CreateOrAccumulateTest.php +++ b/tests/Unit/Bulk/Create/CreateOrAccumulateTest.php @@ -1,40 +1,31 @@ $model - * * @return void * * @throws BulkException - * @throws JsonException - * - * @dataProvider userModelsDataProvider */ - public function testBigChunkSize(string $model): void + public function testBigChunkSize(): void { // arrange $users = $this->userGenerator->makeCollection(2); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->chunk(100); @@ -51,21 +42,15 @@ public function testBigChunkSize(string $model): void } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testSmallChunkSize(string $model): void + public function testSmallChunkSize(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->chunk($users->count()); @@ -80,21 +65,15 @@ public function testSmallChunkSize(string $model): void } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testSmallChunkSizeWithExtraCount(string $model): void + public function testSmallChunkSizeWithExtraCount(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(5); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(5); + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->chunk($users->count() - 1); @@ -110,21 +89,15 @@ public function testSmallChunkSizeWithExtraCount(string $model): void } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testSaveAccumulation(string $model): void + public function testSaveAccumulation(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->createOrAccumulate($users); @@ -134,25 +107,21 @@ public function testSaveAccumulation(string $model): void // assert $users->each( - fn (User $user) => $this->userWasCreated($user) + fn(User $user) => $this->userWasCreated($user) ); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testCreatingWithoutUniqueAttributesWithEvents(string $model): void + public function testCreatingWithoutUniqueAttributesWithEvents(): void { // arrange $users = $this->userGenerator->makeCollection(2); - $model::observe(Observer::class); - $sut = $model::query()->bulk(); + User::observe(Observer::class); + $sut = User::query()->bulk(); // assert $this->expectException(BulkIdentifierDidNotFind::class); @@ -162,21 +131,15 @@ public function testCreatingWithoutUniqueAttributesWithEvents(string $model): vo } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testCreatingWithoutUniqueAttributesWithoutEvents(string $model): void + public function testCreatingWithoutUniqueAttributesWithoutEvents(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->chunk(2); @@ -185,16 +148,7 @@ public function testCreatingWithoutUniqueAttributesWithoutEvents(string $model): // assert $users->each( - fn (User $user) => $this->userWasCreated($user) + fn(User $user) => $this->userWasCreated($user) ); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/Create/CreateTest.php b/tests/Unit/Bulk/Create/CreateTest.php index 007d87c..44095d5 100644 --- a/tests/Unit/Bulk/Create/CreateTest.php +++ b/tests/Unit/Bulk/Create/CreateTest.php @@ -1,44 +1,33 @@ $model - * * @return void * - * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testBase(string $model): void + public function testBase(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query() + $users = $this->userGenerator->makeCollection(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -66,16 +55,12 @@ public function testBase(string $model): void } /** - * @param class-string $model - * * @return void * - * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider + * @throws RandomException */ - public function testWithTimestamps(string $model): void + public function testWithTimestamps(): void { // arrange $expectedCreatedAt = Carbon::now()->subSeconds( @@ -85,7 +70,6 @@ public function testWithTimestamps(string $model): void random_int(100, 100_000) ); $users = $this->userGenerator - ->setModel($model) ->makeCollection(2) ->each( function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { @@ -93,7 +77,7 @@ function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { $user->setUpdatedAt($expectedUpdatedAt); } ); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -112,46 +96,34 @@ function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testStdRow(string $model): void + public function testStdRow(): void { // arrange - $user = $this->userGenerator - ->setModel($model) - ->makeOne(); - $sut = $model::query() + $user = $this->userGenerator->makeOne(); + $sut = User::query() ->bulk() ->uniqueBy(['email']); // act - $sut->create([(object) $user->toArray()]); + $sut->create([(object)$user->toArray()]); // assert $this->userWasCreated($user); } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testObjectRowWithMethodToArray(string $model): void + public function testObjectRowWithMethodToArray(): void { // arrange - $user = $this->userGenerator - ->setModel($model) - ->makeOne(); + $user = $this->userGenerator->makeOne(); $userAsArray = $user->toArray(); $userAsArray['gender'] = $user->gender->value; $className = 'SomeClass' . Str::random(); @@ -162,7 +134,7 @@ public function toArray(): array { } } "); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -174,20 +146,16 @@ public function toArray(): array { } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testCreatingWithoutUniqueAttributesWithEvents(string $model): void + public function testCreatingWithoutUniqueAttributesWithEvents(): void { // arrange $users = $this->userGenerator->makeCollection(2); - $model::observe(Observer::class); - $sut = $model::query()->bulk(); + User::observe(Observer::class); + $sut = User::query()->bulk(); // assert $this->expectException(BulkIdentifierDidNotFind::class); @@ -197,37 +165,22 @@ public function testCreatingWithoutUniqueAttributesWithEvents(string $model): vo } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testCreatingWithoutUniqueAttributesWithoutEvents(string $model): void + public function testCreatingWithoutUniqueAttributesWithoutEvents(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->makeCollection(2); - $sut = $model::query()->bulk(); + $users = $this->userGenerator->makeCollection(2); + $sut = User::query()->bulk(); // act $sut->create($users); // assert $users->each( - fn (User $user) => $this->userWasCreated($user) + fn(User $user) => $this->userWasCreated($user) ); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/Delete/DatabaseTest.php b/tests/Unit/Bulk/Delete/DatabaseTest.php index 30eadae..9df2de7 100644 --- a/tests/Unit/Bulk/Delete/DatabaseTest.php +++ b/tests/Unit/Bulk/Delete/DatabaseTest.php @@ -1,46 +1,34 @@ $model - * * @return void * * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDeleteWithSoftDeleting(string $model): void + public function testDeleteWithSoftDeleting(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query() + $users = $this->userGenerator->createCollection(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -68,22 +56,16 @@ public function testDeleteWithSoftDeleting(string $model): void } /** - * @param class-string $model - * * @return void * * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testForceDeleteWithSoftDeleting(string $model): void + public function testForceDeleteWithSoftDeleting(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query() + $users = $this->userGenerator->createCollection(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -111,7 +93,6 @@ public function testForceDeleteWithSoftDeleting(string $model): void } /** - * @param class-string $model * @param string $method * * @return void @@ -122,11 +103,11 @@ public function testForceDeleteWithSoftDeleting(string $model): void * * @dataProvider postModelsDataProvider */ - public function testDeleteWithoutSoftDeleting(string $model, string $method): void + public function testDeleteWithoutSoftDeleting(string $method): void { // arrange - $posts = $model::factory()->count(2)->create(); - $sut = $model::query()->bulk(); + $posts = Post::factory()->count(2)->create(); + $sut = Post::query()->bulk(); // act $sut->{$method}($posts); @@ -139,42 +120,11 @@ public function testDeleteWithoutSoftDeleting(string $model, string $method): vo } } - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqliteUser::class], - ]; - } - - public function postModelsDataProvider(): array + public static function postModelsDataProvider(): array { return [ - 'mysql, delete' => [ - MySqlPost::class, - 'delete', - ], - 'mysql, forceDelete' => [ - MySqlPost::class, - 'forceDelete', - ], - 'pgsql, delete' => [ - PostgreSqlPost::class, - 'delete', - ], - 'pgsql, forceDelete' => [ - PostgreSqlPost::class, - 'forceDelete', - ], - 'sqlite, delete' => [ - SqlitePost::class, - 'delete', - ], - 'sqlite, forceDelete' => [ - SqlitePost::class, - 'forceDelete', - ], + 'delete' => ['delete'], + 'forceDelete' => ['forceDelete'], ]; } } diff --git a/tests/Unit/Bulk/Delete/DeleteAccumulatedTest.php b/tests/Unit/Bulk/Delete/DeleteAccumulatedTest.php index 19385e2..603690a 100644 --- a/tests/Unit/Bulk/Delete/DeleteAccumulatedTest.php +++ b/tests/Unit/Bulk/Delete/DeleteAccumulatedTest.php @@ -1,43 +1,31 @@ $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testDeleteAccumulatedWithSoftDeleting(string $model): void + public function testDeleteAccumulatedWithSoftDeleting(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query() + $users = $this->userGenerator->createCollection(2); + $sut = User::query() ->bulk() ->deleteOrAccumulate($users); @@ -46,26 +34,20 @@ public function testDeleteAccumulatedWithSoftDeleting(string $model): void // assert $users->each( - fn (User $user) => $this->userWasSoftDeleted($user) + fn(User $user) => $this->userWasSoftDeleted($user) ); } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testForceDeleteAccumulatedWithSoftDeleting(string $model): void + public function testForceDeleteAccumulatedWithSoftDeleting(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query() + $users = $this->userGenerator->createCollection(2); + $sut = User::query() ->bulk() ->forceDeleteOrAccumulate($users); @@ -74,12 +56,11 @@ public function testForceDeleteAccumulatedWithSoftDeleting(string $model): void // assert $users->each( - fn (User $user) => $this->userDoesNotExist($user) + fn(User $user) => $this->userDoesNotExist($user) ); } /** - * @param class-string $model * @param string $accumulateMethod * @param string $deleteMethod * @@ -90,16 +71,13 @@ public function testForceDeleteAccumulatedWithSoftDeleting(string $model): void * * @dataProvider postModelsDataProvider */ - public function testDeleteAccumulatedWithoutSoftDeleting( - string $model, - string $accumulateMethod, - string $deleteMethod, - ): void { + public function testDeleteAccumulatedWithoutSoftDeleting(string $accumulateMethod, string $deleteMethod): void + { // arrange - $posts = $model::factory() + $posts = Post::factory() ->count(2) ->create(); - $sut = $model::query() + $sut = Post::query() ->bulk() ->{$accumulateMethod}($posts); @@ -108,36 +86,20 @@ public function testDeleteAccumulatedWithoutSoftDeleting( // assert $posts->each( - fn (Post $post) => $this->assertDatabaseMissing($post->getTable(), [ + fn(Post $post) => $this->assertDatabaseMissing($post->getTable(), [ 'id' => $post->id, ], $post->getConnectionName()) ); } - public function userModelsDataProvider(): array + public static function postModelsDataProvider(): array { return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } - - public function postModelsDataProvider(): array - { - return [ - 'mysql' => [ - MySqlPost::class, + 'not force' => [ 'deleteOrAccumulate', 'deleteAccumulated', ], - 'pgsql' => [ - PostgreSqlPost::class, - 'forceDeleteOrAccumulate', - 'forceDeleteAccumulated', - ], - 'sqlite' => [ - SqLitePost::class, + 'force' => [ 'forceDeleteOrAccumulate', 'forceDeleteAccumulated', ], diff --git a/tests/Unit/Bulk/Delete/DeleteOrAccumulateTest.php b/tests/Unit/Bulk/Delete/DeleteOrAccumulateTest.php index 53350aa..344c847 100644 --- a/tests/Unit/Bulk/Delete/DeleteOrAccumulateTest.php +++ b/tests/Unit/Bulk/Delete/DeleteOrAccumulateTest.php @@ -1,95 +1,71 @@ $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDeleteWithSoftDeletingSmallChunk(string $model): void + public function testDeleteWithSoftDeletingSmallChunk(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query()->bulk(); + $users = $this->userGenerator->createCollection(2); + $sut = User::query()->bulk(); // act $sut->deleteOrAccumulate($users); // assert $users->each( - fn (User $user) => $this->userExists($user) + fn(User $user) => $this->userExists($user) ); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testForceDeleteWithSoftDeletingSmallChunk(string $model): void + public function testForceDeleteWithSoftDeletingSmallChunk(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query()->bulk(); + $users = $this->userGenerator->createCollection(2); + $sut = User::query()->bulk(); // act $sut->forceDeleteOrAccumulate($users); // assert $users->each( - fn (User $user) => $this->userExists($user) + fn(User $user) => $this->userExists($user) ); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDeleteWithSoftDeletingBigChunk(string $model): void + public function testDeleteWithSoftDeletingBigChunk(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query() + $users = $this->userGenerator->createCollection(2); + $sut = User::query() ->bulk() ->chunk($users->count()); @@ -98,26 +74,20 @@ public function testDeleteWithSoftDeletingBigChunk(string $model): void // assert $users->each( - fn (User $user) => $this->userWasSoftDeleted($user) + fn(User $user) => $this->userWasSoftDeleted($user) ); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testForceDeleteWithSoftDeletingBigChunk(string $model): void + public function testForceDeleteWithSoftDeletingBigChunk(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query() + $users = $this->userGenerator->createCollection(2); + $sut = User::query() ->bulk() ->chunk($users->count()); @@ -126,12 +96,11 @@ public function testForceDeleteWithSoftDeletingBigChunk(string $model): void // assert $users->each( - fn (User $user) => $this->userDoesNotExist($user) + fn(User $user) => $this->userDoesNotExist($user) ); } /** - * @param class-string $model * @param string $method * * @return void @@ -141,25 +110,24 @@ public function testForceDeleteWithSoftDeletingBigChunk(string $model): void * * @dataProvider postModelsDataProvider */ - public function testDeleteWithoutSoftDeletingSmallChunk(string $model, string $method): void + public function testDeleteWithoutSoftDeletingSmallChunk(string $method): void { // arrange - $posts = $model::factory()->count(2)->create(); - $sut = $model::query()->bulk(); + $posts = Post::factory()->count(2)->create(); + $sut = Post::query()->bulk(); // act $sut->{$method}($posts); // assert $posts->each( - fn (Post $post) => $this->assertDatabaseHas($post->getTable(), [ + fn(Post $post) => $this->assertDatabaseHas($post->getTable(), [ 'id' => $post->id, ], $post->getConnectionName()) ); } /** - * @param class-string $model * @param string $method * * @return void @@ -168,11 +136,11 @@ public function testDeleteWithoutSoftDeletingSmallChunk(string $model, string $m * * @dataProvider postModelsDataProvider */ - public function testDeleteWithoutSoftDeletingBigChunk(string $model, string $method): void + public function testDeleteWithoutSoftDeletingBigChunk(string $method): void { // arrange - $posts = $model::factory()->count(2)->create(); - $sut = $model::query() + $posts = Post::factory()->count(2)->create(); + $sut = Post::query() ->bulk() ->chunk($posts->count()); @@ -181,46 +149,19 @@ public function testDeleteWithoutSoftDeletingBigChunk(string $model, string $met // assert $posts->each( - fn (Post $post) => $this->assertDatabaseMissing($post->getTable(), [ + fn(Post $post) => $this->assertDatabaseMissing($post->getTable(), [ 'id' => $post->id, ], $post->getConnectionName()) ); } - public function userModelsDataProvider(): array + public static function postModelsDataProvider(): array { return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } - - public function postModelsDataProvider(): array - { - return [ - 'mysql, deleteOrAccumulate' => [ - MySqlPost::class, - 'deleteOrAccumulate', - ], - 'mysql, forceDeleteOrAccumulate' => [ - MySqlPost::class, - 'forceDeleteOrAccumulate', - ], - 'pgsql, deleteOrAccumulate' => [ - PostgreSqlPost::class, - 'deleteOrAccumulate', - ], - 'pgsql, forceDeleteOrAccumulate' => [ - PostgreSqlPost::class, - 'forceDeleteOrAccumulate', - ], - 'sqlite, deleteOrAccumulate' => [ - SqLitePost::class, + 'deleteOrAccumulate' => [ 'deleteOrAccumulate', ], - 'sqlite, forceDeleteOrAccumulate' => [ - SqLitePost::class, + 'forceDeleteOrAccumulate' => [ 'forceDeleteOrAccumulate', ], ]; diff --git a/tests/Unit/Bulk/Delete/FireEventsTest.php b/tests/Unit/Bulk/Delete/FireEventsTest.php index 3814f22..b5caab4 100644 --- a/tests/Unit/Bulk/Delete/FireEventsTest.php +++ b/tests/Unit/Bulk/Delete/FireEventsTest.php @@ -1,35 +1,29 @@ $model * @param string $forceDeleteEvent * @param string $deleteEvent * @param string $deleteManyEvent @@ -43,24 +37,22 @@ class FireEventsTest extends TestCase * @dataProvider modelWithSoftDeletingDataProvider */ public function testFiringSoftDelete( - string $model, string $forceDeleteEvent, string $deleteEvent, string $deleteManyEvent, string $forceDeleteManyEvent, - ): void { + ): void + { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query()->bulk(); + $users = $this->userGenerator->createCollection(2); + $sut = User::query()->bulk(); $forceDeletingCallback = Mockery::spy(TestCallback::class); $deletingCallback = Mockery::spy(TestCallback::class); $deletingManyCallback = Mockery::spy(TestCallback::class); $forceDeletingManyCallback = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listen($forceDeleteEvent, $forceDeletingCallback); Observer::listen($deleteEvent, $deletingCallback); Observer::listen($deleteManyEvent, $deletingManyCallback); @@ -72,7 +64,7 @@ public function testFiringSoftDelete( // assert $modelListenerUserIndex = 0; - $this->spyShouldHaveReceived($deletingCallback) + self::spyShouldHaveReceived($deletingCallback) ->twice() ->withArgs( function (User $user) use ($users, &$modelListenerUserIndex): bool { @@ -85,7 +77,7 @@ function (User $user) use ($users, &$modelListenerUserIndex): bool { return false; } ); - $this->spyShouldHaveReceived($deletingManyCallback) + self::spyShouldHaveReceived($deletingManyCallback) ->once() ->withArgs( function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelListenerUserIndex): bool { @@ -103,12 +95,11 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelL && $modelListenerUserIndex === 2; } ); - $this->spyShouldNotHaveReceived($forceDeletingCallback); - $this->spyShouldNotHaveReceived($forceDeletingManyCallback); + self::spyShouldNotHaveReceived($forceDeletingCallback); + self::spyShouldNotHaveReceived($forceDeletingManyCallback); } /** - * @param class-string $model * @param string $forceDeleteEvent * @param string $deleteEvent * @param string $deleteManyEvent @@ -122,24 +113,22 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelL * @dataProvider modelWithSoftDeletingDataProvider */ public function testFiringForceDeleting( - string $model, string $forceDeleteEvent, string $deleteEvent, string $deleteManyEvent, string $forceDeleteManyEvent, - ): void { + ): void + { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollection(2); - $sut = $model::query()->bulk(); + $users = $this->userGenerator->createCollection(2); + $sut = User::query()->bulk(); $forceDeletingListener = Mockery::spy(TestCallback::class); $deletingListener = Mockery::spy(TestCallback::class); $deletingManyListener = Mockery::spy(TestCallback::class); $forceDeletingManyListener = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listen($forceDeleteEvent, $forceDeletingListener); Observer::listen($deleteEvent, $deletingListener); Observer::listen($deleteManyEvent, $deletingManyListener); @@ -151,7 +140,7 @@ public function testFiringForceDeleting( // assert $modelListenerUserIndex = 0; - $this->spyShouldHaveReceived($forceDeletingListener) + self::spyShouldHaveReceived($forceDeletingListener) ->twice() ->withArgs( function (User $user) use ($users, &$modelListenerUserIndex): bool { @@ -165,7 +154,7 @@ function (User $user) use ($users, &$modelListenerUserIndex): bool { } ); - $this->spyShouldHaveReceived($deletingListener) + self::spyShouldHaveReceived($deletingListener) ->twice() ->withArgs( function (User $user) use ($users, &$modelListenerUserIndex): bool { @@ -179,7 +168,7 @@ function (User $user) use ($users, &$modelListenerUserIndex): bool { } ); - $this->spyShouldHaveReceived($deletingManyListener) + self::spyShouldHaveReceived($deletingManyListener) ->once() ->withArgs( function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelListenerUserIndex): bool { @@ -203,7 +192,7 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelL } ); - $this->spyShouldHaveReceived($forceDeletingManyListener) + self::spyShouldHaveReceived($forceDeletingManyListener) ->once() ->withArgs( function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelListenerUserIndex): bool { @@ -224,7 +213,6 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelL } /** - * @param class-string $model * @param string $forceDeleteEvent * @param string $deleteEvent * @param string $deleteManyEvent @@ -238,23 +226,23 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users, &$modelL * @dataProvider modelWithoutSoftDeletingDataProvider */ public function testFiringDeletingWithoutSoft( - string $model, string $forceDeleteEvent, string $deleteEvent, string $deleteManyEvent, string $forceDeleteManyEvent, - ): void { + ): void + { // arrange /** @var PostCollection $posts */ - $posts = $model::factory()->count(2)->create(); - $sut = $model::query()->bulk(); + $posts = Post::factory()->count(2)->create(); + $sut = Post::query()->bulk(); $forceDeletingListener = Mockery::spy(TestCallback::class); $deletingListener = Mockery::spy(TestCallback::class); $deletingManyListener = Mockery::spy(TestCallback::class); $forceDeletingManyListener = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + Post::observe(Observer::class); Observer::listen($forceDeleteEvent, $forceDeletingListener); Observer::listen($deleteEvent, $deletingListener); Observer::listen($deleteManyEvent, $deletingManyListener); @@ -266,7 +254,7 @@ public function testFiringDeletingWithoutSoft( // assert $modelListenerPostIndex = 0; - $this->spyShouldHaveReceived($deletingListener) + self::spyShouldHaveReceived($deletingListener) ->twice() ->withArgs( function (Post $post) use ($posts, &$modelListenerPostIndex): bool { @@ -280,7 +268,7 @@ function (Post $post) use ($posts, &$modelListenerPostIndex): bool { } ); - $this->spyShouldHaveReceived($deletingManyListener) + self::spyShouldHaveReceived($deletingManyListener) ->once() ->withArgs( function (PostCollection $actualPosts, BulkRows $bulkRows) use ($posts, &$modelListenerPostIndex): bool { @@ -299,36 +287,20 @@ function (PostCollection $actualPosts, BulkRows $bulkRows) use ($posts, &$modelL } ); - $this->spyShouldNotHaveReceived($forceDeletingListener); - $this->spyShouldNotHaveReceived($forceDeletingManyListener); + self::spyShouldNotHaveReceived($forceDeletingListener); + self::spyShouldNotHaveReceived($forceDeletingManyListener); } - public function modelWithSoftDeletingDataProvider(): array + public static function modelWithSoftDeletingDataProvider(): array { return [ - 'mysql + -ing events' => [ - MySqlUser::class, + '-ing events' => [ BulkEventEnum::FORCE_DELETING, BulkEventEnum::DELETING, BulkEventEnum::DELETING_MANY, BulkEventEnum::FORCE_DELETING_MANY, ], - 'mysql + -ed events' => [ - MySqlUser::class, - BulkEventEnum::FORCE_DELETED, - BulkEventEnum::DELETED, - BulkEventEnum::DELETED_MANY, - BulkEventEnum::FORCE_DELETED_MANY, - ], - 'pgsql + -ing events' => [ - PostgreSqlUser::class, - BulkEventEnum::FORCE_DELETING, - BulkEventEnum::DELETING, - BulkEventEnum::DELETING_MANY, - BulkEventEnum::FORCE_DELETING_MANY, - ], - 'pgsql + -ed events' => [ - PostgreSqlUser::class, + '-ed events' => [ BulkEventEnum::FORCE_DELETED, BulkEventEnum::DELETED, BulkEventEnum::DELETED_MANY, @@ -337,46 +309,16 @@ public function modelWithSoftDeletingDataProvider(): array ]; } - public function modelWithoutSoftDeletingDataProvider(): array + public static function modelWithoutSoftDeletingDataProvider(): array { return [ - 'mysql + -ing events' => [ - MySqlPost::class, - BulkEventEnum::FORCE_DELETING, - BulkEventEnum::DELETING, - BulkEventEnum::DELETING_MANY, - BulkEventEnum::FORCE_DELETING_MANY, - ], - 'mysql + -ed events' => [ - MySqlPost::class, - BulkEventEnum::FORCE_DELETED, - BulkEventEnum::DELETED, - BulkEventEnum::DELETED_MANY, - BulkEventEnum::FORCE_DELETED_MANY, - ], - 'pgsql + -ing events' => [ - PostgreSqlPost::class, - BulkEventEnum::FORCE_DELETING, - BulkEventEnum::DELETING, - BulkEventEnum::DELETING_MANY, - BulkEventEnum::FORCE_DELETING_MANY, - ], - 'pgsql + -ed events' => [ - PostgreSqlPost::class, - BulkEventEnum::FORCE_DELETED, - BulkEventEnum::DELETED, - BulkEventEnum::DELETED_MANY, - BulkEventEnum::FORCE_DELETED_MANY, - ], - 'sqlite + -ing events' => [ - SqLitePost::class, + '-ing events' => [ BulkEventEnum::FORCE_DELETING, BulkEventEnum::DELETING, BulkEventEnum::DELETING_MANY, BulkEventEnum::FORCE_DELETING_MANY, ], - 'sqlite + -ed events' => [ - SqLitePost::class, + '-ed events' => [ BulkEventEnum::FORCE_DELETED, BulkEventEnum::DELETED, BulkEventEnum::DELETED_MANY, diff --git a/tests/Unit/Bulk/SaveAccumulatedTest.php b/tests/Unit/Bulk/SaveAccumulatedTest.php index f287a23..a18c5f6 100644 --- a/tests/Unit/Bulk/SaveAccumulatedTest.php +++ b/tests/Unit/Bulk/SaveAccumulatedTest.php @@ -1,37 +1,28 @@ $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function test(string $model): void + public function test(): void { // arrange - $this->userGenerator->setModel($model); - $creatingUsers = $this->userGenerator->makeCollection(2); $updatingUsers = $this->userGenerator->createCollectionAndDirty(2); $upsertingUsers = new UserCollection([ @@ -39,7 +30,7 @@ public function test(string $model): void $this->userGenerator->createOneAndDirty(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->orUniqueBy(['id']) @@ -52,21 +43,12 @@ public function test(string $model): void // assert $creatingUsers->each( - fn (User $user) => $this->userWasCreated($user) + fn(User $user) => $this->userWasCreated($user) ); $updatingUsers->each( - fn (User $user) => $this->userWasUpdated($user) + fn(User $user) => $this->userWasUpdated($user) ); $this->userWasCreated($upsertingUsers->get(0)); $this->userWasUpdated($upsertingUsers->get(1)); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/TransmittingModelIntoConstructorTest.php b/tests/Unit/Bulk/TransmittingModelIntoConstructorTest.php index dfe77e1..4cc56c7 100644 --- a/tests/Unit/Bulk/TransmittingModelIntoConstructorTest.php +++ b/tests/Unit/Bulk/TransmittingModelIntoConstructorTest.php @@ -1,22 +1,22 @@ $model * @param Closure $data * @param array $events * @@ -35,16 +31,16 @@ final class UpdateAfterWritingEventsTest extends TestCase * * @throws BulkException */ - public function testModel(string $model, Closure $data, array $events): void + public function testModel(Closure $data, array $events): void { // arrange /** @var UserCollection $users */ $users = $data(); $users = $users->keyBy('id'); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); - $model::observe(Observer::class); + User::observe(Observer::class); $spies = []; @@ -60,7 +56,7 @@ public function testModel(string $model, Closure $data, array $events): void foreach ($events as $event) { $copiesUsers = clone $users; - $this->spyShouldHaveReceived($spies[$event]) + self::spyShouldHaveReceived($spies[$event]) ->times($users->count()) ->withArgs( function (User $user) use ($copiesUsers): bool { @@ -74,7 +70,6 @@ function (User $user) use ($copiesUsers): bool { } /** - * @param class-string $model * @param Closure $data * @param string $event * @@ -84,24 +79,24 @@ function (User $user) use ($copiesUsers): bool { * * @throws BulkException */ - public function testCollection(string $model, Closure $data, string $event): void + public function testCollection(Closure $data, string $event): void { // arrange /** @var UserCollection $users */ $users = $data(); $users = $users->keyBy('id'); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); $spy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listen($event, $spy); // act $sut->update($users); // assert - $this->spyShouldHaveReceived($spy) + self::spyShouldHaveReceived($spy) ->once() ->withArgs( function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { @@ -112,9 +107,9 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { ); } - public function modelDataProvider(): array + public static function modelDataProvider(): array { - $target = [ + return [ 'saved' => [ function () { return App::make(UserGenerator::class) @@ -195,24 +190,11 @@ function () { [BulkEventEnum::RESTORED], ], ]; - - $result = []; - - foreach ($this->userModels() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; } - public function collectionDataProvider(): array + public static function collectionDataProvider(): array { - $target = [ + return [ 'saved many' => [ function () { return App::make(UserGenerator::class) @@ -250,27 +232,5 @@ function () { BulkEventEnum::RESTORED_MANY, ], ]; - - $result = []; - - foreach ($this->userModels() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; - } - - public function userModels(): array - { - return [ - 'mysql' => MySqlUser::class, - 'pgsql' => PostgreSqlUser::class, - 'sqlite' => SqLiteUser::class, - ]; } } diff --git a/tests/Unit/Bulk/Update/UpdateAndReturnTest.php b/tests/Unit/Bulk/Update/UpdateAndReturnTest.php index 721c626..98d7aa8 100644 --- a/tests/Unit/Bulk/Update/UpdateAndReturnTest.php +++ b/tests/Unit/Bulk/Update/UpdateAndReturnTest.php @@ -1,26 +1,22 @@ $model * @param string $uniqBy * * @return void @@ -29,16 +25,15 @@ final class UpdateAndReturnTest extends TestCase * * @throws BulkException */ - public function testDatabase(string $model, string $uniqBy): void + public function testDatabase(string $uniqBy): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOne(), $this->userGenerator->createOneAndDirty(), ]); $users = $users->keyBy('id'); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy([$uniqBy]); @@ -47,12 +42,11 @@ public function testDatabase(string $model, string $uniqBy): void // assert $users->each( - fn (User $user) => $this->userWasUpdated($user) + fn(User $user) => $this->userWasUpdated($user) ); } /** - * @param class-string $model * @param string $uniqBy * * @return void @@ -61,16 +55,15 @@ public function testDatabase(string $model, string $uniqBy): void * * @throws BulkException */ - public function testResult(string $model, string $uniqBy): void + public function testResult(string $uniqBy): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOne(), $this->userGenerator->createOneAndDirty(), ]); $users = $users->keyBy('id'); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy([$uniqBy]); @@ -88,7 +81,6 @@ public function testResult(string $model, string $uniqBy): void } /** - * @param class-string $model * @param string $uniqBy * * @return void @@ -97,11 +89,10 @@ public function testResult(string $model, string $uniqBy): void * * @throws BulkException */ - public function testSelectColumns(string $model, string $uniqBy): void + public function testSelectColumns(string $uniqBy): void { // arrange $fields = ['id', 'email', 'name']; - $this->userGenerator->setModel($model); $users = new UserCollection([ Arr::only( $this->userGenerator->createOne()->toArray(), @@ -113,7 +104,7 @@ public function testSelectColumns(string $model, string $uniqBy): void ), ]); $users = $users->keyBy('id'); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy([$uniqBy]); @@ -139,33 +130,11 @@ public function testSelectColumns(string $model, string $uniqBy): void } } - public function dataProvider(): array + public static function dataProvider(): array { - $target = [ + return [ 'email' => ['email'], 'id' => ['id'], ]; - - $result = []; - - foreach ($this->userModels() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; - } - - public function userModels(): array - { - return [ - 'mysql' => MySqlUser::class, - 'pgsql' => PostgreSqlUser::class, - 'sqlite' => SqLiteUser::class, - ]; } } diff --git a/tests/Unit/Bulk/Update/UpdateAndTouchTest.php b/tests/Unit/Bulk/Update/UpdateAndTouchTest.php index 60c864b..f732caa 100644 --- a/tests/Unit/Bulk/Update/UpdateAndTouchTest.php +++ b/tests/Unit/Bulk/Update/UpdateAndTouchTest.php @@ -1,62 +1,51 @@ $postModel - * @param class-string $commentModel - * * @return void * * @throws JsonException * @throws BulkException - * - * @dataProvider modelsDataProvider */ - public function test(string $postModel, string $commentModel): void + public function test(): void { // arrange $now = Carbon::now(); Carbon::setTestNow(Carbon::now()->subYear()); /** @var PostCollection $posts */ - $posts = $postModel::factory() + $posts = Post::factory() ->count(2) ->create() ->each( - function (Post $post) use ($commentModel): void { - $commentModel::factory() + function (Post $post): void { + Comment::factory() ->count(2) ->create(['post_id' => $post->id]); $post->text = Str::random(); } ); - $sut = $postModel::query()->bulk(); + $sut = Post::query()->bulk(); Carbon::setTestNow($now); - $commentModel::setGlobalTouchedRelations(['user']); - $postModel::setGlobalTouchedRelations(['comments']); + Comment::setGlobalTouchedRelations(['user']); + Post::setGlobalTouchedRelations(['comments']); // act $sut->update($posts); @@ -77,13 +66,4 @@ function (Post $post) use ($commentModel): void { } } } - - public function modelsDataProvider(): array - { - return [ - 'mysql' => [MySqlPost::class, MySqlComment::class], - 'pgsql' => [PostgreSqlPost::class, PostgreSqlComment::class], - 'sqlite' => [SqLitePost::class, SqLiteComment::class], - ]; - } } diff --git a/tests/Unit/Bulk/Update/UpdateBeforeWritingEventDependenciesTest.php b/tests/Unit/Bulk/Update/UpdateBeforeWritingEventDependenciesTest.php index 39d2dec..9587b5c 100644 --- a/tests/Unit/Bulk/Update/UpdateBeforeWritingEventDependenciesTest.php +++ b/tests/Unit/Bulk/Update/UpdateBeforeWritingEventDependenciesTest.php @@ -1,6 +1,6 @@ $model * @param Closure $data * @param string $event * @param array $dependencies @@ -44,14 +40,14 @@ final class UpdateBeforeWritingEventDependenciesTest extends TestCase * @dataProvider modelDataProvider */ public function testModelEventReturnsFalseSometimes( - string $model, Closure $data, string $event, array $dependencies - ): void { + ): void + { // arrange $users = $data(); - $model::observe(Observer::class); + User::observe(Observer::class); /** @var array $spies */ $spies = [ $event => Mockery::mock(TestCallback::class), @@ -69,7 +65,7 @@ public function testModelEventReturnsFalseSometimes( } } - $sut = $model::query() + $sut = User::query() ->bulk() ->withTrashed() ->uniqueBy(['id']); @@ -79,7 +75,7 @@ public function testModelEventReturnsFalseSometimes( // assert foreach ($dependencies['model'] as $dependency) { - $this->spyShouldHaveReceived($spies[$dependency]) + self::spyShouldHaveReceived($spies[$dependency]) ->once() ->withArgs( static function (User $user) use ($users): bool { @@ -89,7 +85,7 @@ static function (User $user) use ($users): bool { } foreach ($dependencies['collection'] as $dependency) { - $this->spyShouldHaveReceived($spies[$dependency]) + self::spyShouldHaveReceived($spies[$dependency]) ->once() ->withArgs( static function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { @@ -106,7 +102,6 @@ static function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): /** * If one of model events always returns false then its dependencies have not been called. * - * @param class-string $model * @param Closure $data * @param string $event * @param array $dependencies @@ -118,14 +113,14 @@ static function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): * @dataProvider modelDataProvider */ public function testModelEventReturnsFalseAlways( - string $model, Closure $data, string $event, array $dependencies - ): void { + ): void + { // arrange $users = $data(); - $model::observe(Observer::class); + User::observe(Observer::class); /** @var array $spies */ $spies = [ $event => Mockery::mock(TestCallback::class), @@ -143,7 +138,7 @@ public function testModelEventReturnsFalseAlways( } } - $sut = $model::query() + $sut = User::query() ->bulk() ->withTrashed() ->uniqueBy(['id']); @@ -153,18 +148,17 @@ public function testModelEventReturnsFalseAlways( // assert foreach ($dependencies['model'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } foreach ($dependencies['collection'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } } /** * When one of collection events returns false then its dependencies have not been called. * - * @param class-string $model * @param Closure $data * @param string $event * @param array $dependencies @@ -176,14 +170,14 @@ public function testModelEventReturnsFalseAlways( * @dataProvider collectionDataProvider */ public function testCollectionEventReturnsFalse( - string $model, Closure $data, string $event, array $dependencies, - ): void { + ): void + { // arrange $users = $data(); - $model::observe(Observer::class); + User::observe(Observer::class); /** @var array $spies */ $spies = [ $event => Mockery::mock(TestCallback::class), @@ -201,7 +195,7 @@ public function testCollectionEventReturnsFalse( } } - $sut = $model::query() + $sut = User::query() ->bulk() ->withTrashed() ->uniqueBy(['id']); @@ -211,28 +205,24 @@ public function testCollectionEventReturnsFalse( // assert foreach ($dependencies['model'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } foreach ($dependencies['collection'] as $dependency) { - $this->spyShouldNotHaveReceived($spies[$dependency]); + self::spyShouldNotHaveReceived($spies[$dependency]); } } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDoNotFireUpdatingIfTheModelIsNotDirty(string $model): void + public function testDoNotFireUpdatingIfTheModelIsNotDirty(): void { // arrange $users = $this->userGenerator->createCollection(2); - $model::observe(Observer::class); + User::observe(Observer::class); $savingSpy = Mockery::spy(TestCallback::class); $savingManySpy = Mockery::spy(TestCallback::class); $updatingSpy = Mockery::spy(TestCallback::class); @@ -243,7 +233,7 @@ public function testDoNotFireUpdatingIfTheModelIsNotDirty(string $model): void Observer::listen(BulkEventEnum::UPDATING, $updatingSpy); Observer::listen(BulkEventEnum::UPDATING_MANY, $updatingManySpy); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['id']); @@ -251,19 +241,18 @@ public function testDoNotFireUpdatingIfTheModelIsNotDirty(string $model): void $sut->update($users); // assert - $this->spyShouldHaveReceived($savingSpy); - $this->spyShouldHaveReceived($savingManySpy); - $this->spyShouldNotHaveReceived($updatingSpy); - $this->spyShouldNotHaveReceived($updatingManySpy); + self::spyShouldHaveReceived($savingSpy); + self::spyShouldHaveReceived($savingManySpy); + self::spyShouldNotHaveReceived($updatingSpy); + self::spyShouldNotHaveReceived($updatingManySpy); } - public function modelDataProvider(): array + public static function modelDataProvider(): array { - $target = [ + return [ 'saving' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(2) ->toArray(); }, @@ -282,9 +271,8 @@ function (string $model) { ], ], 'updating' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(2) ->toArray(); }, @@ -300,9 +288,8 @@ function (string $model) { ], ], 'saving && deleting' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(2, [], ['deleted_at' => Carbon::now()]) ->toArray(); }, @@ -325,9 +312,8 @@ function (string $model) { ], ], 'updating && deleting' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(2, [], ['deleted_at' => Carbon::now()]) ->toArray(); }, @@ -343,9 +329,8 @@ function (string $model) { ], ], 'saving && restoring' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 2, ['deleted_at' => Carbon::now()], @@ -372,9 +357,8 @@ function (string $model) { ], ], 'updating && restoring' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 2, ['deleted_at' => Carbon::now()], @@ -394,9 +378,8 @@ function (string $model) { ], ], 'deleting' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollection(2, ['deleted_at' => null]) ->each( function (User $user) { @@ -417,9 +400,8 @@ function (User $user) { ], ], 'restoring' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollection(2, ['deleted_at' => Carbon::now()]) ->each( function (User $user) { @@ -440,31 +422,14 @@ function (User $user) { ], ], ]; - - $result = []; - - foreach ($this->userModelsDataProvider() as $type => [$model]) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - function () use ($value, $model) { - return $value[0]($model); - }, - ...array_slice($value, 1), - ]; - } - } - - return $result; } - public function collectionDataProvider(): array + public static function collectionDataProvider(): array { - $target = [ + return [ 'saving many' => [ - function (string $model) { - $userGenerator = App::make(UserGenerator::class) - ->setModel($model); + function () { + $userGenerator = App::make(UserGenerator::class); $firstUser = $userGenerator->createOneAndDirty(); $secondUser = $userGenerator->createOneAndDirty( ['deleted_at' => null], @@ -504,9 +469,8 @@ function (string $model) { ], ], 'updating many' => [ - function (string $model) { - $userGenerator = App::make(UserGenerator::class) - ->setModel($model); + function () { + $userGenerator = App::make(UserGenerator::class); $firstUser = $userGenerator->createOneAndDirty(); $secondUser = $userGenerator->createOneAndDirty( ['deleted_at' => null], @@ -534,9 +498,8 @@ function (string $model) { ], ], 'deleting many' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 3, ['deleted_at' => null], @@ -555,9 +518,8 @@ function (string $model) { ], ], 'restoring many' => [ - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 3, ['deleted_at' => Carbon::now()], @@ -576,30 +538,5 @@ function (string $model) { ], ], ]; - - $result = []; - - foreach ($this->userModelsDataProvider() as $type => [$model]) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - function () use ($value, $model) { - return $value[0]($model); - }, - ...array_slice($value, 1), - ]; - } - } - - return $result; - } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; } } diff --git a/tests/Unit/Bulk/Update/UpdateBuilderCallbacksTest.php b/tests/Unit/Bulk/Update/UpdateBuilderCallbacksTest.php index 45aae5e..8c78bf5 100644 --- a/tests/Unit/Bulk/Update/UpdateBuilderCallbacksTest.php +++ b/tests/Unit/Bulk/Update/UpdateBuilderCallbacksTest.php @@ -1,6 +1,6 @@ $model * @param string $method * @param Closure $callback * @@ -37,19 +33,19 @@ final class UpdateBuilderCallbacksTest extends TestCase * * @dataProvider dataProvider */ - public function testModel(string $model, string $method, Closure $callback): void + public function testModel(string $method, Closure $callback): void { // arrange $users = $callback(); $spy = Mockery::spy(TestCallback::class, $method); - $sut = $model::query()->bulk(); + $sut = User::query()->bulk(); $sut->{$method}($spy); // act $sut->update($users); // arrange - $this->spyShouldHaveReceived($spy) + self::spyShouldHaveReceived($spy) ->once() ->withArgs( function (User $user) use ($users): bool { @@ -59,7 +55,6 @@ function (User $user) use ($users): bool { } /** - * @param class-string $model * @param string $method * @param Closure $callback * @@ -69,20 +64,20 @@ function (User $user) use ($users): bool { * * @dataProvider dataProvider */ - public function testCollection(string $model, string $method, Closure $callback): void + public function testCollection(string $method, Closure $callback): void { // arrange /** @var UserCollection $users */ $users = $callback(); $spy = Mockery::spy(TestCallback::class, $method); - $sut = $model::query()->bulk(); + $sut = User::query()->bulk(); $sut->{$method . 'Many'}($spy); // act $sut->update($users); // arrange - $this->spyShouldHaveReceived($spy) + self::spyShouldHaveReceived($spy) ->once() ->withArgs( function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { @@ -95,17 +90,10 @@ function (UserCollection $actualUsers, BulkRows $bulkRows) use ($users): bool { ); } - /** - * @param class-string $model - * - * @return void - * - * @dataProvider userModelsDataProvider - */ - public function testCallUndefinedListener(string $model): void + public function testCallUndefinedListener(): void { // arrange - $sut = $model::query()->bulk(); + $sut = User::query()->bulk(); // assert $this->expectException(BadMethodCallException::class); @@ -114,46 +102,41 @@ public function testCallUndefinedListener(string $model): void $sut->onFake(); } - public function dataProvider(): array + public static function dataProvider(): array { - $target = [ + return [ 'onUpdating' => [ 'onUpdating', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(1); }, ], 'onSaving' => [ 'onSaving', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(1); }, ], 'onUpdated' => [ 'onUpdated', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(1); }, ], 'onSaved' => [ 'onSaved', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty(1); }, ], 'onDeleting' => [ 'onDeleting', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 1, ['deleted_at' => null], @@ -163,9 +146,8 @@ function (string $model) { ], 'onDeleted' => [ 'onDeleted', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 1, ['deleted_at' => null], @@ -175,9 +157,8 @@ function (string $model) { ], 'onRestoring' => [ 'onRestoring', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 1, ['deleted_at' => Carbon::now()], @@ -187,9 +168,8 @@ function (string $model) { ], 'onRestored' => [ 'onRestored', - function (string $model) { + function () { return App::make(UserGenerator::class) - ->setModel($model) ->createCollectionAndDirty( 1, ['deleted_at' => Carbon::now()], @@ -198,30 +178,5 @@ function (string $model) { }, ], ]; - - $result = []; - - foreach ($this->userModelsDataProvider() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model[0], - $value[0], - function () use ($model, $value) { - return $value[1]($model[0]); - }, - ]; - } - } - - return $result; - } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; } } diff --git a/tests/Unit/Bulk/Update/UpdateDifferentUniqueByTest.php b/tests/Unit/Bulk/Update/UpdateDifferentUniqueByTest.php index c725573..3e8edf6 100644 --- a/tests/Unit/Bulk/Update/UpdateDifferentUniqueByTest.php +++ b/tests/Unit/Bulk/Update/UpdateDifferentUniqueByTest.php @@ -1,27 +1,23 @@ $model * @param array|string $uniqueBy * @param array|string $orUniqueBy * @@ -32,10 +28,9 @@ final class UpdateDifferentUniqueByTest extends TestCase * * @dataProvider dataProvider */ - public function test(string $model, string|array $uniqueBy, string|array $orUniqueBy): void + public function test(string|array $uniqueBy, string|array $orUniqueBy): void { // arrange - $this->userGenerator->setModel($model); $userWithEmail = Arr::except( $this->userGenerator->createOneAndDirty()->toArray(), ['id'] @@ -45,7 +40,7 @@ public function test(string $model, string|array $uniqueBy, string|array $orUniq ['email'] ); $connectionName = $this->userGenerator->makeOne()->getConnectionName(); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy($uniqueBy) ->orUniqueBy($orUniqueBy); @@ -54,7 +49,7 @@ public function test(string $model, string|array $uniqueBy, string|array $orUniq $sut->update([$userWithEmail, $userWithId]); // assert - $this->assertDatabaseHas($model::table(), [ + $this->assertDatabaseHas(User::table(), [ 'id' => $userWithId['id'], 'name' => $userWithId['name'], 'gender' => $userWithId['gender']->value, @@ -69,12 +64,12 @@ public function test(string $model, string|array $uniqueBy, string|array $orUniq 'deleted_at' => $userWithId['deleted_at'], ], $connectionName); - $this->assertDatabaseMissing($model::table(), [ + $this->assertDatabaseMissing(User::table(), [ 'id' => $userWithId['id'], 'created_at' => Carbon::now()->toDateTimeString(), ], $connectionName); - $this->assertDatabaseHas($model::table(), [ + $this->assertDatabaseHas(User::table(), [ 'email' => $userWithEmail['email'], 'name' => $userWithEmail['name'], 'gender' => $userWithEmail['gender']->value, @@ -89,40 +84,18 @@ public function test(string $model, string|array $uniqueBy, string|array $orUniq 'deleted_at' => $userWithEmail['deleted_at'], ], $connectionName); - $this->assertDatabaseMissing($model::table(), [ + $this->assertDatabaseMissing(User::table(), [ 'email' => $userWithEmail['email'], 'created_at' => Carbon::now()->toDateTimeString(), ], $connectionName); } - public function dataProvider(): array + public static function dataProvider(): array { - $target = [ + return [ 'email, id' => ['email', 'id'], '[email], [id]' => [['email'], ['id']], '[[email]], [[id]]' => [[['email']], [['id']]], ]; - - $result = []; - - foreach ($this->userModels() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; - } - - public function userModels(): array - { - return [ - 'mysql' => MySqlUser::class, - 'pgsql' => PostgreSqlUser::class, - 'sqlite' => SqLiteUser::class, - ]; } } diff --git a/tests/Unit/Bulk/Update/UpdateEventsTest.php b/tests/Unit/Bulk/Update/UpdateEventsTest.php index 61beda8..d59f403 100644 --- a/tests/Unit/Bulk/Update/UpdateEventsTest.php +++ b/tests/Unit/Bulk/Update/UpdateEventsTest.php @@ -1,80 +1,65 @@ $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDisableAllEvents(string $model): void + public function testDisableAllEvents(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->disableEvents(); $spy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($spy); // act $sut->update($users); // assert - $this->spyShouldNotHaveReceived($spy); + self::spyShouldNotHaveReceived($spy); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testDisableModelEndEvents(string $model): void + public function testDisableModelEndEvents(): void { // arrange $disabledEvents = BulkEventEnum::modelEnd(); - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->disableModelEndEvents(); $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); foreach ($disabledEvents as $event) { @@ -85,14 +70,13 @@ public function testDisableModelEndEvents(string $model): void $sut->update($users); // assert - $this->spyShouldHaveReceived($callingSpy) + self::spyShouldHaveReceived($callingSpy) ->atLeast() ->once(); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model * @param string $disabledEvent * * @return void @@ -101,20 +85,18 @@ public function testDisableModelEndEvents(string $model): void * * @dataProvider eventsDataProvider */ - public function testDisableSomeEvents(string $model, string $disabledEvent): void + public function testDisableSomeEvents(string $disabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->disableEvents([$disabledEvent]); $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); Observer::listen($disabledEvent, $notCallingSpy); @@ -122,14 +104,13 @@ public function testDisableSomeEvents(string $model, string $disabledEvent): voi $sut->update($users); // assert - $this->spyShouldHaveReceived($callingSpy) + self::spyShouldHaveReceived($callingSpy) ->atLeast() ->once(); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model * @param string $disabledEvent * * @return void @@ -138,20 +119,18 @@ public function testDisableSomeEvents(string $model, string $disabledEvent): voi * * @dataProvider eventsDataProvider */ - public function testDisableOneEvent(string $model, string $disabledEvent): void + public function testDisableOneEvent(string $disabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->disableEvent($disabledEvent); $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($callingSpy); Observer::listen($disabledEvent, $notCallingSpy); @@ -159,33 +138,27 @@ public function testDisableOneEvent(string $model, string $disabledEvent): void $sut->update($users); // assert - $this->spyShouldHaveReceived($callingSpy) + self::spyShouldHaveReceived($callingSpy) ->atLeast() ->once(); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testEnableAllEvents(string $model): void + public function testEnableAllEvents(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->enableEvents(); $spy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($spy); $countOfCallingPerModel = count(BulkEventEnum::update()) + count(BulkEventEnum::save()); @@ -193,7 +166,7 @@ public function testEnableAllEvents(string $model): void $sut->update($users); // assert - $this->spyShouldHaveReceived($spy) + self::spyShouldHaveReceived($spy) ->times( $countOfCallingPerModel * $users->count() // The minus due to the collection events @@ -202,7 +175,6 @@ public function testEnableAllEvents(string $model): void } /** - * @param class-string $model * @param string $enabledEvent * * @return void @@ -211,13 +183,11 @@ public function testEnableAllEvents(string $model): void * * @dataProvider eventsDataProvider */ - public function testEnableSomeDisabledEvents(string $model, string $enabledEvent): void + public function testEnableSomeDisabledEvents(string $enabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->enableEvents() ->disableEvent($enabledEvent) @@ -225,18 +195,17 @@ public function testEnableSomeDisabledEvents(string $model, string $enabledEvent $callingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listen($enabledEvent, $callingSpy); // act $sut->update($users); // assert - $this->spyShouldHaveReceived($callingSpy); + self::spyShouldHaveReceived($callingSpy); } /** - * @param class-string $model * @param string $enabledEvent * * @return void @@ -245,13 +214,11 @@ public function testEnableSomeDisabledEvents(string $model, string $enabledEvent * * @dataProvider eventsDataProvider */ - public function testEnableSomeEvents(string $model, string $enabledEvent): void + public function testEnableSomeEvents(string $enabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->disableEvents() ->enableEvents([$enabledEvent]); @@ -259,7 +226,7 @@ public function testEnableSomeEvents(string $model, string $enabledEvent): void $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($notCallingSpy, [$enabledEvent]); Observer::listen($enabledEvent, $callingSpy); @@ -267,12 +234,11 @@ public function testEnableSomeEvents(string $model, string $enabledEvent): void $sut->update($users); // assert - $this->spyShouldHaveReceived($callingSpy); - $this->spyShouldNotHaveReceived($notCallingSpy); + self::spyShouldHaveReceived($callingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } /** - * @param class-string $model * @param string $enabledEvent * * @return void @@ -281,13 +247,11 @@ public function testEnableSomeEvents(string $model, string $enabledEvent): void * * @dataProvider eventsDataProvider */ - public function testEnableOneEvent(string $model, string $enabledEvent): void + public function testEnableOneEvent(string $enabledEvent): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->disableEvents() ->enableEvent($enabledEvent); @@ -295,7 +259,7 @@ public function testEnableOneEvent(string $model, string $enabledEvent): void $callingSpy = Mockery::spy(TestCallback::class); $notCallingSpy = Mockery::spy(TestCallback::class); - $model::observe(Observer::class); + User::observe(Observer::class); Observer::listenAny($notCallingSpy, [$enabledEvent]); Observer::listen($enabledEvent, $callingSpy); @@ -303,34 +267,18 @@ public function testEnableOneEvent(string $model, string $enabledEvent): void $sut->update($users); // assert - $this->spyShouldHaveReceived($callingSpy); - $this->spyShouldNotHaveReceived($notCallingSpy); - } - - public function eventsDataProvider(): array - { - $targetEvents = [ - ...BulkEventEnum::save(), - ...BulkEventEnum::update(), - ]; - - $result = []; - - foreach ($this->userModelsDataProvider() as $key => [$model]) { - foreach ($targetEvents as $targetEvent) { - $result[$targetEvent . ' && ' . $key] = [$model, $targetEvent]; - } - } - - return $result; + self::spyShouldHaveReceived($callingSpy); + self::spyShouldNotHaveReceived($notCallingSpy); } - public function userModelsDataProvider(): array + public static function eventsDataProvider(): array { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; + return array_map( + fn(string $event) => [$event], + [ + ...BulkEventEnum::save(), + ...BulkEventEnum::update(), + ] + ); } } diff --git a/tests/Unit/Bulk/Update/UpdateOnlyAndExceptTest.php b/tests/Unit/Bulk/Update/UpdateOnlyAndExceptTest.php index 74fa5cf..e5bc06f 100644 --- a/tests/Unit/Bulk/Update/UpdateOnlyAndExceptTest.php +++ b/tests/Unit/Bulk/Update/UpdateOnlyAndExceptTest.php @@ -1,40 +1,30 @@ $model - * * @return void * - * @throws JsonException - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testOnly(string $model): void + public function testOnly(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->uniqueBy(['id']) ->updateOnly(['name']); @@ -67,22 +57,15 @@ function (User $user) { } /** - * @param class-string $model - * * @return void * - * @throws JsonException * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testUpdateAllExcept(string $model): void + public function testUpdateAllExcept(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->uniqueBy(['id']) ->updateAllExcept(['name']); @@ -113,13 +96,4 @@ function (User $user) { } ); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/Update/UpdateOrAccumulateTest.php b/tests/Unit/Bulk/Update/UpdateOrAccumulateTest.php index 67e8417..f40e885 100644 --- a/tests/Unit/Bulk/Update/UpdateOrAccumulateTest.php +++ b/tests/Unit/Bulk/Update/UpdateOrAccumulateTest.php @@ -1,38 +1,29 @@ $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testBigChunkSize(string $model): void + public function testBigChunkSize(): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -41,12 +32,11 @@ public function testBigChunkSize(string $model): void // assert $users->each( - fn (User $user) => $this->userWasNotUpdated($user) + fn(User $user) => $this->userWasNotUpdated($user) ); } /** - * @param class-string $model * @param string $uniqBy * * @return void @@ -55,13 +45,11 @@ public function testBigChunkSize(string $model): void * * @dataProvider dataProvider */ - public function testSmallChunkSize(string $model, string $uniqBy): void + public function testSmallChunkSize(string $uniqBy): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->uniqueBy($uniqBy) ->chunk(2); @@ -71,12 +59,11 @@ public function testSmallChunkSize(string $model, string $uniqBy): void // assert $users->each( - fn (User $user) => $this->userWasUpdated($user) + fn(User $user) => $this->userWasUpdated($user) ); } /** - * @param class-string $model * @param string $uniqBy * * @return void @@ -85,13 +72,11 @@ public function testSmallChunkSize(string $model, string $uniqBy): void * * @dataProvider dataProvider */ - public function testSmallChunkSizeWithExtraCount(string $model, string $uniqBy): void + public function testSmallChunkSizeWithExtraCount(string $uniqBy): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(5); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(5); + $sut = User::query() ->bulk() ->uniqueBy($uniqBy) ->chunk($users->count() - 1); @@ -101,13 +86,12 @@ public function testSmallChunkSizeWithExtraCount(string $model, string $uniqBy): // assert $users->slice(0, $users->count() - 1)->each( - fn (User $user) => $this->userWasUpdated($user) + fn(User $user) => $this->userWasUpdated($user) ); $this->userWasNotUpdated($users->last()); } /** - * @param class-string $model * @param string $uniqBy * * @return void @@ -116,13 +100,11 @@ public function testSmallChunkSizeWithExtraCount(string $model, string $uniqBy): * * @dataProvider dataProvider */ - public function testSaveAccumulated(string $model, string $uniqBy): void + public function testSaveAccumulated(string $uniqBy): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->uniqueBy($uniqBy) ->updateOrAccumulate($users); @@ -132,37 +114,15 @@ public function testSaveAccumulated(string $model, string $uniqBy): void // assert $users->each( - fn (User $user) => $this->userWasUpdated($user) + fn(User $user) => $this->userWasUpdated($user) ); } - public function dataProvider(): array + public static function dataProvider(): array { - $target = [ + return [ 'email' => ['email'], 'id' => ['id'], ]; - - $result = []; - - foreach ($this->userModelsDataProvider() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model[0], - ...$value, - ]; - } - } - - return $result; - } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; } } diff --git a/tests/Unit/Bulk/Update/UpdateTest.php b/tests/Unit/Bulk/Update/UpdateTest.php index 57e64e1..bf936e6 100644 --- a/tests/Unit/Bulk/Update/UpdateTest.php +++ b/tests/Unit/Bulk/Update/UpdateTest.php @@ -1,26 +1,21 @@ $model * @param array|callable|string $uniqBy * * @return void @@ -29,13 +24,11 @@ final class UpdateTest extends TestCase * * @dataProvider dataProvider */ - public function testBase(string $model, array|string|callable $uniqBy): void + public function testBase(array|string|callable $uniqBy): void { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query() + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query() ->bulk() ->uniqueBy($uniqBy); @@ -44,22 +37,20 @@ public function testBase(string $model, array|string|callable $uniqBy): void // assert $users->each( - fn (User $user) => $this->userWasUpdated($user) + fn(User $user) => $this->userWasUpdated($user) ); } /** - * @param class-string $model * @param array|callable|string $uniqBy * * @return void * - * @throws JsonException * @throws BulkException - * + * @throws RandomException * @dataProvider dataProvider */ - public function testWithTimestamps(string $model, array|string|callable $uniqBy): void + public function testWithTimestamps(array|string|callable $uniqBy): void { // arrange $expectedCreatedAt = Carbon::now()->subSeconds( @@ -69,7 +60,6 @@ public function testWithTimestamps(string $model, array|string|callable $uniqBy) random_int(100, 100_000) ); $users = $this->userGenerator - ->setModel($model) ->createCollectionAndDirty(2) ->each( function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { @@ -77,7 +67,7 @@ function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { $user->setUpdatedAt($expectedUpdatedAt); } ); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy($uniqBy); @@ -100,21 +90,15 @@ function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { * If the Bulk gets models for updating, then their origins should be synced * even if the bulk does not have any listeners ending with "ed". * - * @param class-string $model - * * @return void * * @throws BulkException - * - * @dataProvider userModelsDataProvider */ - public function testIsDirtyAfterUpdating(string $model) + public function testIsDirtyAfterUpdating() { // arrange - $users = $this->userGenerator - ->setModel($model) - ->createCollectionAndDirty(2); - $sut = $model::query()->bulk(); + $users = $this->userGenerator->createCollectionAndDirty(2); + $sut = User::query()->bulk(); // act $sut->update($users); @@ -126,50 +110,17 @@ public function testIsDirtyAfterUpdating(string $model) } } - public function dataProvider(): array + public static function dataProvider(): array { - $target = [ + return [ 'email' => ['email'], '[email]' => [['email']], '[[email]]' => [[['email']]], - '() => email' => [fn () => 'email'], + '() => email' => [fn() => 'email'], 'id' => ['id'], '[id]' => [['id']], '[[id]]' => [['id']], - '() => id' => [fn () => 'id'], - ]; - - $result = []; - - foreach ($this->userModels() as $type => $model) { - foreach ($target as $key => $value) { - $result[$key . ' && ' . $type] = [ - $model, - ...$value, - ]; - } - } - - return $result; - } - - public function userModelsDataProvider(): array - { - $result = []; - - foreach ($this->userModels() as $key => $value) { - $result[$key] = [$value]; - } - - return $result; - } - - public function userModels(): array - { - return [ - 'mysql' => MySqlUser::class, - 'pgsql' => PostgreSqlUser::class, - 'sqlite' => SqLiteUser::class, + '() => id' => [fn() => 'id'], ]; } } diff --git a/tests/Unit/Bulk/Upsert/UpsertAndReturnTest.php b/tests/Unit/Bulk/Upsert/UpsertAndReturnTest.php index 6c7913a..59052c8 100644 --- a/tests/Unit/Bulk/Upsert/UpsertAndReturnTest.php +++ b/tests/Unit/Bulk/Upsert/UpsertAndReturnTest.php @@ -1,38 +1,33 @@ $model - * * @return void * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testDatabase(string $model): void + public function testDatabase(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -45,19 +40,14 @@ public function testDatabase(string $model): void } /** - * @param class-string $model - * * @return void - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testDatabaseCreateOnly(string $model): void + public function testDatabaseCreateOnly(): void { // arrange - $user = $this->userGenerator - ->setModel($model) - ->makeOne(); - $sut = $model::query() + $user = $this->userGenerator->makeOne(); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -69,19 +59,15 @@ public function testDatabaseCreateOnly(string $model): void } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testDatabaseUpdateOnly(string $model): void + public function testDatabaseUpdateOnly(): void { // arrange - $user = $this->userGenerator - ->setModel($model) - ->createOneAndDirty(); - $sut = $model::query() + $user = $this->userGenerator->createOneAndDirty(); + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -93,21 +79,17 @@ public function testDatabaseUpdateOnly(string $model): void } /** - * @param class-string $model - * * @return void - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testResult(string $model): void + public function testResult(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -126,20 +108,16 @@ public function testResult(string $model): void } /** - * @param class-string $model - * * @return void - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testResultCreateOnly(string $model): void + public function testResultCreateOnly(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -156,20 +134,16 @@ public function testResultCreateOnly(string $model): void } /** - * @param class-string $model - * * @return void - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testResultUpdateOnly(string $model): void + public function testResultUpdateOnly(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -184,13 +158,4 @@ public function testResultUpdateOnly(string $model): void $this->returnedUserWasUpserted($users->get(0), $result->get(0)); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/Upsert/UpsertOrAccumulateTest.php b/tests/Unit/Bulk/Upsert/UpsertOrAccumulateTest.php index 5fda261..ecf69f2 100644 --- a/tests/Unit/Bulk/Upsert/UpsertOrAccumulateTest.php +++ b/tests/Unit/Bulk/Upsert/UpsertOrAccumulateTest.php @@ -1,41 +1,33 @@ $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testBigChunkSize(string $model): void + public function testBigChunkSize(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -48,23 +40,18 @@ public function testBigChunkSize(string $model): void } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testSmallChunkSize(string $model): void + public function testSmallChunkSize(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->chunk($users->count()); @@ -78,25 +65,20 @@ public function testSmallChunkSize(string $model): void } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testSmallChunkSizeWithExtraCount(string $model): void + public function testSmallChunkSizeWithExtraCount(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->chunk($users->count() - 1); @@ -112,23 +94,18 @@ public function testSmallChunkSizeWithExtraCount(string $model): void } /** - * @param class-string $model - * * @return void * - * @dataProvider userModelsDataProvider - * * @throws BulkException */ - public function testSaveAccumulated(string $model): void + public function testSaveAccumulated(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']) ->upsertOrAccumulate($users); @@ -140,13 +117,4 @@ public function testSaveAccumulated(string $model): void $this->userWasUpdated($users->get(0)); $this->userWasCreated($users->get(1)); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/Bulk/Upsert/UpsertTest.php b/tests/Unit/Bulk/Upsert/UpsertTest.php index 0d9d573..b5d6843 100644 --- a/tests/Unit/Bulk/Upsert/UpsertTest.php +++ b/tests/Unit/Bulk/Upsert/UpsertTest.php @@ -1,40 +1,33 @@ $model - * * @return void - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testBase(string $model): void + public function testBase(): void { // arrange - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), ]); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -47,15 +40,12 @@ public function testBase(string $model): void } /** - * @param class-string $model - * * @return void * - * @throws JsonException - * - * @dataProvider userModelsDataProvider + * @throws BulkException + * @throws RandomException */ - public function testWithTimestamps(string $model): void + public function testWithTimestamps(): void { // arrange $expectedCreatedAt = Carbon::now()->subSeconds( @@ -64,7 +54,6 @@ public function testWithTimestamps(string $model): void $expectedUpdatedAt = Carbon::now()->subSeconds( random_int(100, 100_000) ); - $this->userGenerator->setModel($model); $users = new UserCollection([ $this->userGenerator->createOneAndDirty(), $this->userGenerator->makeOne(), @@ -75,7 +64,7 @@ function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { $user->setUpdatedAt($expectedUpdatedAt); } ); - $sut = $model::query() + $sut = User::query() ->bulk() ->uniqueBy(['email']); @@ -93,13 +82,4 @@ function (User $user) use ($expectedCreatedAt, $expectedUpdatedAt): void { } ); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'pgsql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/BulkAccumulationEntityTestTrait.php b/tests/Unit/BulkAccumulationEntityTestTrait.php index 2028d69..5bd759e 100644 --- a/tests/Unit/BulkAccumulationEntityTestTrait.php +++ b/tests/Unit/BulkAccumulationEntityTestTrait.php @@ -1,6 +1,6 @@ $model - * * @return void * - * @throws JsonException - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testWithoutEvents(string $model): void + public function testWithoutEvents(): void { // arrange - $this->userGenerator->setModel($model); $users = $this->userGenerator->createCollection(2); $fakeUser = $this->userGenerator->makeOne(); $values = [ @@ -44,7 +36,7 @@ public function testWithoutEvents(string $model): void 'phones' => $fakeUser->phones, 'last_visited_at' => $fakeUser->last_visited_at?->toDateTimeString(), ]; - $sut = $model::query() + $sut = User::query() ->whereIn('email', $users->pluck('email')); // act @@ -74,18 +66,13 @@ function (User $user) use ($values) { } /** - * @param class-string $model - * * @return void * - * @throws JsonException - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testWithEventsById(string $model): void + public function testWithEventsById(): void { // arrange - $this->userGenerator->setModel($model); $users = $this->userGenerator->createCollection(10); $fakeUser = $this->userGenerator->makeOne(); $values = [ @@ -99,8 +86,8 @@ public function testWithEventsById(string $model): void 'phones' => $fakeUser->phones, 'last_visited_at' => $fakeUser->last_visited_at?->toDateTimeString(), ]; - $model::observe(Observer::class); - $sut = $model::query() + User::observe(Observer::class); + $sut = User::query() ->whereIn('email', $users->pluck('email')); // act @@ -130,18 +117,13 @@ function (User $user) use ($values) { } /** - * @param class-string $model - * * @return void * - * @throws JsonException - * - * @dataProvider userModelsDataProvider + * @throws BulkException */ - public function testWithEventsByEmail(string $model): void + public function testWithEventsByEmail(): void { // arrange - $this->userGenerator->setModel($model); $users = $this->userGenerator->createCollection(10); $fakeUser = $this->userGenerator->makeOne(); $values = [ @@ -155,8 +137,8 @@ public function testWithEventsByEmail(string $model): void 'phones' => $fakeUser->phones, 'last_visited_at' => $fakeUser->last_visited_at?->toDateTimeString(), ]; - $model::observe(Observer::class); - $sut = $model::query() + User::observe(Observer::class); + $sut = User::query() ->whereIn('email', $users->pluck('email')); // act @@ -184,13 +166,4 @@ function (User $user) use ($values) { } ); } - - public function userModelsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class], - 'psql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } } diff --git a/tests/Unit/CommentTestTrait.php b/tests/Unit/CommentTestTrait.php deleted file mode 100644 index 968e305..0000000 --- a/tests/Unit/CommentTestTrait.php +++ /dev/null @@ -1,47 +0,0 @@ - [MySqlComment::class], - 'psql' => [PostgreSqlComment::class], - 'sqlite' => [SqLiteComment::class], - ]; - } - - protected function makeCommentCollection(string $model, int $count, array $data = []): CommentCollection - { - return call_user_func([$model, 'factory'])->count($count)->make($data); - } - - protected function createCommentCollection(string $model, int $count, array $data = []): CommentCollection - { - return call_user_func([$model, 'factory'])->count($count)->create($data); - } - - protected function createDirtyCommentCollection(string $model, int $count, array $data = []): CommentCollection - { - $users = $this->createCommentCollection($model, $count); - $result = $this->makeCommentCollection($model, $count, $data); - - foreach ($result as $key => $user) { - $user->email = $users->get($key)->email; - } - - return $result; - } -} diff --git a/tests/Unit/ModelListenerTestTrait.php b/tests/Unit/ModelListenerTestTrait.php index f002ad4..1785b78 100644 --- a/tests/Unit/ModelListenerTestTrait.php +++ b/tests/Unit/ModelListenerTestTrait.php @@ -1,12 +1,12 @@ listen($event, $result); @@ -39,7 +40,8 @@ protected function makeModelListenerWithReturningValue( string $event, BulkEventDispatcher $eventDispatcher, mixed $returningValue, - ): LegacyMockInterface|MockInterface { + ): LegacyMockInterface|MockInterface + { $result = Mockery::spy(TestCallback::class); $result->expects('__invoke') ->zeroOrMoreTimes() diff --git a/tests/Unit/Scenarios/CreateScenario/CreatedEventTest.php b/tests/Unit/Scenarios/CreateScenario/CreatedEventTest.php index 4c9d7ba..0ba619d 100644 --- a/tests/Unit/Scenarios/CreateScenario/CreatedEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/CreatedEventTest.php @@ -1,13 +1,14 @@ makeSimpleModelListener(BulkEventEnum::CREATED, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->times($users->count()); + self::spyShouldHaveReceived($listener)->times($users->count()); } /** * The listener for the 'created' event should receive only one argument, which must be the model. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::CREATED, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertModelListenerArguments($users, ...func_get_args()) + fn() => $this->assertModelListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/CreatedManyEventTest.php b/tests/Unit/Scenarios/CreateScenario/CreatedManyEventTest.php index b529618..c1f9c3b 100644 --- a/tests/Unit/Scenarios/CreateScenario/CreatedManyEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/CreatedManyEventTest.php @@ -1,13 +1,14 @@ makeSimpleModelListener(BulkEventEnum::CREATED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->once(); + self::spyShouldHaveReceived($listener)->once(); } /** * The listener for the 'createdMany' event should receive two arguments: * the model and an object of the BulkRows class. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::CREATED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertCollectionListenerArguments($users, ...func_get_args()) + fn() => $this->assertCollectionListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/CreatingEventTest.php b/tests/Unit/Scenarios/CreateScenario/CreatingEventTest.php index d680733..f61f9e8 100644 --- a/tests/Unit/Scenarios/CreateScenario/CreatingEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/CreatingEventTest.php @@ -1,14 +1,14 @@ makeSimpleModelListener(BulkEventEnum::CREATING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->times($users->count()); + self::spyShouldHaveReceived($listener)->times($users->count()); } /** @@ -55,47 +51,43 @@ public function testTriggering(string $userModel): void public function testNotTriggeringWhenSavingReturnedFalse(string $previousEventName): void { // arrange - $eventDispatcher = new BulkEventDispatcher(MySqlUser::class); + $eventDispatcher = new BulkEventDispatcher(User::class); $this->makeModelListenerWithReturningValue( $previousEventName, $eventDispatcher, [false, false] ); $creatingListener = $this->makeSimpleModelListener(BulkEventEnum::CREATING, $eventDispatcher); - $users = $this->makeUserCollection(MySqlUser::class, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldNotHaveReceived($creatingListener); + self::spyShouldNotHaveReceived($creatingListener); } /** * The listener for the 'creating' event should receive only one argument, which must be the model. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::CREATING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertModelListenerArguments($users, ...func_get_args()) + fn() => $this->assertModelListenerArguments($users, ...func_get_args()) ); } @@ -104,7 +96,7 @@ public function testListenerArguments(string $userModel): void * * @return array[] */ - public function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array + public static function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array { return [ 'saving' => [BulkEventEnum::SAVING], diff --git a/tests/Unit/Scenarios/CreateScenario/CreatingManyEventTest.php b/tests/Unit/Scenarios/CreateScenario/CreatingManyEventTest.php index 508e3c7..d13fef7 100644 --- a/tests/Unit/Scenarios/CreateScenario/CreatingManyEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/CreatingManyEventTest.php @@ -1,14 +1,14 @@ makeSimpleModelListener(BulkEventEnum::CREATING_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->once(); + self::spyShouldHaveReceived($listener)->once(); } /** @@ -55,48 +51,44 @@ public function testTriggering(string $userModel): void public function testNotTriggeringWhenPreviousListenerReturnedFalse(string $previousEventName): void { // arrange - $eventDispatcher = new BulkEventDispatcher(MySqlUser::class); + $eventDispatcher = new BulkEventDispatcher(User::class); $this->makeModelListenerWithReturningValue( $previousEventName, $eventDispatcher, [false, false] ); $creatingManyListener = $this->makeSimpleModelListener(BulkEventEnum::CREATING_MANY, $eventDispatcher); - $users = $this->makeUserCollection(MySqlUser::class, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldNotHaveReceived($creatingManyListener); + self::spyShouldNotHaveReceived($creatingManyListener); } /** * The listener for the 'creatingMany' event should receive two arguments: * the model and an object of the BulkRows class. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::CREATING_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertCollectionListenerArguments($users, ...func_get_args()) + fn() => $this->assertCollectionListenerArguments($users, ...func_get_args()) ); } @@ -105,7 +97,7 @@ public function testListenerArguments(string $userModel): void * * @return array[] */ - public function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array + public static function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array { return [ 'saving' => [BulkEventEnum::SAVING], diff --git a/tests/Unit/Scenarios/CreateScenario/DeletedEventTest.php b/tests/Unit/Scenarios/CreateScenario/DeletedEventTest.php index bdd730c..6ec0267 100644 --- a/tests/Unit/Scenarios/CreateScenario/DeletedEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/DeletedEventTest.php @@ -1,14 +1,15 @@ makeSimpleModelListener(BulkEventEnum::DELETED, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener)->times($users->count()); + self::spyShouldHaveReceived($listener)->times($users->count()); } /** * The listener for the 'deleted' event should receive only one argument, which must be the model. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::DELETED, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertModelListenerArguments($users, ...func_get_args()) + fn() => $this->assertModelListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/DeletedManyEventTest.php b/tests/Unit/Scenarios/CreateScenario/DeletedManyEventTest.php index 059bdb6..0bab16e 100644 --- a/tests/Unit/Scenarios/CreateScenario/DeletedManyEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/DeletedManyEventTest.php @@ -1,14 +1,15 @@ makeSimpleModelListener(BulkEventEnum::DELETED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener)->once(); + self::spyShouldHaveReceived($listener)->once(); } /** * The listener for the 'deletedMany' event should receive two arguments: * the model and an object of the BulkRows class. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::DELETED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertCollectionListenerArguments($users, ...func_get_args()) + fn() => $this->assertCollectionListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/DeletingEventTest.php b/tests/Unit/Scenarios/CreateScenario/DeletingEventTest.php index b8e9087..59655c6 100644 --- a/tests/Unit/Scenarios/CreateScenario/DeletingEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/DeletingEventTest.php @@ -1,15 +1,15 @@ makeSimpleModelListener(BulkEventEnum::DELETING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener)->times($users->count()); + self::spyShouldHaveReceived($listener)->times($users->count()); } /** * If the model has a listener for the 'deleting' event, but 'deleted_at' is not filled in, then this listener should not be invoked. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testNotTriggeringWhenDeletedAtIsNull(string $userModel): void + public function testNotTriggeringWhenDeletedAtIsNull(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::DELETING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => null]); + $users = User::factory()->count(2)->make(['deleted_at' => null]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldNotHaveReceived($listener); + self::spyShouldNotHaveReceived($listener); } /** @@ -80,47 +72,43 @@ public function testNotTriggeringWhenDeletedAtIsNull(string $userModel): void public function testNotTriggeringWhenSavingReturnedFalse(string $previousEventName): void { // arrange - $eventDispatcher = new BulkEventDispatcher(MySqlUser::class); + $eventDispatcher = new BulkEventDispatcher(User::class); $this->makeModelListenerWithReturningValue( $previousEventName, $eventDispatcher, [false, false] ); $deletingListener = $this->makeSimpleModelListener(BulkEventEnum::DELETING, $eventDispatcher); - $users = $this->makeUserCollection(MySqlUser::class, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldNotHaveReceived($deletingListener); + self::spyShouldNotHaveReceived($deletingListener); } /** * The listener for the 'deleting' event should receive only one argument, which must be the model. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::DELETING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertModelListenerArguments($users, ...func_get_args()) + fn() => $this->assertModelListenerArguments($users, ...func_get_args()) ); } @@ -129,7 +117,7 @@ public function testListenerArguments(string $userModel): void * * @return array[] */ - public function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array + public static function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array { return [ 'saving' => [BulkEventEnum::SAVING], diff --git a/tests/Unit/Scenarios/CreateScenario/DeletingManyEventTest.php b/tests/Unit/Scenarios/CreateScenario/DeletingManyEventTest.php index 20d6607..9380a2f 100644 --- a/tests/Unit/Scenarios/CreateScenario/DeletingManyEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/DeletingManyEventTest.php @@ -1,15 +1,15 @@ makeSimpleModelListener(BulkEventEnum::DELETING_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener)->once(); + self::spyShouldHaveReceived($listener)->once(); } /** * If the model has a listener for the 'deletingMany' event, but 'deleted_at' is not filled in, * then this listener should not be invoked. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testNotTriggeringWhenDeletedAtIsNull(string $userModel): void + public function testNotTriggeringWhenDeletedAtIsNull(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::DELETED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => null]); + $users = User::factory()->count(2)->make(['deleted_at' => null]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldNotHaveReceived($listener); + self::spyShouldNotHaveReceived($listener); } /** @@ -81,48 +73,44 @@ public function testNotTriggeringWhenDeletedAtIsNull(string $userModel): void public function testNotTriggeringWhenPreviousListenerReturnedFalse(string $previousEventName): void { // arrange - $eventDispatcher = new BulkEventDispatcher(MySqlUser::class); + $eventDispatcher = new BulkEventDispatcher(User::class); $this->makeModelListenerWithReturningValue( $previousEventName, $eventDispatcher, [false, false] ); $deletingManyListener = $this->makeSimpleModelListener(BulkEventEnum::DELETING_MANY, $eventDispatcher); - $users = $this->makeUserCollection(MySqlUser::class, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldNotHaveReceived($deletingManyListener); + self::spyShouldNotHaveReceived($deletingManyListener); } /** * The listener for the 'deletingMany' event should receive two arguments: * the model and an object of the BulkRows class. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::DELETING_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2, ['deleted_at' => Carbon::now()]); + $users = User::factory()->count(2)->make(['deleted_at' => Carbon::now()]); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher, deletedAtColumn: 'deleted_at'); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertCollectionListenerArguments($users, ...func_get_args()) + fn() => $this->assertCollectionListenerArguments($users, ...func_get_args()) ); } @@ -131,7 +119,7 @@ public function testListenerArguments(string $userModel): void * * @return array[] */ - public function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array + public static function notTriggeringWhenPreviousListenerReturnedFalseDataProvider(): array { return [ 'saving' => [BulkEventEnum::SAVING], diff --git a/tests/Unit/Scenarios/CreateScenario/InsertTest.php b/tests/Unit/Scenarios/CreateScenario/InsertTest.php index 6c3c73f..56f8f78 100644 --- a/tests/Unit/Scenarios/CreateScenario/InsertTest.php +++ b/tests/Unit/Scenarios/CreateScenario/InsertTest.php @@ -1,15 +1,14 @@ makeUserCollection($userModel, 2); + $eventDispatcher = new BulkEventDispatcher(User::class); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act @@ -49,18 +43,14 @@ public function testSuccessfully(string $userModel): void * If any of the rows already exist in the database, the request should trigger a PDOException, * and none of the rows should be updated. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testDuplicate(string $userModel): void + public function testDuplicate(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); - $existingUser = $this->createUser($userModel); - $users = $this->makeUserCollection($userModel, 2); + $eventDispatcher = new BulkEventDispatcher(User::class); + $existingUser = User::factory()->create(); + $users = User::factory()->count(2)->make(); $users->get(0)->email = $existingUser->email; $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); @@ -83,18 +73,14 @@ public function testDuplicate(string $userModel): void * If any of the rows already exist in the database and the 'ignoring' flag is set to true, * the request should not trigger a PDOException, and new rows should be inserted. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testDuplicateWithIgnoring(string $userModel): void + public function testDuplicateWithIgnoring(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); - $existingUser = $this->createUser($userModel); - $users = $this->makeUserCollection($userModel, 2); + $eventDispatcher = new BulkEventDispatcher(User::class); + $existingUser = User::factory()->create(); + $users = User::factory()->count(2)->make(); $users->get(0)->email = $existingUser->email; $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); @@ -111,20 +97,16 @@ public function testDuplicateWithIgnoring(string $userModel): void * After creation, the 'wasRecentlyCreated' flag must be set to true * if the model has the 'incrementing' flag set to true. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testFlagWasRecentlyCreatedWithIncrementing(string $userModel): void + public function testFlagWasRecentlyCreatedWithIncrementing(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $eventDispatcher->listen(BulkEventEnum::SAVED, function (User $user) { self::assertTrue($user->wasRecentlyCreated); }); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act @@ -135,22 +117,16 @@ public function testFlagWasRecentlyCreatedWithIncrementing(string $userModel): v * After creation, the 'wasRecentlyCreated' flag must be set to true * if the model has the 'incrementing' flag set to false. * - * @param string $storyModel - * - * @psalm-param class-string $storyModel - * * @return void - * - * @dataProvider storyModelsDataProvider */ - public function testFlagWasRecentlyCreatedWithoutIncrementing(string $storyModel): void + public function testFlagWasRecentlyCreatedWithoutIncrementing(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($storyModel); + $eventDispatcher = new BulkEventDispatcher(Story::class); $eventDispatcher->listen(BulkEventEnum::SAVED, function (Story $story) { self::assertTrue($story->wasRecentlyCreated); }); - $stories = $this->makeStoryCollection($storyModel, 2); + $stories = Story::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($stories, ['uuid']); // act diff --git a/tests/Unit/Scenarios/CreateScenario/SavedEventTest.php b/tests/Unit/Scenarios/CreateScenario/SavedEventTest.php index de1f37b..b8443b3 100644 --- a/tests/Unit/Scenarios/CreateScenario/SavedEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/SavedEventTest.php @@ -1,13 +1,14 @@ makeSimpleModelListener(BulkEventEnum::SAVED, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->times($users->count()); + self::spyShouldHaveReceived($listener)->times($users->count()); } /** * The listener for the 'saved' event should receive only one argument, which must be the model. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::SAVED, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertModelListenerArguments($users, ...func_get_args()) + fn() => $this->assertModelListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/SavedManyEventTest.php b/tests/Unit/Scenarios/CreateScenario/SavedManyEventTest.php index e52b8af..fb84299 100644 --- a/tests/Unit/Scenarios/CreateScenario/SavedManyEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/SavedManyEventTest.php @@ -1,13 +1,14 @@ makeSimpleModelListener(BulkEventEnum::SAVED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->once(); + self::spyShouldHaveReceived($listener)->once(); } /** * The listener for the 'savedMany' event should receive two arguments: * the model and an object of the BulkRows class. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::SAVED_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertCollectionListenerArguments($users, ...func_get_args()) + fn() => $this->assertCollectionListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/SavingEventTest.php b/tests/Unit/Scenarios/CreateScenario/SavingEventTest.php index e19867d..734979d 100644 --- a/tests/Unit/Scenarios/CreateScenario/SavingEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/SavingEventTest.php @@ -1,13 +1,14 @@ makeSimpleModelListener(BulkEventEnum::SAVING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->times($users->count()); + self::spyShouldHaveReceived($listener)->times($users->count()); } /** * The listener for the 'saving' event should receive only one argument, which must be the model. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::SAVING, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertModelListenerArguments($users, ...func_get_args()) + fn() => $this->assertModelListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/SavingManyEventTest.php b/tests/Unit/Scenarios/CreateScenario/SavingManyEventTest.php index d7d8bd5..b6bf6be 100644 --- a/tests/Unit/Scenarios/CreateScenario/SavingManyEventTest.php +++ b/tests/Unit/Scenarios/CreateScenario/SavingManyEventTest.php @@ -1,13 +1,14 @@ makeSimpleModelListener(BulkEventEnum::SAVING_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener)->once(); + self::spyShouldHaveReceived($listener)->once(); } /** * The listener for the 'savingMany' event should receive two arguments: * the model and an object of the BulkRows class. * - * @param string $userModel - * * @return void - * - * @dataProvider userModelsDataProvider */ - public function testListenerArguments(string $userModel): void + public function testListenerArguments(): void { // arrange - $eventDispatcher = new BulkEventDispatcher($userModel); + $eventDispatcher = new BulkEventDispatcher(User::class); $listener = $this->makeSimpleModelListener(BulkEventEnum::SAVING_MANY, $eventDispatcher); - $users = $this->makeUserCollection($userModel, 2); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); // act $this->handleCreateScenario($data, $eventDispatcher); // assert - $this->spyShouldHaveReceived($listener) + self::spyShouldHaveReceived($listener) ->withArgs( - fn () => $this->assertCollectionListenerArguments($users, ...func_get_args()) + fn() => $this->assertCollectionListenerArguments($users, ...func_get_args()) ); } } diff --git a/tests/Unit/Scenarios/CreateScenario/SyncOriginalTest.php b/tests/Unit/Scenarios/CreateScenario/SyncOriginalTest.php index 451b306..5a88679 100644 --- a/tests/Unit/Scenarios/CreateScenario/SyncOriginalTest.php +++ b/tests/Unit/Scenarios/CreateScenario/SyncOriginalTest.php @@ -1,14 +1,15 @@ makeUserCollection($userModel, 2); + $eventDispatcher = new BulkEventDispatcher(User::class); + $users = User::factory()->count(2)->make(); $data = $this->getBulkAccumulationEntityFromCollection($users, ['email']); $usersFromEvent = null; $eventDispatcher->listen( diff --git a/tests/Unit/Scenarios/CreateScenario/TouchRelationsTest.php b/tests/Unit/Scenarios/CreateScenario/TouchRelationsTest.php index 5a8c421..907fe84 100644 --- a/tests/Unit/Scenarios/CreateScenario/TouchRelationsTest.php +++ b/tests/Unit/Scenarios/CreateScenario/TouchRelationsTest.php @@ -1,26 +1,15 @@ $userModel - * - * @param string $commentModel - * - * @psalm-param class-string $commentModel - * - * @param string $articleModel - * - * @psalm-param class-string
$articleModel - * * @return void - * - * @dataProvider connectionsDataProvider */ - public function test(string $userModel, string $commentModel, string $articleModel): void + public function test(): void { // arrange Carbon::setTestNow(Carbon::now()->startOfSecond()); - $user = $this->createUser($userModel, [ + $user = User::factory()->create([ 'created_at' => Carbon::parse('2020-01-02 03:04:05'), 'updated_at' => Carbon::parse('2020-01-02 03:04:05'), ]); - $articles = $this->createArticleCollection($articleModel, 2, [ + $articles = Article::factory()->count(2)->create([ 'user_id' => $user->id, 'created_at' => Carbon::parse('2020-01-02 03:04:05')->toDateTimeString(), 'updated_at' => Carbon::parse('2020-01-02 03:04:05')->toDateTimeString(), ]); - $eventDispatcher = new BulkEventDispatcher($commentModel); - $comments = $this->makeCommentCollection($commentModel, 2, [ + $eventDispatcher = new BulkEventDispatcher(Comment::class); + $comments = Comment::factory()->count(2)->make([ 'user_id' => $user->id, ]); $data = $this->getBulkAccumulationEntityFromCollection($comments, ['user_id', 'text']); @@ -101,18 +74,4 @@ public function test(string $userModel, string $commentModel, string $articleMod ); } } - - /** - * Data provider. - * - * @return array[] - */ - public function connectionsDataProvider(): array - { - return [ - 'mysql' => [MySqlUser::class, MySqlComment::class, MySqlArticle::class], - 'pgsql' => [PostgreSqlUser::class, PostgreSqlComment::class, PostgreSqlArticle::class], - 'sqlite' => [SqLiteUser::class, SqLiteComment::class, SqLiteArticle::class], - ]; - } } diff --git a/tests/Unit/Scenarios/CreateScenarioTestCase.php b/tests/Unit/Scenarios/CreateScenarioTestCase.php index 3d94d70..1a4d293 100644 --- a/tests/Unit/Scenarios/CreateScenarioTestCase.php +++ b/tests/Unit/Scenarios/CreateScenarioTestCase.php @@ -1,13 +1,13 @@ getFromContainer(CreateScenario::class); diff --git a/tests/Unit/StoryTestTrait.php b/tests/Unit/StoryTestTrait.php deleted file mode 100644 index 7f7ea75..0000000 --- a/tests/Unit/StoryTestTrait.php +++ /dev/null @@ -1,47 +0,0 @@ - [MySqlStory::class], - 'psql' => [PostgreSqlStory::class], - 'sqlite' => [SqLiteStory::class], - ]; - } - - protected function makeStoryCollection(string $model, int $count, array $data = []): StoryCollection - { - return call_user_func([$model, 'factory'])->count($count)->make($data); - } - - protected function createStoryCollection(string $model, int $count, array $data = []): StoryCollection - { - return call_user_func([$model, 'factory'])->count($count)->create($data); - } - - protected function createDirtyStoryCollection(string $model, int $count, array $data = []): StoryCollection - { - $users = $this->createStoryCollection($model, $count); - $result = $this->makeStoryCollection($model, $count, $data); - - foreach ($result as $key => $user) { - $user->email = $users->get($key)->email; - } - - return $result; - } -} diff --git a/tests/Unit/UserTestTrait.php b/tests/Unit/UserTestTrait.php index 2b90c5b..2529308 100644 --- a/tests/Unit/UserTestTrait.php +++ b/tests/Unit/UserTestTrait.php @@ -1,15 +1,11 @@ [MySqlUser::class], - 'psql' => [PostgreSqlUser::class], - 'sqlite' => [SqLiteUser::class], - ]; - } - protected function userWasCreated(User $user): void { self::assertDatabaseHas($user->getTable(), [ @@ -161,31 +143,4 @@ protected function returnedUserWasUpserted(User $expect, User $actual): void self::assertEquals($expect->deleted_at, $actual->deleted_at); self::assertTrue($actual->id > 0); } - - protected function makeUserCollection(string $model, int $count, array $data = []): UserCollection - { - return call_user_func([$model, 'factory'])->count($count)->make($data); - } - - protected function createUserCollection(string $model, int $count, array $data = []): UserCollection - { - return call_user_func([$model, 'factory'])->count($count)->create($data); - } - - protected function createDirtyUserCollection(string $model, int $count, array $data = []): UserCollection - { - $users = $this->createUserCollection($model, $count); - $result = $this->makeUserCollection($model, $count, $data); - - foreach ($result as $key => $user) { - $user->email = $users->get($key)->email; - } - - return $result; - } - - protected function createUser(string $model, array $data = []): User - { - return call_user_func([$model, 'factory'])->create($data); - } } diff --git a/tests/app/Factories/ArticleFactory.php b/tests/app/Factories/ArticleFactory.php deleted file mode 100644 index 0c70ffd..0000000 --- a/tests/app/Factories/ArticleFactory.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ - public function definition(): array - { - return [ - 'uuid' => $this->faker->uuid(), - 'title' => $this->faker->text(50), - ]; - } -} diff --git a/tests/app/Factories/CommentFactory.php b/tests/app/Factories/CommentFactory.php deleted file mode 100644 index 8b3d6e8..0000000 --- a/tests/app/Factories/CommentFactory.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ - public function definition(): array - { - return [ - 'user_id' => PostgreSqlUser::factory(), - 'post_id' => PostgreSqlPost::factory(), - 'text' => $this->faker->text(), - ]; - } -} diff --git a/tests/app/Factories/MySqlArticleFactory.php b/tests/app/Factories/MySqlArticleFactory.php deleted file mode 100644 index 00c6528..0000000 --- a/tests/app/Factories/MySqlArticleFactory.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ - protected $model = MySqlArticle::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return array_merge(parent::definition(), [ - 'user_id' => MySqlUser::factory(), - ]); - } -} diff --git a/tests/app/Factories/MySqlCommentFactory.php b/tests/app/Factories/MySqlCommentFactory.php deleted file mode 100644 index 4bfd648..0000000 --- a/tests/app/Factories/MySqlCommentFactory.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ - protected $model = MySqlComment::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return array_merge(parent::definition(), [ - 'user_id' => MySqlUser::factory(), - 'post_id' => MySqlPost::factory(), - ]); - } -} diff --git a/tests/app/Factories/MySqlPostFactory.php b/tests/app/Factories/MySqlPostFactory.php deleted file mode 100644 index 1eb9dfe..0000000 --- a/tests/app/Factories/MySqlPostFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = MySqlPost::class; -} diff --git a/tests/app/Factories/MySqlStoryFactory.php b/tests/app/Factories/MySqlStoryFactory.php deleted file mode 100644 index cd81180..0000000 --- a/tests/app/Factories/MySqlStoryFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = MySqlStory::class; -} diff --git a/tests/app/Factories/MySqlUserFactory.php b/tests/app/Factories/MySqlUserFactory.php deleted file mode 100644 index 774b983..0000000 --- a/tests/app/Factories/MySqlUserFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = MySqlUser::class; -} diff --git a/tests/app/Factories/PostgreSqlArticleFactory.php b/tests/app/Factories/PostgreSqlArticleFactory.php deleted file mode 100644 index 7d15664..0000000 --- a/tests/app/Factories/PostgreSqlArticleFactory.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ - protected $model = PostgreSqlArticle::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return array_merge(parent::definition(), [ - 'user_id' => PostgreSqlUser::factory(), - ]); - } -} diff --git a/tests/app/Factories/PostgreSqlCommentFactory.php b/tests/app/Factories/PostgreSqlCommentFactory.php deleted file mode 100644 index a0c3282..0000000 --- a/tests/app/Factories/PostgreSqlCommentFactory.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ - protected $model = PostgreSqlComment::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return array_merge(parent::definition(), [ - 'user_id' => PostgreSqlUser::factory(), - 'post_id' => PostgreSqlPost::factory(), - ]); - } -} diff --git a/tests/app/Factories/PostgreSqlPostFactory.php b/tests/app/Factories/PostgreSqlPostFactory.php deleted file mode 100644 index 0d0418c..0000000 --- a/tests/app/Factories/PostgreSqlPostFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = PostgreSqlPost::class; -} diff --git a/tests/app/Factories/PostgreSqlStoryFactory.php b/tests/app/Factories/PostgreSqlStoryFactory.php deleted file mode 100644 index 12de500..0000000 --- a/tests/app/Factories/PostgreSqlStoryFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = PostgreSqlStory::class; -} diff --git a/tests/app/Factories/PostgreSqlUserFactory.php b/tests/app/Factories/PostgreSqlUserFactory.php deleted file mode 100644 index c9ec2fa..0000000 --- a/tests/app/Factories/PostgreSqlUserFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = PostgreSqlUser::class; -} diff --git a/tests/app/Factories/SqLiteArticleFactory.php b/tests/app/Factories/SqLiteArticleFactory.php deleted file mode 100644 index 237a2fa..0000000 --- a/tests/app/Factories/SqLiteArticleFactory.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ - protected $model = SqLiteArticle::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return array_merge(parent::definition(), [ - 'user_id' => SqLiteUser::factory(), - ]); - } -} diff --git a/tests/app/Factories/SqLiteCommentFactory.php b/tests/app/Factories/SqLiteCommentFactory.php deleted file mode 100644 index 9f5d3ae..0000000 --- a/tests/app/Factories/SqLiteCommentFactory.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ - protected $model = SqLiteComment::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return array_merge(parent::definition(), [ - 'user_id' => SqLiteUser::factory(), - 'post_id' => SqLitePost::factory(), - ]); - } -} diff --git a/tests/app/Factories/SqLitePostFactory.php b/tests/app/Factories/SqLitePostFactory.php deleted file mode 100644 index dd51131..0000000 --- a/tests/app/Factories/SqLitePostFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = SqLitePost::class; -} diff --git a/tests/app/Factories/SqLiteStoryFactory.php b/tests/app/Factories/SqLiteStoryFactory.php deleted file mode 100644 index 2916415..0000000 --- a/tests/app/Factories/SqLiteStoryFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = SqLiteStory::class; -} diff --git a/tests/app/Factories/SqLiteUserFactory.php b/tests/app/Factories/SqLiteUserFactory.php deleted file mode 100644 index ab78316..0000000 --- a/tests/app/Factories/SqLiteUserFactory.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - protected $model = SqLiteUser::class; -} diff --git a/tests/app/Factories/StoryFactory.php b/tests/app/Factories/StoryFactory.php deleted file mode 100644 index bbeb6cd..0000000 --- a/tests/app/Factories/StoryFactory.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - public function definition(): array - { - return [ - 'uuid' => $this->faker->uuid(), - 'title' => $this->faker->text(50), - 'content' => $this->faker->text(200), - ]; - } -} diff --git a/tests/app/Models/MySqlArticle.php b/tests/app/Models/MySqlArticle.php deleted file mode 100644 index f5f1e42..0000000 --- a/tests/app/Models/MySqlArticle.php +++ /dev/null @@ -1,26 +0,0 @@ -belongsTo(MySqlUser::class); - } - - public static function newFactory(): MySqlArticleFactory - { - return new MySqlArticleFactory(); - } -} diff --git a/tests/app/Models/MySqlComment.php b/tests/app/Models/MySqlComment.php deleted file mode 100644 index c8ec3b0..0000000 --- a/tests/app/Models/MySqlComment.php +++ /dev/null @@ -1,38 +0,0 @@ -belongsTo(MySqlUser::class, 'user_id'); - } - - public function post(): BelongsTo|PostBuilder - { - return $this->belongsTo(MySqlPost::class, 'post_id', 'id'); - } - - public static function newFactory(): MySqlCommentFactory - { - return new MySqlCommentFactory(); - } -} diff --git a/tests/app/Models/MySqlPost.php b/tests/app/Models/MySqlPost.php deleted file mode 100644 index 0a4efc5..0000000 --- a/tests/app/Models/MySqlPost.php +++ /dev/null @@ -1,30 +0,0 @@ -hasMany(MySqlComment::class, 'post_id', 'id'); - } - - public static function newFactory(): MySqlPostFactory - { - return new MySqlPostFactory(); - } -} diff --git a/tests/app/Models/MySqlStory.php b/tests/app/Models/MySqlStory.php deleted file mode 100644 index 9e1339e..0000000 --- a/tests/app/Models/MySqlStory.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMany(MySqlComment::class, 'user_id'); - } - - public function articles(): HasMany|ArticleBuilder - { - return $this->hasMany(MySqlArticle::class, 'user_id'); - } - - protected static function newFactory(): MySqlUserFactory - { - return new MySqlUserFactory(); - } -} diff --git a/tests/app/Models/PostgreSqlArticle.php b/tests/app/Models/PostgreSqlArticle.php deleted file mode 100644 index 9e97f98..0000000 --- a/tests/app/Models/PostgreSqlArticle.php +++ /dev/null @@ -1,26 +0,0 @@ -belongsTo(PostgreSqlUser::class); - } - - public static function newFactory(): PostgreSqlArticleFactory - { - return new PostgreSqlArticleFactory(); - } -} diff --git a/tests/app/Models/PostgreSqlComment.php b/tests/app/Models/PostgreSqlComment.php deleted file mode 100644 index a66365d..0000000 --- a/tests/app/Models/PostgreSqlComment.php +++ /dev/null @@ -1,36 +0,0 @@ -belongsTo(PostgreSqlUser::class, 'user_id'); - } - - public function post(): BelongsTo|PostBuilder - { - return $this->belongsTo(PostgreSqlPost::class, 'post_id', 'id'); - } - - public static function newFactory(): PostgreSqlCommentFactory - { - return new PostgreSqlCommentFactory(); - } -} diff --git a/tests/app/Models/PostgreSqlPost.php b/tests/app/Models/PostgreSqlPost.php deleted file mode 100644 index d87cfca..0000000 --- a/tests/app/Models/PostgreSqlPost.php +++ /dev/null @@ -1,30 +0,0 @@ -hasMany(PostgreSqlComment::class, 'post_id', 'id'); - } - - public static function newFactory(): PostgreSqlPostFactory - { - return new PostgreSqlPostFactory(); - } -} diff --git a/tests/app/Models/PostgreSqlStory.php b/tests/app/Models/PostgreSqlStory.php deleted file mode 100644 index e0213d1..0000000 --- a/tests/app/Models/PostgreSqlStory.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMany(PostgreSqlComment::class, 'user_id'); - } - - public function articles(): HasMany|ArticleBuilder - { - return $this->hasMany(PostgreSqlArticle::class, 'user_id'); - } - - protected static function newFactory(): PostgreSqlUserFactory - { - return new PostgreSqlUserFactory(); - } -} diff --git a/tests/app/Models/SqLiteArticle.php b/tests/app/Models/SqLiteArticle.php deleted file mode 100644 index 19c8e21..0000000 --- a/tests/app/Models/SqLiteArticle.php +++ /dev/null @@ -1,26 +0,0 @@ -belongsTo(SqLiteUser::class); - } - - public static function newFactory(): SqLiteArticleFactory - { - return new SqLiteArticleFactory(); - } -} diff --git a/tests/app/Models/SqLiteComment.php b/tests/app/Models/SqLiteComment.php deleted file mode 100644 index b9f9a86..0000000 --- a/tests/app/Models/SqLiteComment.php +++ /dev/null @@ -1,36 +0,0 @@ -belongsTo(SqLiteUser::class, 'user_id'); - } - - public function post(): BelongsTo|PostBuilder - { - return $this->belongsTo(SqLitePost::class, 'post_id', 'id'); - } - - public static function newFactory(): SqLiteCommentFactory - { - return new SqLiteCommentFactory(); - } -} diff --git a/tests/app/Models/SqLitePost.php b/tests/app/Models/SqLitePost.php deleted file mode 100644 index ca359d2..0000000 --- a/tests/app/Models/SqLitePost.php +++ /dev/null @@ -1,30 +0,0 @@ -hasMany(SqLiteComment::class, 'post_id', 'id'); - } - - public static function newFactory(): SqLitePostFactory - { - return new SqLitePostFactory(); - } -} diff --git a/tests/app/Models/SqLiteStory.php b/tests/app/Models/SqLiteStory.php deleted file mode 100644 index b542226..0000000 --- a/tests/app/Models/SqLiteStory.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMany(SqLiteComment::class, 'user_id'); - } - - public function articles(): HasMany|ArticleBuilder - { - return $this->hasMany(SqLiteArticle::class, 'user_id'); - } - - protected static function newFactory(): SqLiteUserFactory - { - return new SqLiteUserFactory(); - } -}