Giter Club home page Giter Club logo

nova-assertions's Introduction

Nova Assertions

Latest Version on Github Total Downloads Twitter Follow

Nova requests & assertions for Laravel tests - View examples

testing tdd laravel nova

Assert: Policies | Cards | Actions | Filters | Lenses | Resources | Fields | Relations


Installation

composer require dillingham/nova-assertions --dev

Enable by adding the NovaAssertions to a test

use NovaTesting\NovaAssertions;

class UserTest extends TestCase
{
    use NovaAssertions;
}

Authentication

Log in a user that has access to Nova

$this->be(factory(User::class)->create());

Nova Requests

Request using a resource's uriKey to perform assertions:

$response = $this->novaIndex('users');

$response = $this->novaDetail('users', $user->id);

$response = $this->novaCreate('users');

$response = $this->novaEdit('users', $user->id);

$response = $this->novaLens('users', Lens::class);

Request Filters

You may also pass filters & their values to indexes & lenses

$response = $this->novaIndex('users', [
    StatusFilter::class => 'active'
]);
$response = $this->novaLens('users', Lens::class, [
    StatusFilter::class => 'active'
]);

Assert Http

You can call http response methods as usual:

$response->assertOk();

Assert Resources

$response->assertResourceCount(3);
$response->assertResources(function($resources) {
    return $resources->count() > 0;
});

Assert Cards

$response->assertCardCount(5);
$response->assertCardsInclude(Card::class);
$response->assertCardsExclude(Card::class);
$response->assertCards(function($cards) {
    return $cards->count() > 0;
});

Assert Actions

$response->assertActionCount(5);
$response->assertActionsInclude(Action::class);
$response->assertActionsExclude(Action::class);
$response->assertActions(function($actions) {
    return $actions->count() > 0;
});

Assert Filters

$response->assertFilterCount(5);
$response->assertFiltersInclude(Filter::class);
$response->assertFiltersExclude(Filter::class);
$response->assertFilters(function($filters) {
    return $filters->count() > 0;
});

Assert Lenses

$response->assertLensCount(5);
$response->assertLensesInclude(Lens::class);
$response->assertLensesExclude(Lens::class);
$response->assertLenses(function($lenses) {
    return $lenses->count() > 0;
});

Assert Fields

$response->assertFieldCount(5);

Assert a specific field exists

$response->assertFieldsInclude('id');

Assert a specific field contains a value

$response->assertFieldsInclude('id', $user->id);

Assert multiple fields exist

$response->assertFieldsInclude(['id', 'email']);

Assert multiple fields with specific values exist

$response->assertFieldsInclude(['id' => 1, 'email' => 'example']);

Assert multiple values for one field exist

$response->assertFieldsInclude('id', $users->pluck('id'));

Make assertions against a collection of fields

$response->assertFields(function($fields) {
    return $fields->count() > 0;
});

Also exclude works in all of these scenarios

$response->assertFieldsExclude(['id' => 1, 'email' => 'example']);

Assert Relations

// App\Nova\Post
// BelongsTo::make('Category'),
$response = $this->novaCreate('posts');

$response->assertRelation('categories', function($categories) {
    //
});
// App\Nova\Category
// HasMany::make('Posts'),
$response = $this->novaDetail('categories');

$response->assertRelation('posts', function($posts) {
    //
});

Assert Policies

Assert Nova's use of policies & the authed user:

$response->assertCanView();

$response->assertCanCreate();

$response->assertCanUpdate();

$response->assertCanDelete();

$response->assertCanForceDelete();

$response->assertCanRestore();

Also can assert cannot for each:

$response->assertCannotView();

Author

Hi ๐Ÿ‘‹, Im Brian Dillingham, creator of this Nova package and others

Hope you find it useful. Feel free to reach out with feedback.

Follow me on twitter: @im_brian_d

nova-assertions's People

Contributors

andresilvagomez avatar asivaneswaran avatar dillingham avatar khaled-dev avatar knutle avatar stevelacey avatar wfeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nova-assertions's Issues

AssertFiltersInclude fails with new Nova version

With the latest nova version, the filter class path is different. Here is the error:


