Last active
February 15, 2024 02:37
-
-
Save jhm-ciberman/b6063c31a680b75fca55f7dcb37f66ae to your computer and use it in GitHub Desktop.
Revisions
-
jhm-ciberman revised this gist
Feb 15, 2024 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ namespace Tests\Feature; use Tests\TestCase; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Nova; class NovaResourcesTest extends TestCase @@ -14,6 +14,8 @@ public function testAllNovaResources() // It is meant for testing only basic syntax errors // Nova resource behaviours should be manually tested Nova::resourcesIn(app_path('Nova')); $resources = collect(Nova::$resources); $this->assertTrue($resources->count() > 0); @@ -41,7 +43,7 @@ private function executeTestFor($resourceClass) public function assertResourceMethod($resource, $methodName) { $request = new NovaRequest(); $array = $resource->{$methodName}($request); -
jhm-ciberman revised this gist
Feb 15, 2024 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,11 +3,8 @@ namespace Tests\Feature; use Tests\TestCase; use Illuminate\Http\Request; use Laravel\Nova\Nova; class NovaResourcesTest extends TestCase { @@ -48,6 +45,6 @@ public function assertResourceMethod($resource, $methodName) $array = $resource->{$methodName}($request); $this->assertIsArray($array); } } -
jhm-ciberman created this gist
Apr 28, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ <?php namespace Tests\Feature; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Http\Request; use Laravel\Nova\Nova; use Laravel\Nova\Resource; class NovaResourcesTest extends TestCase { public function testAllNovaResources() { // This test only instanciates one resource of each type // It is meant for testing only basic syntax errors // Nova resource behaviours should be manually tested $resources = collect(Nova::$resources); $this->assertTrue($resources->count() > 0); $resources->each(function($resourceClass) { $this->executeTestFor($resourceClass); }); } private function executeTestFor($resourceClass) { // Asserts the model asociated to the nova resource can be instantiated $model = app($resourceClass::$model); $this->assertNotNull($model); // Instantiates the nova resource $resource = new $resourceClass($model); $this->assertResourceMethod($resource, 'fields'); $this->assertResourceMethod($resource, 'cards'); $this->assertResourceMethod($resource, 'filters'); $this->assertResourceMethod($resource, 'lenses'); $this->assertResourceMethod($resource, 'actions'); } public function assertResourceMethod($resource, $methodName) { $request = new Request(); $array = $resource->{$methodName}($request); $this->assertInternalType('array', $array); } }