diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fb84ac500..1444156af4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,13 +18,23 @@ jobs: strategy: fail-fast: false matrix: - php: [7.3, 7.4, 8.0, 8.1] - laravel: ['8.*', '9.*'] + 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 + laravel: 10.* + - php: 8.0 + laravel: 10.* name: 'PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }}' @@ -52,6 +62,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 @@ -62,4 +76,5 @@ jobs: # Run phpunit tests - name: Run tests - run: ./vendor/bin/phpunit + run: ./vendor/bin/phpunit --no-coverage + 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 57ef2f44b5..12656da149 100644 --- a/composer.json +++ b/composer.json @@ -1,56 +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", - "intervention/image": "^2.4", - "doctrine/dbal": "^2.5|^3.1", - "larapack/doctrine-support": "~0.1.4", - "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", - "orchestra/testbench": ">=4.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/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); } 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) 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 053556c1ad..d24c177b8a 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); @@ -251,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())