From 411551f08fd3c494952fe345cb32b3a53e3819e9 Mon Sep 17 00:00:00 2001 From: Christoph Schweppe Date: Mon, 27 Feb 2023 13:30:17 +0100 Subject: [PATCH 1/8] Laravel 10 support --- .github/workflows/test.yml | 8 +++++++- composer.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fb84ac500..4effd10747 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,12 +19,18 @@ jobs: fail-fast: false matrix: php: [7.3, 7.4, 8.0, 8.1] - laravel: ['8.*', '9.*'] + laravel: ['8.*', '9.*', '10.*'] exclude: - php: 7.3 laravel: 9.* - php: 7.4 laravel: 9.* + - php: 7.3 + laravel: 10.* + - php: 7.4 + laravel: 10.* + - php: 8.0 + laravel: 10.* name: 'PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }}' diff --git a/composer.json b/composer.json index 57ef2f44b5..ac970ddae0 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^7.3|^7.4|^8.0", - "illuminate/support": "~8.0|~9.0", + "illuminate/support": "~8.0|~9.0|~10.0", "intervention/image": "^2.4", "doctrine/dbal": "^2.5|^3.1", "larapack/doctrine-support": "~0.1.4", From c72485d5c2622cd4ec63ee1397d6d60a5e5cf6b2 Mon Sep 17 00:00:00 2001 From: Christoph Schweppe Date: Mon, 27 Feb 2023 13:42:51 +0100 Subject: [PATCH 2/8] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ac970ddae0..f13a692ffc 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require-dev": { "phpunit/phpcov": ">=6.0", "phpunit/phpunit": ">=8.0", - "laravel/framework": "~8.0|~9.0", + "laravel/framework": "~8.0|~9.0|~10.0", "orchestra/testbench": ">=4.0", "laravel/browser-kit-testing": ">=6.1.0", "orchestra/testbench-browser-kit": ">=4.0" From 3be44e96d6711aa781c157f2ac996e9a37f5164e Mon Sep 17 00:00:00 2001 From: Christoph Schweppe Date: Mon, 27 Feb 2023 14:21:35 +0100 Subject: [PATCH 3/8] Update tests --- .github/workflows/test.yml | 4 ++++ composer.json | 5 ++--- src/VoyagerServiceProvider.php | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4effd10747..6f03658630 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,6 +58,10 @@ jobs: - name: Show laravel version run: composer show laravel/framework + # Generate vendor symlink + - name: Generate vendor symlink + run: ./vendor/bin/testbench + # Install NPM dependencies - name: Install Dependencies run: npm install diff --git a/composer.json b/composer.json index f13a692ffc..fecc723258 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ "php": "^7.3|^7.4|^8.0", "illuminate/support": "~8.0|~9.0|~10.0", "intervention/image": "^2.4", - "doctrine/dbal": "^2.5|^3.1", - "larapack/doctrine-support": "~0.1.4", + "doctrine/dbal": "^3.1|^3.5", "laravel/ui": ">=1.0", "arrilot/laravel-widgets": "^3.7", "league/flysystem": "~1.1|~2.0|~3.0", @@ -29,7 +28,7 @@ "phpunit/phpcov": ">=6.0", "phpunit/phpunit": ">=8.0", "laravel/framework": "~8.0|~9.0|~10.0", - "orchestra/testbench": ">=4.0", + "orchestra/testbench": ">=6.0", "laravel/browser-kit-testing": ">=6.1.0", "orchestra/testbench-browser-kit": ">=4.0" }, diff --git a/src/VoyagerServiceProvider.php b/src/VoyagerServiceProvider.php index 053556c1ad..918d17cef7 100644 --- a/src/VoyagerServiceProvider.php +++ b/src/VoyagerServiceProvider.php @@ -16,7 +16,6 @@ use Illuminate\Support\Facades\View; use Illuminate\Support\Str; use Intervention\Image\ImageServiceProvider; -use Larapack\DoctrineSupport\DoctrineSupportServiceProvider; use TCG\Voyager\Events\FormFieldsRegistered; use TCG\Voyager\Facades\Voyager as VoyagerFacade; use TCG\Voyager\FormFields\After\DescriptionHandler; @@ -59,7 +58,6 @@ public function register() $this->app->register(VoyagerEventServiceProvider::class); $this->app->register(ImageServiceProvider::class); $this->app->register(VoyagerDummyServiceProvider::class); - $this->app->register(DoctrineSupportServiceProvider::class); $loader = AliasLoader::getInstance(); $loader->alias('Voyager', VoyagerFacade::class); From a74198baf70f26ca6aa02723aea39a03cc45b043 Mon Sep 17 00:00:00 2001 From: Christoph Schweppe Date: Wed, 1 Mar 2023 09:00:56 +0100 Subject: [PATCH 4/8] Update test.yml --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f03658630..59d1b6ffcd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,13 +18,17 @@ jobs: strategy: fail-fast: false matrix: - php: [7.3, 7.4, 8.0, 8.1] + php: [7.3, 7.4, 8.0, 8.1, 8.2] laravel: ['8.*', '9.*', '10.*'] exclude: + - php: 8.2 + laravel: 8.* - php: 7.3 laravel: 9.* - php: 7.4 laravel: 9.* + - php: 8.2 + laravel: 9.* - php: 7.3 laravel: 10.* - php: 7.4 From de0fd215ef67456c0c1304c37866c967db1bd1d0 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Mon, 28 Aug 2023 13:20:02 -0400 Subject: [PATCH 5/8] Adding updates to fix the Bread Issue --- src/Database/Schema/SchemaManager.php | 2 +- src/Database/Schema/Table.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Database/Schema/SchemaManager.php b/src/Database/Schema/SchemaManager.php index 2ed097fa59..62b64e8479 100644 --- a/src/Database/Schema/SchemaManager.php +++ b/src/Database/Schema/SchemaManager.php @@ -62,7 +62,7 @@ public static function listTableDetails($tableName) $indexes = static::manager()->listTableIndexes($tableName); - return new Table($tableName, $columns, $indexes, $foreignKeys, false, []); + return new Table($tableName, $columns, $indexes, [], $foreignKeys, []); } /** diff --git a/src/Database/Schema/Table.php b/src/Database/Schema/Table.php index 91caba08df..2e1d2c9fb1 100644 --- a/src/Database/Schema/Table.php +++ b/src/Database/Schema/Table.php @@ -35,7 +35,7 @@ public static function make($table) $options = $table['options']; - return new self($name, $columns, $indexes, $foreignKeys, false, $options); + return new self($name, $columns, $indexes, [], $foreignKeys, $options); } public function getColumnsIndexes($columns, $sort = false) From 37a101b77c2e9dbda04b7bfcc36d113d768e726f Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Sat, 4 Nov 2023 17:41:29 +0000 Subject: [PATCH 6/8] Fix oldName column option not supported error --- src/Database/Schema/Column.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Schema/Column.php b/src/Database/Schema/Column.php index ff641dd994..b2e971a4c4 100644 --- a/src/Database/Schema/Column.php +++ b/src/Database/Schema/Column.php @@ -15,7 +15,7 @@ public static function make(array $column, string $tableName = null) $type = ($type instanceof DoctrineType) ? $type : DoctrineType::getType(trim($type['name'])); $type->tableName = $tableName; - $options = array_diff_key($column, ['name' => $name, 'type' => $type]); + $options = array_diff_key($column, array_flip(['name', 'composite', 'oldName', 'null', 'extra', 'type', 'charset', 'collation'])); return new DoctrineColumn($name, $type, $options); } From f32317b4c596f6439673e5e3eda71517d8379bc5 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Sun, 5 Nov 2023 09:36:21 +0000 Subject: [PATCH 7/8] Fix failing tests for Laravel 10 --- .gitignore | 1 + composer.json | 114 ++++++++++-------- phpunit.xml | 58 ++++----- .../CategoriesTableSeeder.php | 2 + .../PagesTableSeeder.php | 2 + .../PostsTableSeeder.php | 2 + .../UsersTableSeeder.php | 2 + .../DataRowsTableSeeder.php | 2 + .../DataTypesTableSeeder.php | 2 + .../MenuItemsTableSeeder.php | 2 + .../{seeds => seeders}/MenusTableSeeder.php | 2 + .../PermissionRoleTableSeeder.php | 2 + .../PermissionsTableSeeder.php | 2 + .../{seeds => seeders}/RolesTableSeeder.php | 2 + .../SettingsTableSeeder.php | 2 + .../TranslationsTableSeeder.php | 2 + .../VoyagerDatabaseSeeder.php | 4 +- .../VoyagerDummyDatabaseSeeder.php | 4 +- src/Commands/InstallCommand.php | 34 +----- src/Models/MenuItem.php | 2 +- src/Providers/VoyagerDummyServiceProvider.php | 4 +- src/Seed.php | 11 -- src/VoyagerServiceProvider.php | 4 +- tests/AssetsTest.php | 2 +- tests/Unit/Actions/AbstractActionTest.php | 10 +- 25 files changed, 134 insertions(+), 140 deletions(-) rename publishable/database/{dummy_seeds => dummy_seeders}/CategoriesTableSeeder.php (99%) rename publishable/database/{dummy_seeds => dummy_seeders}/PagesTableSeeder.php (99%) rename publishable/database/{dummy_seeds => dummy_seeders}/PostsTableSeeder.php (99%) rename publishable/database/{dummy_seeds => dummy_seeders}/UsersTableSeeder.php (95%) rename publishable/database/{seeds => seeders}/DataRowsTableSeeder.php (99%) rename publishable/database/{seeds => seeders}/DataTypesTableSeeder.php (98%) rename publishable/database/{seeds => seeders}/MenuItemsTableSeeder.php (99%) rename publishable/database/{seeds => seeders}/MenusTableSeeder.php (91%) rename publishable/database/{seeds => seeders}/PermissionRoleTableSeeder.php (94%) rename publishable/database/{seeds => seeders}/PermissionsTableSeeder.php (96%) rename publishable/database/{seeds => seeders}/RolesTableSeeder.php (95%) rename publishable/database/{seeds => seeders}/SettingsTableSeeder.php (99%) rename publishable/database/{seeds => seeders}/TranslationsTableSeeder.php (99%) rename publishable/database/{seeds => seeders}/VoyagerDatabaseSeeder.php (89%) rename publishable/database/{seeds => seeders}/VoyagerDummyDatabaseSeeder.php (87%) delete mode 100644 src/Seed.php diff --git a/.gitignore b/.gitignore index 8fa94f5419..7d66f7ec6a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build .lock composer.lock .phpunit.result.cache +.phpunit.cache diff --git a/composer.json b/composer.json index fecc723258..12656da149 100644 --- a/composer.json +++ b/composer.json @@ -1,55 +1,65 @@ { - "name": "tcg/voyager", - "description": "A Laravel Admin Package for The Control Group to make your life easier and steer your project in the right direction", - "keywords": ["laravel", "admin", "panel"], - "license": "MIT", - "homepage": "https://voyager.devdojo.com/", - "support": { - "issues": "https://github.com/the-control-group/voyager/issues", - "source": "https://github.com/the-control-group/voyager" - }, - "authors": [ - { - "name": "Tony Lea", - "email": "tony.lea@thecontrolgroup.com" - } - ], - "require": { - "php": "^7.3|^7.4|^8.0", - "illuminate/support": "~8.0|~9.0|~10.0", - "intervention/image": "^2.4", - "doctrine/dbal": "^3.1|^3.5", - "laravel/ui": ">=1.0", - "arrilot/laravel-widgets": "^3.7", - "league/flysystem": "~1.1|~2.0|~3.0", - "ext-json": "*" - }, - "require-dev": { - "phpunit/phpcov": ">=6.0", - "phpunit/phpunit": ">=8.0", - "laravel/framework": "~8.0|~9.0|~10.0", - "orchestra/testbench": ">=6.0", - "laravel/browser-kit-testing": ">=6.1.0", - "orchestra/testbench-browser-kit": ">=4.0" - }, - "autoload": { - "psr-4": { - "TCG\\Voyager\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "TCG\\Voyager\\Tests\\": "tests/", - "TCG\\Voyager\\Tests\\Database\\Factories\\": "tests/database/factories/" - } - }, - "minimum-stability": "stable", - "extra": { - "laravel": { - "providers": [ - "TCG\\Voyager\\VoyagerServiceProvider", - "TCG\\Voyager\\Providers\\VoyagerDummyServiceProvider" - ] - } + "name": "tcg/voyager", + "description": "A Laravel Admin Package for The Control Group to make your life easier and steer your project in the right direction", + "keywords": [ + "laravel", + "admin", + "panel" + ], + "license": "MIT", + "homepage": "https://voyager.devdojo.com/", + "support": { + "issues": "https://github.com/the-control-group/voyager/issues", + "source": "https://github.com/the-control-group/voyager" + }, + "authors": [ + { + "name": "Tony Lea", + "email": "tony.lea@thecontrolgroup.com" } + ], + "require": { + "php": "^7.3|^7.4|^8.0|^8.1|^8.2", + "illuminate/support": "~8.0|~9.0|~10.0", + "intervention/image": "^2.7", + "doctrine/dbal": "^3.1|^3.5", + "laravel/ui": ">=1.0", + "arrilot/laravel-widgets": "^3.7", + "league/flysystem": "~1.1|~2.0|~3.0", + "ext-json": "*" + }, + "require-dev": { + "phpunit/phpcov": ">=6.0", + "phpunit/phpunit": ">=8.0", + "laravel/framework": "~8.0|~9.0|~10.0", + "orchestra/testbench": ">=6.0", + "laravel/browser-kit-testing": ">=6.1.0", + "orchestra/testbench-browser-kit": ">=4.0" + }, + "autoload": { + "psr-4": { + "TCG\\Voyager\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "TCG\\Voyager\\Tests\\": "tests/", + "TCG\\Voyager\\Tests\\Database\\Factories\\": "tests/database/factories/", + "Database\\Seeders\\": "vendor/orchestra/testbench-core/laravel/database/seeders" + } + }, + "minimum-stability": "stable", + "extra": { + "laravel": { + "providers": [ + "TCG\\Voyager\\VoyagerServiceProvider", + "TCG\\Voyager\\Providers\\VoyagerDummyServiceProvider" + ] + } + }, + "scripts": { + "post-autoload-dump": [ + "@php vendor/bin/testbench package:discover --ansi" + ] + } } diff --git a/phpunit.xml b/phpunit.xml index 3a3d849625..f26f839b8e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,34 +1,28 @@ - - - - tests - - - - - - - - - - ./src/ - - - - - - - - + + + + + + + + + + tests + + + + + + + + + + + + + + ./src/ + + diff --git a/publishable/database/dummy_seeds/CategoriesTableSeeder.php b/publishable/database/dummy_seeders/CategoriesTableSeeder.php similarity index 99% rename from publishable/database/dummy_seeds/CategoriesTableSeeder.php rename to publishable/database/dummy_seeders/CategoriesTableSeeder.php index edabac4ff0..8c365107f2 100644 --- a/publishable/database/dummy_seeds/CategoriesTableSeeder.php +++ b/publishable/database/dummy_seeders/CategoriesTableSeeder.php @@ -1,5 +1,7 @@ composer = $composer; $this->composer->setWorkingPath(base_path()); - $this->seedFolder = Seed::getFolderName(); } protected function getOptions() @@ -89,7 +87,7 @@ public function handle(Filesystem $filesystem) $this->info('Publishing the Voyager assets, database, and config files'); // Publish only relevant resources on install - $tags = ['seeds']; + $tags = ['seeders']; $this->call('vendor:publish', ['--provider' => VoyagerServiceProvider::class, '--tag' => $tags]); @@ -125,25 +123,14 @@ public function handle(Filesystem $filesystem) if ($this->option('with-dummy')) { $this->info('Publishing dummy content'); - $tags = ['dummy_seeds', 'dummy_content', 'dummy_config', 'dummy_migrations']; + $tags = ['dummy_seeders', 'dummy_content', 'dummy_config', 'dummy_migrations']; $this->call('vendor:publish', ['--provider' => VoyagerDummyServiceProvider::class, '--tag' => $tags]); - - $this->addNamespaceIfNeeded( - collect($filesystem->files("{$publishablePath}/database/dummy_seeds/")), - $filesystem - ); } else { $this->call('vendor:publish', ['--provider' => VoyagerServiceProvider::class, '--tag' => ['config', 'voyager_avatar']]); } - $this->addNamespaceIfNeeded( - collect($filesystem->files("{$publishablePath}/database/seeds/")), - $filesystem - ); - $this->info('Dumping the autoloaded files and reloading all new files'); $this->composer->dumpAutoloads(); - require_once base_path('vendor/autoload.php'); $this->info('Seeding data into the database'); $this->call('db:seed', ['--class' => 'VoyagerDatabaseSeeder', '--force' => $this->option('force')]); @@ -162,21 +149,4 @@ public function handle(Filesystem $filesystem) $this->info('Successfully installed Voyager! Enjoy'); } - private function addNamespaceIfNeeded($seeds, Filesystem $filesystem) - { - if ($this->seedFolder != 'seeders') { - return; - } - - $seeds->each(function ($file) use ($filesystem) { - $path = database_path('seeders').'/'.$file->getFilename(); - $stub = str_replace( - ["get($path) - ); - - $filesystem->put($path, $stub); - }); - } } diff --git a/src/Models/MenuItem.php b/src/Models/MenuItem.php index 111ad0bbfa..a0d5a7e1a4 100644 --- a/src/Models/MenuItem.php +++ b/src/Models/MenuItem.php @@ -90,7 +90,7 @@ protected function prepareLink($absolute, $route, $parameters, $url) public function getParametersAttribute() { - return json_decode($this->attributes['parameters']); + return json_decode($this->attributes['parameters'] ?? ''); } public function setParametersAttribute($value) diff --git a/src/Providers/VoyagerDummyServiceProvider.php b/src/Providers/VoyagerDummyServiceProvider.php index 2417b43683..8c887e83db 100644 --- a/src/Providers/VoyagerDummyServiceProvider.php +++ b/src/Providers/VoyagerDummyServiceProvider.php @@ -30,8 +30,8 @@ private function registerPublishableResources() $publishablePath = dirname(__DIR__).'/../publishable'; $publishable = [ - 'dummy_seeds' => [ - "{$publishablePath}/database/dummy_seeds/" => database_path(Seed::getFolderName()), + 'dummy_seeders' => [ + "{$publishablePath}/database/dummy_seeders/" => database_path('seeders'), ], 'dummy_content' => [ "{$publishablePath}/dummy_content/" => storage_path('app/public'), diff --git a/src/Seed.php b/src/Seed.php deleted file mode 100644 index d8df22e8be..0000000000 --- a/src/Seed.php +++ /dev/null @@ -1,11 +0,0 @@ -version(), '8.0') >= 0 ? 'seeders' : 'seeds'; - } -} diff --git a/src/VoyagerServiceProvider.php b/src/VoyagerServiceProvider.php index 918d17cef7..d24c177b8a 100644 --- a/src/VoyagerServiceProvider.php +++ b/src/VoyagerServiceProvider.php @@ -249,8 +249,8 @@ private function registerPublishableResources() 'voyager_avatar' => [ "{$publishablePath}/dummy_content/users/" => storage_path('app/public/users'), ], - 'seeds' => [ - "{$publishablePath}/database/seeds/" => database_path(Seed::getFolderName()), + 'seeders' => [ + "{$publishablePath}/database/seeders/" => database_path('seeders'), ], 'config' => [ "{$publishablePath}/config/voyager.php" => config_path('voyager.php'), diff --git a/tests/AssetsTest.php b/tests/AssetsTest.php index c6b1f47f8f..79676f9db5 100644 --- a/tests/AssetsTest.php +++ b/tests/AssetsTest.php @@ -23,7 +23,7 @@ public function testCanOpenFileInAssets() $this->assertEquals(200, $response->status(), $url.' did not return a 200'); } - public function urlProvider() + public static function urlProvider() { return [ [ diff --git a/tests/Unit/Actions/AbstractActionTest.php b/tests/Unit/Actions/AbstractActionTest.php index 7a74054acb..4e939a3a04 100644 --- a/tests/Unit/Actions/AbstractActionTest.php +++ b/tests/Unit/Actions/AbstractActionTest.php @@ -39,7 +39,7 @@ public function testGetRouteWithEmptyKey() { $stub = $this->getMockBuilder(AbstractAction::class) ->disableOriginalConstructor() - ->setMethods(['getDefaultRoute']) + ->onlyMethods(['getDefaultRoute']) ->getMockForAbstractClass(); // The `getDefaultRoute` method is called as default inside the @@ -59,7 +59,7 @@ public function testGetRouteWithCustomKey() { $stub = $this->getMockBuilder(AbstractAction::class) ->disableOriginalConstructor() - ->setMethods(['getCustomRoute']) + ->addMethods(['getCustomRoute']) ->getMockForAbstractClass(); // The key that's passed to the `getRoute` method will be capitalized @@ -80,7 +80,7 @@ public function testConvertAttributesToHtml() { $stub = $this->getMockBuilder(AbstractAction::class) ->disableOriginalConstructor() - ->setMethods(['getAttributes']) + ->onlyMethods(['getAttributes']) ->getMockForAbstractClass(); $stub->expects($this->any()) @@ -115,7 +115,7 @@ public function testTrueIsReturnedIfDataTypeMatchesTheOneWhereTheActionWasCreate { $stub = $this->getMockBuilder(AbstractAction::class) ->setConstructorArgs([$this->userDataType, $this->user]) - ->setMethods(['getDataType']) + ->onlyMethods(['getDataType']) ->getMockForAbstractClass(); $stub->expects($this->any()) @@ -133,7 +133,7 @@ public function testFalseIsReturnedIfDataTypeDoesNotMatchesTheOneWhereTheActionW { $stub = $this->getMockBuilder(AbstractAction::class) ->setConstructorArgs([$this->userDataType, $this->user]) - ->setMethods(['getDataType']) + ->onlyMethods(['getDataType']) ->getMockForAbstractClass(); $stub->expects($this->any()) From 167daa152353c8494eda49e73fb78f895bc60f9e Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Sun, 5 Nov 2023 10:31:39 +0000 Subject: [PATCH 8/8] Remove covorage from tests workflow --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59d1b6ffcd..1444156af4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,4 +76,5 @@ jobs: # Run phpunit tests - name: Run tests - run: ./vendor/bin/phpunit + run: ./vendor/bin/phpunit --no-coverage +