mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Tests for data collecting
This commit is contained in:
parent
6dd9a6724f
commit
2dd98ccbc5
@ -179,6 +179,7 @@ class TemplateTest extends TestCase
|
|||||||
|
|
||||||
public function testDataMaps()
|
public function testDataMaps()
|
||||||
{
|
{
|
||||||
|
$start = microtime(true);
|
||||||
|
|
||||||
Invoice::factory()->count(10)->create([
|
Invoice::factory()->count(10)->create([
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
@ -233,6 +234,8 @@ class TemplateTest extends TestCase
|
|||||||
|
|
||||||
// nlog($p->toArray());
|
// nlog($p->toArray());
|
||||||
|
|
||||||
|
$start = microtime(true);
|
||||||
|
|
||||||
$p = Payment::with('client','invoices','paymentables','credits')
|
$p = Payment::with('client','invoices','paymentables','credits')
|
||||||
->where('id', $this->decodePrimaryKey($arr['data']['id']))
|
->where('id', $this->decodePrimaryKey($arr['data']['id']))
|
||||||
->cursor()
|
->cursor()
|
||||||
@ -242,9 +245,15 @@ class TemplateTest extends TestCase
|
|||||||
|
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
|
|
||||||
|
nlog("end payments = " . microtime(true) - $start);
|
||||||
|
|
||||||
$this->assertIsArray($data);
|
$this->assertIsArray($data);
|
||||||
|
|
||||||
$invoices = Invoice::with('client','payments','credits')
|
$start = microtime(true);
|
||||||
|
\DB::enableQueryLog();
|
||||||
|
|
||||||
|
$invoices = Invoice::with('client','payments.client','payments.paymentables','payments.credits','credits.client')
|
||||||
->orderBy('id','desc')
|
->orderBy('id','desc')
|
||||||
->where('client_id', $this->client->id)
|
->where('client_id', $this->client->id)
|
||||||
->take(10)
|
->take(10)
|
||||||
@ -252,6 +261,7 @@ class TemplateTest extends TestCase
|
|||||||
->map(function($invoice){
|
->map(function($invoice){
|
||||||
|
|
||||||
$payments = $invoice->payments->map(function ($payment){
|
$payments = $invoice->payments->map(function ($payment){
|
||||||
|
nlog(microtime(true));
|
||||||
return $this->transformPayment($payment);
|
return $this->transformPayment($payment);
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
@ -312,8 +322,15 @@ class TemplateTest extends TestCase
|
|||||||
];
|
];
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
|
$queries = \DB::getQueryLog();
|
||||||
|
$count = count($queries);
|
||||||
|
|
||||||
|
nlog("query count = {$count}");
|
||||||
|
nlog($invoices);
|
||||||
$this->assertIsArray($invoices);
|
$this->assertIsArray($invoices);
|
||||||
|
|
||||||
|
nlog("end invoices = " . microtime(true) - $start);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function transformPayment(Payment $payment): array
|
private function transformPayment(Payment $payment): array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user