@mdemori it's expected behavior when you use DatabaseMigrations
What's the problem to re-create quotation using factory? https://laravel.com/docs/8.x/database-testing#defining-model-factories
Hi,
I've a test class with two distinct tests where I need to maintain data between two test inside the db. Everything is configured as sqlite in memory db.
The problem is that after executing the test_create_quotation_from_external_system (see below the example) the db seem reset to an empty state, so the test_create_quotation_if_quotation_alredy_exists don't find any data inside the table.
How can I preserve the data between tests ?
Below an example of my test, without data but only with relevant information:
<?php
namespace Services\QuotationService;
use Mockery as m;
use Tests\TestCase;
use App\Models\Order;
class QuotationOrderServiceTest extends TestCase
{
use DatabaseMigrations;
public function setUp(): void
{
parent::setUp();
}
public function test_create_quotation_from_external_system()
{
// some testing stuff that create one single line inside the database
self::assertEquals(1,
Order::count(),
'Failed to create quotation request');
}
public function test_create_quotation_if_quotation_alredy_exists()
{
//this test fail here, because the Order Table is always empty
self::assertEquals(1,
Order::count(),
'Failed to check quotation creations if quotation already exists.');
// some testing stuff that reload same data from previous test but don't create the new line because same
//quotation number already exists.
// in this case to be sure that everything was correct, i need to check that the db has one single row like
// the previous test.
self::assertEquals(1,
Order::count(),
'Failed to create quotation request');
}
@mdemori it's expected behavior when you use DatabaseMigrations
What's the problem to re-create quotation using factory? https://laravel.com/docs/8.x/database-testing#defining-model-factories
Please or to participate in this conversation.