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 + 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())