mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Tests for wave
This commit is contained in:
parent
a0439f23b2
commit
95861a2a8c
@ -149,9 +149,13 @@ class BaseImport
|
||||
{
|
||||
$count = 0;
|
||||
nlog("record count = ".count($data));
|
||||
foreach ($data as $key => $record) {
|
||||
try {
|
||||
nlog($data);
|
||||
|
||||
foreach ($data as $key => $record) {
|
||||
|
||||
try {
|
||||
nlog($key);
|
||||
nlog($record);
|
||||
$entity = $this->transformer->transform($record);
|
||||
nlog($entity);
|
||||
/** @var \App\Http\Requests\Request $request */
|
||||
@ -179,10 +183,15 @@ nlog("saving {$entity->name}");
|
||||
$entity->saveQuietly();
|
||||
$count++;
|
||||
|
||||
nlog("entity number");
|
||||
nlog($entity->id);
|
||||
nlog("after save");
|
||||
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
nlog($e->getMessage());
|
||||
nlog("exception");
|
||||
nlog($ex->getMessage());
|
||||
|
||||
if ($ex instanceof ImportException) {
|
||||
$message = $ex->getMessage();
|
||||
@ -191,6 +200,8 @@ nlog($e->getMessage());
|
||||
$message = 'Unknown error';
|
||||
}
|
||||
|
||||
nlog($message);
|
||||
|
||||
$this->error_array[$entity_type][] = [
|
||||
$entity_type => $record,
|
||||
'error' => $message,
|
||||
|
@ -48,10 +48,10 @@ class Wave extends BaseImport implements ImportInterface
|
||||
$entity_type = 'client';
|
||||
|
||||
$data = $this->getCsvData($entity_type);
|
||||
nlog($data);
|
||||
// nlog($data);
|
||||
|
||||
$data = $this->preTransform($data, $entity_type);
|
||||
nlog($data);
|
||||
// nlog($data);
|
||||
|
||||
if (empty($data)) {
|
||||
$this->entity_count['clients'] = 0;
|
||||
@ -72,6 +72,7 @@ nlog($data);
|
||||
$this->entity_count['clients'] = $client_count;
|
||||
|
||||
nlog($this->entity_count);
|
||||
nlog($this->error_array);
|
||||
}
|
||||
|
||||
public function transform(array $data){}
|
||||
|
@ -13,6 +13,7 @@ namespace Tests\Feature\Import\CSV;
|
||||
|
||||
use App\Import\Providers\Wave;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Models\Client;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
@ -52,31 +53,40 @@ class WaveTest extends TestCase
|
||||
$hash = Str::random(32);
|
||||
|
||||
$column_map = [
|
||||
0 => 'client.name',
|
||||
1 => 'contact.email',
|
||||
2 => 'contact.first_name',
|
||||
3 => 'contact.last_name',
|
||||
4 => 'client.currency_id',
|
||||
6 => 'client.phone',
|
||||
10 => 'client.website',
|
||||
11 => 'client.country_id',
|
||||
12 => 'client.state',
|
||||
13 => 'client.address1',
|
||||
14 => 'client.address2',
|
||||
15 => 'client.city',
|
||||
16 => 'client.postal_code',
|
||||
19 => 'client.shipping_country_id',
|
||||
20 => 'client.shipping_state',
|
||||
21 => 'client.shipping_address1',
|
||||
22 => 'client.shipping_address2',
|
||||
23 => 'client.shipping_city',
|
||||
0 => 'customer_name',
|
||||
1 => 'email',
|
||||
2 => 'contact_first_name',
|
||||
3 => 'contact_last_name',
|
||||
4 => 'customer_currency',
|
||||
// 5 => 'account_number',
|
||||
6 => 'phone',
|
||||
7 => 'fax',
|
||||
8 => 'mobile',
|
||||
9 => 'toll_free',
|
||||
10 => 'website',
|
||||
11 => 'country',
|
||||
12 => 'province/state',
|
||||
13 => 'address_line_1',
|
||||
14 => 'address_line_2',
|
||||
15 => 'city',
|
||||
16 => 'postal_code/zip_code',
|
||||
17 => 'shipping_address',
|
||||
18 => 'ship-to_contact',
|
||||
19 => 'ship-to_country',
|
||||
20 => 'ship-to_province/state',
|
||||
21 => 'ship-to_address_line_1',
|
||||
22 => 'ship-to_address_line_2',
|
||||
23 => 'ship-to_city',
|
||||
24 => 'ship-to_postal_code/zip_code',
|
||||
25 => 'ship-to_phone',
|
||||
26 => 'delivery_instructions',
|
||||
];
|
||||
|
||||
$data = [
|
||||
'hash' => $hash,
|
||||
'column_map' => ['client' => ['mapping' => $column_map]],
|
||||
'skip_header' => true,
|
||||
'import_type' => 'wave',
|
||||
'import_type' => 'waveaccounting',
|
||||
];
|
||||
|
||||
Cache::put($hash . '-client', base64_encode($csv), 360);
|
||||
@ -88,9 +98,9 @@ class WaveTest extends TestCase
|
||||
$base_transformer = new BaseTransformer($this->company);
|
||||
|
||||
$this->assertTrue($base_transformer->hasClient('Homer Simpson'));
|
||||
// $this->assertTrue($base_transformer->hasClient('Jessica Jones'));
|
||||
// $this->assertTrue($base_transformer->hasClient('Lucas Cage'));
|
||||
// $this->assertTrue($base_transformer->hasClient('Mark Walberg'));
|
||||
$this->assertTrue($base_transformer->hasClient('Jessica Jones'));
|
||||
$this->assertTrue($base_transformer->hasClient('Lucas Cage'));
|
||||
$this->assertTrue($base_transformer->hasClient('Mark Walberg'));
|
||||
|
||||
}
|
||||
|
||||
|
@ -233,6 +233,8 @@ trait MockAccountData
|
||||
$user_id = $user->id;
|
||||
$this->user = $user;
|
||||
|
||||
auth()->login($user);
|
||||
|
||||
CreateCompanyTaskStatuses::dispatchNow($this->company, $this->user);
|
||||
|
||||
$this->cu = CompanyUserFactory::create($user->id, $this->company->id, $this->account->id);
|
||||
|
Loading…
Reference in New Issue
Block a user