update tests

This commit is contained in:
karneaud 2024-08-08 12:56:36 -04:00
parent 6cea02684c
commit f2755aa1f4
2 changed files with 27 additions and 36 deletions

View File

@ -38,7 +38,7 @@ class ImportQuickbooksControllerTest extends TestCase
Session::start(); Session::start();
app()->singleton(QuickbooksInterface::class, fn() => new QuickbooksSDK($this->mock)); //app()->singleton(QuickbooksInterface::class, fn() => new QuickbooksSDK($this->mock));
} }
public function testAuthorize(): void public function testAuthorize(): void
@ -88,47 +88,38 @@ class ImportQuickbooksControllerTest extends TestCase
$this->mock->shouldHaveReceived('exchangeAuthorizationCodeForToken')->once()->with(123456,12345678); $this->mock->shouldHaveReceived('exchangeAuthorizationCodeForToken')->once()->with(123456,12345678);
} }
// public function testImport(): void public function testImport(): void
// { {
// Cache::spy(); // Cache::spy();
// Bus::fake(); //Bus::fake();
// $this->mock->shouldReceive('Query')->andReturnUsing( $data = $this->setUpTestData('customers');
// function($val, $s = 1, $max = 1000) use ($count, $data) { $count = count($data);
// if(stristr($val, 'count')) { $this->mock->shouldReceive('Query')->andReturnUsing(
// return $count; function($val, $s = 1, $max = 1000) use ($count, $data) {
// } if(stristr($val, 'count')) {
return $count;
}
// return Arr::take($data,$max); return Arr::take($data,$max);
// } }
// ); );
// $this->setUpTestData('customers');
// // Perform the test // Perform the test
// $response = $this->withHeaders([ $response = $this->actingAs($this->user)->withHeaders([
// 'X-API-TOKEN' => $this->token, 'X-API-TOKEN' => $this->token,
// ])->post('/api/v1/import/quickbooks/preimport',[ ])->post('/api/v1/import/quickbooks',[
// 'import_type' => 'client' 'import_types' => ['client']
// ]); ]);
// $response->assertStatus(200); $response->assertStatus(200);
// $response = json_decode( $response->getContent());
// $this->assertNotNull($response->hash);
// $hash = $response->hash;
// $response = $this->withHeaders([
// 'X-API-TOKEN' => $this->token,
// ])->post('/api/v1/import/quickbooks',[
// 'import_type' => 'client',
// 'hash' => $response->hash
// ]);
// $response->assertStatus(200);
// Cache::shouldHaveReceived('has')->once()->with("{$hash}-client"); //Cache::shouldHaveReceived('has')->once()->with("{$hash}-client");
// Bus::assertDispatched(\App\Jobs\Import\QuickbooksIngest::class); //Bus::assertDispatched(\App\Jobs\Import\QuickbooksIngest::class);
// } }
protected function setUpTestData($file) { protected function setUpTestData($file) {
$data = json_decode( $data = json_decode(
file_get_contents(base_path("tests/Mock/Quickbooks/Data/$file.json")),true file_get_contents(base_path("tests/Mock/Quickbooks/Data/$file.json")),true
); );
$count = count($data);
return $data; return $data;
} }

View File

@ -46,7 +46,7 @@ class QuickbooksIngestTest extends TestCase
'hash' => $hash, 'hash' => $hash,
'column_map' => ['client' => ['mapping' => []]], 'column_map' => ['client' => ['mapping' => []]],
'skip_header' => true, 'skip_header' => true,
'import_type' => 'quickbooks', 'import_types' => ['client'],
], $this->company )->handle(); ], $this->company )->handle();
$this->assertTrue(Client::withTrashed()->where(['company_id' => $this->company->id, 'name' => "Freeman Sporting Goods"])->exists()); $this->assertTrue(Client::withTrashed()->where(['company_id' => $this->company->id, 'name' => "Freeman Sporting Goods"])->exists());
} }