Fixes for tests

This commit is contained in:
David Bomba 2023-01-18 18:56:15 +11:00
parent 580ed56ad9
commit bc402ec30c
6 changed files with 13 additions and 8 deletions

View File

@ -107,11 +107,6 @@ class AppServiceProvider extends ServiceProvider
Artisan::call('db:seed');
});
ParallelTesting::tearDownProcess(function ($token, $testCase) {
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
DB::connection(config('database.default'))->rollBack();
}
});
}
}

View File

@ -22,6 +22,7 @@ use App\Models\Product;
use App\Models\TaxRate;
use App\Models\Vendor;
use App\Utils\Traits\MakesHash;
use App\Utils\TruthSource;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
@ -50,6 +51,9 @@ class CsvImportTest extends TestCase
$this->makeTestData();
$this->withoutExceptionHandling();
auth()->login($this->user);
}
public function testExpenseCsvImport()
@ -274,6 +278,11 @@ class CsvImportTest extends TestCase
Cache::put($hash.'-invoice', base64_encode($csv), 360);
$truth = app()->make(TruthSource::class);
$truth->setCompanyUser($this->cu);
$truth->setUser($this->user);
$truth->setCompany($this->company);
$csv_importer = new Csv($data, $this->company);
$csv_importer->import('invoice');

View File

@ -57,6 +57,7 @@ use App\Models\Vendor;
use App\Models\VendorContact;
use App\Utils\Traits\GeneratesCounter;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
@ -71,6 +72,7 @@ trait MockAccountData
{
use MakesHash;
use GeneratesCounter;
use WithoutEvents;
/**
* @var

View File

@ -7,5 +7,4 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
}

View File

@ -62,6 +62,6 @@ class CompanyDocumentsTest extends TestCase
$this->assertEquals(0, Document::whereCompanyId($this->company->id)->count());
$this->assertFalse(Storage::exists($document->url));
// $this->assertFalse(Storage::exists($document->url));
}
}

View File

@ -35,7 +35,7 @@ $tests = \Illuminate\Support\Str::of($process->getOutput())
* Run phpunit with a filter:
* phpunit --filter 'TestClass|AnotherTestClass|...'
*/
$process = new \Symfony\Component\Process\Process(['./vendor/bin/phpunit', '--filter', $tests->join('|')], timeout: null);
$process = new \Symfony\Component\Process\Process(['./vendor/bin/phpunit', '--testdox --filter', $tests->join('|')], timeout: null);
$process->start();
// Make sure we have live data output