[{"class":"App\\Nova\\Filters\\GenderFilter"}]

within

[[{"class":"GenderFilter", 

As you can see, the GenderFilter class in Nova now only shows the path past App\Nova\Filters.

For example, a class in App\Nova\Filters\Members is shown like this in the Nova output:

{"class":"Members\\EligibilityFilter"

assertCanView and asserCannotView

Both these assertions don't work when I do this:

    public function testResponsibleCanViewOwnAssociationShow()
    {
        $this->be($this->responsible());
        $association = Association::factory()->create([
            'responsible_1_id' => $this->responsible()->member_id,
        ]);

        $response = $this->novaDetail('associations', $association->id);
        $response->assertCanView();
    }

I get this error:

Unable to find JSON fragment: 

[{"authorizedToView":true}]

And for this:

    public function testResponsibleCannotViewOtherAssociationShow()
    {
        $this->be($this->responsible());
        $association = Association::factory()->create([
            'responsible_1_id' => Member::factory(),
        ]);

        $response = $this->novaDetail('associations', $association->id);
        $response->assertCannotView();
    }

I get this error:

Unable to find JSON fragment: 

[{"authorizedToView":false}]

But the response I get is a AccessDeniedHttpException, so technically the test should pass.

I am on the latest version.

novaEdit method have error after Nova 3.11.0

My testcase looks like this:

$this->novaEdit('users', $user->id)->assertSee(json_encode($user->nickname), false);

At Nova 3.10.0 is run success, when i upgrade to 3.1.1 the result is 404 not found error.

I'm trying to find out why, at this commit

https://github.com/laravel/nova/commit/d38616b2afa760f4475a046d5d1c3efa9f839650

when i comment out this line

app()->instance(NovaRequest::class, $request);

every thing is ok, but i dont know how to fix it. Can you help me to look this.

thx so much for this package.

assertRelation returns 404 but Laravel Nova finds it correctly

I have a simple Team resource with fields like this:

BelongsToMany::make('Users')->searchable()
        ->fields(new TeamUserFields),
HasMany::make('Whitelist Ips'),

The Nova UI works just fine and I can save new IP address to the team as expected. However when I run the test below it works fine on the users relation but the whitelist ips throws the error below.

$response = $this->novaDetail('teams', $team->id);
$response->assertOk()
    ->assertRelation('users', function($users) {
      return $users->count() == 1;
    })
    ->assertRelation('whitelistIps', function($ips) {
      return $ips->count() == 0;
    });
  โ€ข Tests\Feature\Nova\UserResourceTest > team resource covered
   ErrorException

  Undefined array key "resources"

  at vendor/laravel/framework/src/Illuminate/View/View.php:323

When I look at the data property in the View class from the error above, it appears to show a 404 and is generating the nova-api incorrectly,

It's creating this with an incorrect resource URL slug:

/nova-api/whitelistIps?viaResource=teams&viaResourceId=1&viaRelationship=whitelistIps&relationshipType=hasMany

When it should be:

/nova-api/whitelist-ips?viaResource=teams&viaResourceId=1&viaRelationship=whitelistIps&relationshipType=hasMany

I have tried different variations of the relationship name, but that always returns "Field not found" error from this package. I am not sure how to get the resource name to generate correctly when using these tests

assertFieldCount() on index returns 1

Trying to count the fields on the index page returns 1 everytime.

public function testIndexFields()
    {
        Association::factory()->create();

        $response = $this->novaIndex('associations');

        dd($response);
        $response->assertFieldCount(7);

    }

Response returns this:

 #data: "{"label":"Associations","resources":[{"id":{"attribute":"id","component":"id-field","helpText":null,"indexName":"ID","name":"ID","nullable":false,"panel":null,"prefixComponent":true,"readonly":false,"required":false,"sortable":true,"sortableUriKey":"id","stacked":false,"textAlign":"left","validationKey":"id","value":1},"fields":[{"attribute":"id","component":"id-field","helpText":null,"indexName":"ID","name":"ID","nullable":false,"panel":null,"prefixComponent":true,"readonly":false,"required":false,"sortable":true,"sortableUriKey":"id","stacked":false,"textAlign":"left","validationKey":"id","value":1},{"attribute":"name","component":"text-field","helpText":null,"indexName":"Nom","name":"Nom","nullable":false,"panel":null,"prefixComponent":true,"readonly":false,"required":true,"sortable":true,"sortableUriKey":"name","stacked":false,"textAlign":"left","validationKey":"name","value":"Ste-Caroline"},{"attribute":"logo","component":"file-field","helpText":null,"indexName":"Logo","name":"Logo","nullable":false,"panel":null,"prefixComponent":true,"readonly":false,"required":false,"sortable":false,"sortableUriKey":"logo","stacked":false,"textAlign":"center","validationKey":"logo","value":null,"thumbnailUrl":null,"previewUrl":null,"downloadable":false,"deletable":true,"acceptedTypes":"image\/*","maxWidth":250,"rounded":true},{"belongsToId":1,"belongsToRelationship":"responsible1","debounce":500,"displaysWithTrashed":false,"label":"Membres","resourceName":"members","reverse":false,"searchable":true,"withSubtitles":false,"showCreateRelationButton":false,"singularLabel":"Responsable 1","viewable":true,"attribute":"responsible1","component":"belongs-to-field","helpText":null,"indexName":"Responsable 1","name":"Responsable 1","nullable":false,"panel":null,"prefixComponent":true,"readonly":false,"required":true,"sortable":false,"sortableUriKey":"responsible_1_id","stacked":false,"textAlign":"left","validationKey":"responsible1","value":"Th\u00e9ophile Perron"},{"belongsToId":2,"belongsToRelationship":"responsible2","debounce":500,"displaysWithTrashed":false,"label":"Membres","resourceName":"members","reverse":false,"searchable":true,"withSubtitles":false,"showCreateRelationButton":false,"singularLabel":"Responsable 2","viewable":true,"attribute":"responsible2","component":"belongs-to-field","helpText":null,"indexName":"Responsable 2","name":"Responsable 2","nullable":false,"panel":null,"prefixComponent":true,"readonly":false,"required":true,"sortable":false,"sortableUriKey":"responsible_2_id","stacked":false,"textAlign":"left","validationKey":"responsible2","value":"Dominic Carrier"},{"attribute":"email","component":"text-field","helpText":null,"indexName":"Courriel","name":"Courriel","nullable":false,"panel":"Contact","prefixComponent":true,"readonly":false,"required":true,"sortable":false,"sortableUriKey":"email","stacked":false,"textAlign":"left","validationKey":"email","value":null}],"title":"Ste-Caroline","actions":[{"cancelButtonText":"Annuler","component":"confirm-action-modal","confirmButtonText":"Ex\u00e9cuter action","class":"btn-primary","confirmText":"\u00cates-vous s\u00fbr que vous voulez ex\u00e9cuter cette action\u2008?","destructive":false,"name":"Generate Export","uriKey":"generate-export","fields":[],"availableForEntireResource":false,"showOnDetail":true,"showOnIndex":true,"showOnTableRow":false,"standalone":false,"withoutConfirmation":false}],"authorizedToView":true,"authorizedToCreate":true,"authorizedToUpdate":true,"authorizedToDelete":true,"authorizedToRestore":true,"authorizedToForceDelete":true,"softDeletes":true,"softDeleted":false}],"prev_page_url":null,"next_page_url":null,"per_page":25,"per_page_options":[25,50,100],"softDeletes":true}"

But when I do this:

 $response->assertFieldsInclude(['name', 'logo', 'responsible1', 'responsible2', 'email']);

It passes...

Basic Laravel 8 installation + Nova 3 allways 403

Hello,

I have a problem with a simple test. It always returns a 403 status instead of the expected 200. What am I doing wrong?

The first assertion works as expected, but the second one always returns the same result, 403.

<?php

namespace Tests\Feature;

use NovaTesting\NovaAssertions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\User;

class UserHasUiAccessTest extends TestCase
{
    use NovaAssertions;


    /** @test */
    function user_has_ui_access()
    {
        $user = User::factory()->create();
        $this->be($user);
        $this->assertAuthenticatedAs($user);


        $response = $this->novaIndex('users');

        $response->assertStatus(200);
    }
}

I am running the test on a clean project where I have only installed Laravel 8 and Laravel Nova 3.

Thanks a lot

Running nova-assertions for nova on a subdomain

Hi,

I have created a project with Laravel Nova as a backend service to mange my project. However, my Laravel Nova is accessible via nova.mywebsiteproject.test. So, basically it lies on a subdomain which is, in my opinion, better.

However, sadly this project does not support subdomains. Is there any possibility we can add this kind of feature to this project? This would be awesome!

If anyone is wondering how you can route Laravel Nova via a subdomain, this is how. You have to add this is the config/nova.php file:

/*
|--------------------------------------------------------------------------
| Nova App URL
|--------------------------------------------------------------------------
|
| This URL is where users will be directed when clicking the application
| name in the Nova navigation bar. You are free to change this URL to
| any location you wish depending on the needs of your application.
|
*/

'url' => env('NOVA_SUBDOMAIN') . "." . env('APP_DOMAIN'),

/*
|--------------------------------------------------------------------------
| Nova App Domain
|--------------------------------------------------------------------------
|
*/

'domain' => env('NOVA_SUBDOMAIN') . "." . env('APP_DOMAIN'),

Kind regards!

Action __construct

Hi,

any suggestion

class Delete extends DestructiveAction
{

    protected $modelId;

    public function __construct($modelId)
    {
        $this->modelId = $modelId;       
    }

How to use it with

$response->assertActionsInclude(Delete::class)

It will create error: Unresolvable dependency resolving [Parameter #0 [ $modelId ]] in class App\Nova\Actions\Delete

while

$response->assertActionsInclude(new Delete(1))

Creates: Illegal offset type in isset or empty

any suggestion how to assert Nova Actions that have constructor

assertCanView Question

Hi, thank you for your package!

Quick question, what does the "assertCanView" tests exactly ?

When my user visits the "users" ressources he can view (little eye icon) some users he manages, but some he can't, how would I test for this using AssertCanView ?

I end up testing like the following but I wonder if there is a better way


public function it_cannot_view_users_he_doesnt_manage()

    {

        $response = $this->novaDetail('users', $this->notManagedUser->id);

        $response->assertForbidden();

    }

Thanks

AuthenticationException

In the browser, login works fine using the same user as in the test
Regardless of using the seeded data, or creating the user in the test, I'm getting Unauthenticated when testing Index

test

public function admin_user_can_access_nova()
    {
        $this->be(User::create([
            'name' => 'admin',
            'email' => '[email protected]',
            'password' => bcrypt('Test1234'),
        ]));

        $response = $this->novaIndex('users');
        $response->assertOk();
        $response->assertCanView();
        $response->assertCanCreate();
        $response->assertCanUpdate();
        $response->assertCanDelete();
        $response->assertCanForceDelete();
        $response->assertCanRestore();
    }

In NovaServiceProvider, even I allow all users to debug

    protected function gate()
    {
        Gate::define('viewNova', function ($user) {
            return true;
        });
    }

PHPUnit

There was 1 error:
1) Tests\Feature\NovaTest::admin_user_can_access_nova
Laravel\Nova\Exceptions\AuthenticationException: Unauthenticated.

Environment:

Homestead 10
Laravel 7
Nova 3.14

nova test policy

Hello, it is my redic problem in that when you do tests with a user who does not have permissions, ak runs my test only passes the one that cannot create but those to update and but it does not happen because this error is due

namespace Tests\Feature;

use App\User;
use NovaTesting\NovaAssertions;
use Illuminate\Support\Facades\Config;
use Tests\TestCase;

class UserNovaTest extends TestCase
{
use NovaAssertions;

/* function __construct()
{
    parent::setUp();
} */

public function PolicyCannot($index)
{
    $user = User::where('name', 'roberto')->first();
    $this->actingAs($user)->withSession(['business_center_id' => 1]);
    Config::set('testing.viewAny', false);
    Config::set('testing.create', false);
    Config::set('testing.update', false);
    Config::set('testing.delete', false);
    Config::set('testing.restore', false);  
    Config::set('testing.forceDelete', false); 
    $response = $this->novaIndex($index);
    $response->assertStatus(403);
    $response->assertCannotCreate();
    $response->assertCannotUpdate();
    $response->assertCannotDelete();
    $response->assertCannotForceDelete();
    $response->assertCannotRestore();
} 
public function test_user_nova()
{
    $this->PolicyCannot('offices');
    $this->PolicyCannot('patients');
    $this->PolicyCannot('appointments');
    $this->PolicyCannot('promotions');
    $this->PolicyCannot('medical-services-categories');
    $this->PolicyCannot('appointment-statuses');
    $this->PolicyCannot('professionals');
    $this->PolicyCannot('medical-services');
    $this->PolicyCannot('symptom-categories');
    $this->PolicyCannot('records');
    $this->PolicyCannot('medical-records');  
}

}

State of package

Hi @dillingham, thanks for the great package. Saves me a lot of time testing my Nova App's.

I was just wondering if you still maintain the package or planning on merging PR's and tagging a new release?

If you're too busy and need help with anything to get it up to date let me know, I'll gladly help out.

After First Test | Fatal error: During class fetch: Uncaught ErrorException

Hey everyone

I'm experiencing a Fatal error:
During class fetch: Uncaught ErrorException: Required parameter $method follows optional parameter expectation
The message shows on a simple index resource test. Any idea what I'm missing? I can see there is a xdebug error but I'm not sure if it's related to the package or the exception.

Every PHPUnit and Pest tests beside are working thine.


  Tests:  1 risked, 51 passed
  Time:   3.08s

UserResourceTest.php

<?php

namespace Tests\Nova;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Tests\TestCase;
use NovaTesting\NovaAssertions;

class UserResourceTest extends TestCase
{
    use NovaAssertions;
    use RefreshDatabase;

    /**
     * A basic test example.
     *
     * @return void
     */

    public function test_render_users_index_resource_page()
    {
        $this->withoutExceptionHandling();
        $user = User::factory()->create();
        Auth::login($user);
        $response = $this->novaIndex('users');
        $response->assertOk();


    }
}

PHP -v

Zend Engine v4.0.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

Exception

/opt/homebrew/bin/php /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/phpunit --configuration /Users/sebastian/Development/fresh-smarango/phpunit.xml --filter "/(Tests\\Nova\\UserResourceTest::test_render_users_index_resource_page)( .*)?$/" --test-suffix UserResourceTest.php /Users/sebastian/Development/fresh-smarango/tests/Nova --teamcity
Testing started at 22:07 ...
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.


Fatal error: During class fetch: Uncaught ErrorException: Required parameter $method follows optional parameter $value in /Users/sebastian/Development/fresh-smarango/vendor/dillingham/nova-assertions/src/Assert/AssertFields.php:47
Stack trace:
#0 /Users/sebastian/Development/fresh-smarango/vendor/composer/ClassLoader.php(476): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Required parame...', '/Users/sebastia...', 47)
#1 /Users/sebastian/Development/fresh-smarango/vendor/composer/ClassLoader.php(476): include()
#2 /Users/sebastian/Development/fresh-smarango/vendor/composer/ClassLoader.php(344): Composer\Autoload\includeFile('/Users/sebastia...')
#3 /Users/sebastian/Development/fresh-smarango/vendor/dillingham/nova-assertions/src/NovaResponse.php(17): Composer\Autoload\ClassLoader->loadClass('NovaTesting\\Ass...')
#4 /Users/sebastian/Development/fresh-smarango/vendor/composer/ClassLoader.php(476): include('/Users/sebastia...')
#5 /Users/sebastian/Development/fresh-smarango/vendor/composer/ClassLoader.php(344): Composer\Autoload\includeFile('/Users/sebastia...')
#6 /Users/sebastian/Development/fresh-smarango/vendor/dillingham/nova-assertions/src/NovaAssertions.php(18): Composer\Autoload\ClassLoader->loadClass('NovaTesting\\Nov...')
#7 /Users/sebastian/Development/fresh-smarango/tests/Nova/UserResourceTest.php(27): Tests\Nova\UserResourceTest->novaIndex('users')
#8 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/Framework/TestCase.php(1526): Tests\Nova\UserResourceTest->test_render_users_index_resource_page()
#9 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/Framework/TestCase.php(1132): PHPUnit\Framework\TestCase->runTest()
#10 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/Framework/TestResult.php(722): PHPUnit\Framework\TestCase->runBare()
#11 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/Framework/TestCase.php(884): PHPUnit\Framework\TestResult->run(Object(Tests\Nova\UserResourceTest))
#12 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): PHPUnit\Framework\TestCase->run(Object(PHPUnit\Framework\TestResult))
#13 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#14 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(667): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#15 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/TextUI/Command.php(143): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\Framework\TestSuite), Array, Array, true)
#16 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/src/TextUI/Command.php(96): PHPUnit\TextUI\Command->run(Array, true)
#17 /Users/sebastian/Development/fresh-smarango/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#18 {main} in /Users/sebastian/Development/fresh-smarango/vendor/dillingham/nova-assertions/src/NovaResponse.php on line 17

Fatal error: Uncaught ErrorException: Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop' in /Users/sebastian/Development/fresh-smarango/vendor/symfony/error-handler/Error/FatalError.php:37
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Function must b...', '/Users/sebastia...', 37)
#1 /Users/sebastian/Development/fresh-smarango/vendor/symfony/error-handler/Error/FatalError.php(37): xdebug_get_function_stack()
#2 /Users/sebastian/Development/fresh-smarango/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(143): Symfony\Component\ErrorHandler\Error\FatalError->__construct('During class fe...', 0, Array, 0)
#3 /Users/sebastian/Development/fresh-smarango/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(130): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalErrorFromPhpError(Array, 0)
#4 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#5 {main}
  thrown in /Users/sebastian/Development/fresh-smarango/vendor/symfony/error-handler/Error/FatalError.php on line 37

Process finished with exit code 255

AssertFields has an Error

The method fieldCheck has an error: PHP Fatal error: During class fetch: Uncaught ErrorException: Required parameter $method follows optional parameter $value in /Users/arasivaneswaran/Documents/repos/ccp-kin-ball-v5/vendor/dillingham/nova-assertions/src/Assert/AssertFields.php:47

protected function fieldCheck($attribute, $value = null, $method)

example tests

$this->actingAs(factory(User::class)->create());

$this->novaIndex('workflows', [
    WorkflowStatus::class => 'staged_at'
])->assertResourceCount(1);

$this->novaIndex('workflows')->assertCanCreate();

$this->novaIndex('workflows')
    ->assertFilterCount(1)
    ->assertFiltersInclude(WorkflowStatus::class)
    ->assertCardCount(1)
    ->assertCardsInclude(CountProposalsCreated::class)
    ->assertResourceCount(4)
    ->assertFieldCount(4)
    ->assertFieldsInclude('id')
    ->assertFieldsInclude(['id', 'title'])
    ->assertFieldsInclude($workflows[0]->only(['id', 'title']))
    ->assertFieldsInclude('id', $workflows->pluck('id'))
    ->assertLensCount(1)
    ->assertLensesInclude(ActivatedUsers::class)
    ->assertActionCount(1)
    ->assertResources(function ($resources) {
        return $resources->count() == 4;
    })->assertLenses(function ($lenses) {
        return $lenses->count() == 1;
    })->assertActions(function ($actions) {
        return $actions->count() == 1;
    })->assertCards(function ($cards) {
        return $cards->count() == 1;
    })->assertFilters(function ($filters) {
        return $filters->count() == 1;
    })->assertFields(function ($fields) {
        return $fields->count() == 4;
    })->assertActionsInclude(Launch::class);

$this->novaLens('workflows', ActivatedUsers::class)
    ->assertResourceCount(4)
    ->assertFieldsInclude('id');

Bump Package Version

The most recent PR #20 was merged, but a package version was not published.

Any plans on pushing a tag?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.