gregdmat / laravel-test-utilities

Stars
0

Instalation

composer require gregdmat/laravel-test-utilities

php artisan ltu:intall

Assert Structure and Value

Data Cases

This feature provides several scenarios for a data type.
  • Modify dataCases config to remove some data case.

  • Types of data available.

    • String
    • Integer
  • Basic usage:

$teste = new DataCases();
        
$teste->get([
    'attribute' => 'type',
    'name' => 'string'
]);
  • Avaible methods

    • get: return an array of cases
      $teste->get([
        'attribute' => 'type',
        'name' => 'string'
      ]);  
    
      $teste->make(
        [
          'attribute' => 'type',
          'name' => 'string'
        ],
        Model::class
      );  
    
      $teste->create(
        [
          'attribute' => 'type',
          'name' => 'string'
        ],
        Model::class
      );  
    
  • Options

    When instantiating the DataCases class, it is possible to pass an array of options to the constructor.

$teste = new DataCases([
    'integer' => [
        'except' => ['negative', 'positive'],
        'positive.min' => 1,
        'positive.max' => 3,
    ]
]);
  • Avaible options
   - except (array of name cases);
   - small.size;
   - normal.size;
   - long.size;
   - negative.min;
   - negative.max;
   - positive.min
   - positive.max
  • Avaible cases (see in the config file).