diff --git a/.github/workflows/manifest.yml b/.github/workflows/manifest.yml index 72597a5329..5bbbd08f6a 100644 --- a/.github/workflows/manifest.yml +++ b/.github/workflows/manifest.yml @@ -11,7 +11,7 @@ jobs: name: Update manifest runs-on: ubuntu-latest env: - phpVersion: '8.1' + phpVersion: '8.2' extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip key: winter-cms-cache-develop steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e14444a88e..39388bfb41 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: name: ${{ matrix.operatingSystem }} / JavaScript env: nodeVersion: 16 - phpVersion: '8.0' + phpVersion: '8.2' extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip key: winter-cms-cache-develop steps: @@ -58,7 +58,7 @@ jobs: - name: Switch library dependency (develop) if: github.ref == 'refs/heads/develop' || github.base_ref == 'develop' - run: php ./.github/workflows/utilities/library-switcher "dev-develop as 1.2" + run: php ./.github/workflows/utilities/library-switcher "dev-wip-laravel-11 as 1.2" - name: Switch library dependency (1.2) if: github.head_ref == '1.2' || github.ref == 'refs/heads/1.2' || github.base_ref == '1.2' @@ -96,7 +96,7 @@ jobs: max-parallel: 8 matrix: operatingSystem: [ubuntu-latest, windows-latest] - phpVersion: ['8.0', '8.1', '8.2', '8.3'] + phpVersion: ['8.2', '8.3'] fail-fast: false runs-on: ${{ matrix.operatingSystem }} name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }} @@ -135,7 +135,7 @@ jobs: - name: Switch library dependency (develop) if: github.ref == 'refs/heads/develop' || github.base_ref == 'develop' - run: php ./.github/workflows/utilities/library-switcher "dev-develop as 1.2" + run: php ./.github/workflows/utilities/library-switcher "dev-wip-laravel-11 as 1.2" - name: Switch library dependency (1.0) if: github.head_ref == '1.0' || github.ref == 'refs/heads/1.0' || github.base_ref == '1.0' @@ -171,10 +171,6 @@ jobs: - name: Run post-update Composer scripts run: php artisan package:discover - - name: Setup problem matchers for PHPUnit - if: matrix.phpVersion == '8.1' - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Run Linting and Tests run: | composer lint diff --git a/.gitignore b/.gitignore index 9485e1fe2f..310a2bcab9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ composer.lock selenium.php /bootstrap/compiled.php .phpunit.result.cache +.phpunit.cache # Hosting ignores php_errors.log @@ -26,6 +27,7 @@ nbproject .vscode !.devcontainer/.vscode _ide_helper.php +*.code-workspace # Other ignores .DS_Store diff --git a/composer.json b/composer.json index 8f4e849a5f..a2435273f1 100644 --- a/composer.json +++ b/composer.json @@ -29,21 +29,21 @@ "source": "https://github.com/wintercms/winter" }, "require": { - "php": "^8.0.2", - "winter/storm": "dev-develop as 1.2", - "winter/wn-system-module": "dev-develop", - "winter/wn-backend-module": "dev-develop", - "winter/wn-cms-module": "dev-develop", - "laravel/framework": "^9.1", + "php": "^8.2", + "winter/storm": "dev-wip-laravel-11 as 1.2", + "winter/wn-system-module": "dev-wip-laravel-11", + "winter/wn-backend-module": "dev-wip-laravel-11", + "winter/wn-cms-module": "dev-wip-laravel-11", + "laravel/framework": "^11.0", "wikimedia/composer-merge-plugin": "~2.1.0" }, "require-dev": { - "phpunit/phpunit": "^9.5.8", + "phpunit/phpunit": "^10.5", "mockery/mockery": "^1.4.4", "fakerphp/faker": "^1.9.2", "squizlabs/php_codesniffer": "^3.2", "php-parallel-lint/php-parallel-lint": "^1.0", - "dms/phpunit-arraysubset-asserts": "^0.1.0|^0.2.1" + "dms/phpunit-arraysubset-asserts": "^0.5.0" }, "scripts": { "post-create-project-cmd": [ @@ -65,7 +65,6 @@ "phpcs --colors -nq --report=\"full\" --extensions=\"php\"" ] }, - "minimum-stability": "dev", "prefer-stable": true, "extra": { "merge-plugin": { diff --git a/config/hashing.php b/config/hashing.php index ad56664fb1..7bf45fba5c 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -48,4 +48,17 @@ 'threads' => 1, 'time' => 4, ], + + /* + |-------------------------------------------------------------------------- + | Password Rehashing + |-------------------------------------------------------------------------- + | + | Laravel 11 will automatically rehash your user's passwords during + | authentication if your hashing algorithm's "work factor" has been updated + | since the password was last hashed. + | + */ + + 'rehash_on_login' => false, ]; diff --git a/modules/backend/composer.json b/modules/backend/composer.json index 07fb327fd3..84acaccf56 100644 --- a/modules/backend/composer.json +++ b/modules/backend/composer.json @@ -23,9 +23,9 @@ } ], "require": { - "php": "^8.0.2", + "php": "^8.2", "composer/installers": "~1.11.0", - "laravel/framework": "^9.1" + "laravel/framework": "^11.0" }, "replace": { "october/backend": "1.1.*" diff --git a/modules/backend/phpunit.xml b/modules/backend/phpunit.xml index 7c0631aa89..2023f43f78 100644 --- a/modules/backend/phpunit.xml +++ b/modules/backend/phpunit.xml @@ -1,17 +1,16 @@ - - - - ./tests - - + + + ./tests + + diff --git a/modules/cms/composer.json b/modules/cms/composer.json index 9d5fc5d302..0730af0685 100644 --- a/modules/cms/composer.json +++ b/modules/cms/composer.json @@ -23,9 +23,9 @@ } ], "require": { - "php": "^8.0.2", + "php": "^8.2", "composer/installers": "~1.11.0", - "laravel/framework": "^9.1" + "laravel/framework": "^11.0" }, "replace": { "october/cms": "1.1.*" diff --git a/modules/cms/phpunit.xml b/modules/cms/phpunit.xml index 4cb34b9f38..bb4330c7dc 100644 --- a/modules/cms/phpunit.xml +++ b/modules/cms/phpunit.xml @@ -1,17 +1,16 @@ - - - - ./tests - - + + + ./tests + + diff --git a/modules/cms/tests/classes/ControllerTest.php b/modules/cms/tests/classes/ControllerTest.php index 16d72cb9ce..abcd338741 100644 --- a/modules/cms/tests/classes/ControllerTest.php +++ b/modules/cms/tests/classes/ControllerTest.php @@ -302,7 +302,7 @@ protected function configAjaxRequestMock($handler, $partials = false) $requestMock = $this ->getMockBuilder('Illuminate\Http\Request') ->disableOriginalConstructor() - ->setMethods(['ajax', 'method', 'header']) + ->onlyMethods(['ajax', 'method', 'header']) ->getMock(); $map = [ diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 8a9569558c..66ac3df32d 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -135,6 +135,13 @@ public function bindContainerObjects() public function update() { try { + $connection = Schema::getConnection(); + if ($connection->getDriverName() === 'sqlite') { + if (version_compare($connection->getServerVersion(), '3.35', '<')) { + throw new Exception("SQLite version minimum requirement not met (>= 3.35)"); + } + }; + $firstUp = !Schema::hasTable($this->getMigrationTableName()); if ($firstUp) { $this->repository->createRepository(); diff --git a/modules/system/composer.json b/modules/system/composer.json index e8387cfb4f..6543a8039a 100644 --- a/modules/system/composer.json +++ b/modules/system/composer.json @@ -23,9 +23,9 @@ } ], "require": { - "php": "^8.0.2", + "php": "^8.2", "composer/installers": "~1.11.0", - "laravel/framework": "^9.1", + "laravel/framework": "^11.0", "composer/semver": "^3.2" }, "replace": { diff --git a/modules/system/console/WinterInstall.php b/modules/system/console/WinterInstall.php index 23cedb057b..aa9e657568 100644 --- a/modules/system/console/WinterInstall.php +++ b/modules/system/console/WinterInstall.php @@ -7,6 +7,7 @@ use File; use Illuminate\Encryption\Encrypter; use PDO; +use Schema; use Str; use Symfony\Component\Console\Input\InputOption; use System\Classes\UpdateManager; diff --git a/modules/system/console/WinterTest.php b/modules/system/console/WinterTest.php index 8a0eb2375d..6ce04e42cb 100644 --- a/modules/system/console/WinterTest.php +++ b/modules/system/console/WinterTest.php @@ -33,11 +33,11 @@ class WinterTest extends Command * @var string The console command signature as ignoreValidationErrors causes options not to be registered. */ protected $signature = 'winter:test - {phpunitArgs?* : Arguments to pass through to PHPUnit} - {?--c|configuration= : A specific phpunit xml file} - {?--b|bootstrap= : A custom PHPUnit bootstrap file} - {?--p|plugin=* : List of plugins to test} - {?--m|module=* : List of modules to test} + {phpunitArgs?* : use "--" followed by the arguments to pass through to PHPUnit such as "-- --stop-on-failure"} + {--c|configuration= : A specific phpunit xml file} + {--b|bootstrap= : A custom PHPUnit bootstrap file} + {--p|plugin=* : List of plugins to test} + {--m|module=* : List of modules to test} '; /** diff --git a/modules/system/phpunit.xml b/modules/system/phpunit.xml index af5eee72a0..66ab407567 100644 --- a/modules/system/phpunit.xml +++ b/modules/system/phpunit.xml @@ -1,17 +1,16 @@ - - - - ./tests - - + + + ./tests + + diff --git a/modules/system/tests/bootstrap/TestCase.php b/modules/system/tests/bootstrap/TestCase.php index 3bdb052718..84784fe14d 100644 --- a/modules/system/tests/bootstrap/TestCase.php +++ b/modules/system/tests/bootstrap/TestCase.php @@ -78,7 +78,8 @@ public static function assertFileNotExists(string $filename, string $message = ' /** * Stub for `assertRegExp` to allow compatibility with both PHPUnit 8 and 9. * - * @param string $filename + * @param string $pattern + * @param string $string * @param string $message * @return void */ @@ -91,4 +92,22 @@ public static function assertRegExp(string $pattern, string $string, string $mes Assert::assertRegExp($pattern, $string, $message); } + + /** + * Stub for `assertObjectHasAttribute` to allow compatibility with both PHPUnit 9 and 10. + * + * @param string $propertyName + * @param object $object + * @param string $message + * @return void + */ + public static function assertObjectHasAttribute(string $propertyName, $object, string $message = ''): void + { + if (method_exists(Assert::class, 'assertObjectHasProperty')) { + Assert::assertObjectHasProperty($propertyName, $object, $message); + return; + } + + Assert::assertObjectHasAttribute($propertyName, $object, $message); + } } diff --git a/modules/system/tests/classes/MediaLibraryTest.php b/modules/system/tests/classes/MediaLibraryTest.php index ac9e67f6ae..7e7a8c24fa 100644 --- a/modules/system/tests/classes/MediaLibraryTest.php +++ b/modules/system/tests/classes/MediaLibraryTest.php @@ -20,7 +20,7 @@ public function tearDown(): void parent::tearDown(); } - public function invalidPathsProvider() + public static function invalidPathsProvider() { return [ ['./file'], @@ -36,7 +36,7 @@ public function invalidPathsProvider() ]; } - public function validPathsProvider() + public static function validPathsProvider() { return [ ['file'], diff --git a/modules/system/tests/classes/VersionManagerTest.php b/modules/system/tests/classes/VersionManagerTest.php index b4d0463a4c..1023808dd5 100644 --- a/modules/system/tests/classes/VersionManagerTest.php +++ b/modules/system/tests/classes/VersionManagerTest.php @@ -157,7 +157,7 @@ public function testExtractScriptsAndComments($versionInfo, $expectedComments, $ $this->assertEquals($expectedScripts, $scripts); } - public function versionInfoProvider() + public static function versionInfoProvider() { return [ [ diff --git a/modules/system/tests/console/CreateMigrationTest.php b/modules/system/tests/console/CreateMigrationTest.php index 77e30eea71..5e3d56d9bd 100644 --- a/modules/system/tests/console/CreateMigrationTest.php +++ b/modules/system/tests/console/CreateMigrationTest.php @@ -34,46 +34,50 @@ public function testCreateMigration() $columns = [ 'id' => ['type'=>'integer', 'index'=>'primary', 'required'=>true], - 'cb' => ['type'=>'boolean'], - 'switch' => ['type'=>'boolean'], + 'cb' => ['type'=>'tinyint'], + 'switch' => ['type'=>'tinyint'], 'int' => ['type'=>'integer'], 'uint' => ['type'=>'integer', 'required'=>true], - 'double' => ['type'=>'float'], + 'double' => ['type'=>'double'], 'range' => ['type'=>'integer', 'required'=>true], 'datetime' => ['type'=>'datetime'], 'date' => ['type'=>'date', 'required'=>true], 'time' => ['type'=>'time'], 'md' => ['type'=>'text'], 'textarea' => ['type'=>'text'], - 'text' => ['type'=>'string', 'required'=>true], + 'text' => ['type'=>'varchar', 'required'=>true], 'phone_id' => ['type'=>'integer', 'index'=>true, 'required'=>true], 'user_id' => ['type'=>'integer', 'index'=>true, 'required'=>true], 'data' => ['type'=>'text'], 'sort_order' => ['type'=>'integer', 'index'=>true], 'taggable_id' => ['type'=>'integer', 'index'=>'morphable_index'], - 'taggable_type' => ['type'=>'string', 'index'=>'morphable_index'], + 'taggable_type' => ['type'=>'varchar', 'index'=>'morphable_index'], 'created_at' => ['type'=>'datetime'], 'updated_at' => ['type'=>'datetime'], ]; - $table = Schema::getConnection()->getDoctrineSchemaManager()->listTableDetails($this->table); + $schemaBuilder = Schema::getConnection()->getSchemaBuilder(); + + $tableColumns = collect($schemaBuilder->getColumns($this->table)); + $tableIndexes = collect($schemaBuilder->getIndexes($this->table))->pluck('columns', 'name'); foreach ($columns as $name => $definition) { - $this->assertEquals(array_get($definition, 'type'), Schema::getColumnType($this->table, $name)); + $column = $tableColumns->where('name', $name)->first(); + + $this->assertEquals(array_get($definition, 'type'), $column['type_name']); + $this->assertEquals(array_get($definition, 'required', false), !$column['nullable']); // assert an index has been created for the primary, morph and foreign keys if ($indexName = array_get($definition, 'index')) { if ($indexName === true) { $indexName = sprintf("%s_%s_index", $this->table, $name); } - $this->assertTrue($table->hasIndex($indexName)); + $this->assertTrue($schemaBuilder->hasIndex($this->table, $indexName)); - if ($indexName === 'morphable_index') { - $index = $table->getIndex($indexName); - $this->assertTrue(in_array($name, $index->getColumns())); + if ($indexColumns = array_get($indexName, $tableIndexes)) { + $this->assertTrue(in_array($name, $indexColumns)); } } - $this->assertEquals(array_get($definition, 'required', false), $table->getColumn($name)->getNotnull()); } $migration->down(); diff --git a/phpunit.xml b/phpunit.xml index 72f7f52986..b2d613baed 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,39 +1,37 @@ - - - ./modules/ - - - ./modules/backend/routes.php - ./modules/cms/routes.php - ./modules/system/routes.php - ./modules/backend/database - ./modules/cms/database - ./modules/system/database - - - - - ./modules/system - ./modules/cms - ./modules/backend - - - - - - - + + + ./modules/system + ./modules/cms + ./modules/backend + + + + + + + + + + ./modules/ + + + ./modules/backend/routes.php + ./modules/cms/routes.php + ./modules/system/routes.php + ./modules/backend/database + ./modules/cms/database + ./modules/system/database + +