Add tests for the Item validations.
continuous-integration/drone/push Build is passing Details

main
KKlochko 2 years ago
parent aedb4d5949
commit 751921e83f

@ -0,0 +1,39 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\Item;
class ItemTest extends TestCase
{
/* Item validation */
public function test_item_with_empty_name(): void
{
$json = Item::validate_with_name('');
$this->assertEquals($json['error'], 'The item name is empty, please, write the name!!!');
}
public function test_not_existing_item_with_name(): void
{
$name = '404 Item';
$json = Item::validate_with_name($name);
$this->assertEquals($json['error'], 'A item with the name does not exist!!!');
}
public function test_valid_item_with_name(): void
{
$name = 'Pizza Polo';
$json = Item::validate_with_name($name);
$this->assertEquals($json['ok'], 'A item with the name is valid.');
}
}
Loading…
Cancel
Save