PHP code example of romegasoftware / nova-test-suite

1. Go to this page and download the library: Download romegasoftware/nova-test-suite 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/ */

    

romegasoftware / nova-test-suite example snippets


protected function remapResource($resource): array
{
    return [
        'location' => $resource->location_id,
        'theme' => $resource->theme_id,
    ];
}

// retrieve all available resources = viewing the index page
$this->getResources();

// retrieve a single resource = viewing a single resource in detail view
$resource = Resource::factory()->create();
$this->getResources($resource);

// resource data is generated behind the scenes with factory()->make()
$this->storeResource();

// also accepts model classes or arrays
$resource = Resource::factory()->make();
$this->storeResource($resource);
$this->storeResource(['name' => 'Vader']);

// resource data is generated behind the scenes with factory()->create()
$this->updateResource(['name' => 'Vader']);

// accepts model classes
$resource = Resource::factory()->create();
$resource->name = 'Vader';
$this->updateResource($resource);

// resource data is generated behind the scenes with factory()->create()
$this->deleteResource();

// also accepts model classes, arrays or integers (ids)
$resource = Resource::factory()->create();
$this->deleteResource($resource);
$this->deleteResource(['id' => 12]);
$this->deleteResource(12);

$this->assertHasManyRelationships([
    'product',
]);
$this->assertBelongsToRelationships([
    'user',
]);

$this->storeResource()
  ->assertNovaFailed();

$this->setNullValuesOn(['customer', 'number_of_participants'])
  ->storeResource()
  ->assertRequiredFields(['customer', 'number_of_participants']);

protected function getDefaultUser()
{
    return $this->yourOwnUser;
}

$this->storeResource()
  ->assertSessionDoesntHaveErrors();

$this->withoutNovaExceptionHandling()
  ->storeResource();