PHP code example of codicastudio / tests-admin
1. Go to this page and download the library: Download codicastudio/tests-admin library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codicastudio / tests-admin example snippets
use NovaTesting\NovaAssertions;
class UserTest extends TestCase
{
use NovaAssertions;
}
$this->be(factory(User::class)->create());
$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);
$response = $this->novaIndex('users', [
StatusFilter::class => 'active'
]);
$response = $this->novaLens('users', Lens::class, [
StatusFilter::class => 'active'
]);
$response->assertOk();
$response->assertResourceCount(3);
$response->assertResources(function($resources) {
return $resources->count() > 0;
});
$response->assertCardCount(5);
$response->assertCardsInclude(Card::class);
$response->assertCardsExclude(Card::class);
$response->assertCards(function($cards) {
return $cards->count() > 0;
});
$response->assertActionCount(5);
$response->assertActionsInclude(Action::class);
$response->assertActionsExclude(Action::class);
$response->assertActions(function($actions) {
return $actions->count() > 0;
});
$response->assertFilterCount(5);
$response->assertFiltersInclude(Filter::class);
$response->assertFiltersExclude(Filter::class);
$response->assertFilters(function($filters) {
return $filters->count() > 0;
});
$response->assertLensCount(5);
$response->assertLensesInclude(Lens::class);
$response->assertLensesExclude(Lens::class);
$response->assertLenses(function($lenses) {
return $lenses->count() > 0;
});
$response->assertFieldCount(5);
$response->assertFieldsInclude('id');
$response->assertFieldsInclude('id', $user->id);
$response->assertFieldsInclude(['id', 'email']);
$response->assertFieldsInclude(['id' => 1, 'email' => 'example']);
$response->assertFieldsInclude('id', $users->pluck('id'));
$response->assertFields(function($fields) {
return $fields->count() > 0;
});
$response->assertFieldsExclude(['id' => 1, 'email' => 'example']);
// 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) {
//
});
$response->assertCanView();
$response->assertCanCreate();
$response->assertCanUpdate();
$response->assertCanDelete();
$response->assertCanForceDelete();
$response->assertCanRestore();
$response->assertCannotView();