2023-04-24 06:55:56 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Tests\Feature\Export;
|
|
|
|
|
2023-08-21 03:29:31 +02:00
|
|
|
use Tests\TestCase;
|
|
|
|
use Tests\MockAccountData;
|
2023-04-24 06:55:56 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2023-08-21 03:29:31 +02:00
|
|
|
use Illuminate\Support\Facades\Event;
|
2023-04-24 06:55:56 +02:00
|
|
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
2023-08-21 03:29:31 +02:00
|
|
|
use Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;
|
2023-04-24 06:55:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
class ReportApiTest extends TestCase
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
use MockAccountData;
|
2023-08-21 03:29:31 +02:00
|
|
|
|
2023-04-24 06:55:56 +02:00
|
|
|
public $faker;
|
|
|
|
|
|
|
|
protected function setUp() :void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->faker = \Faker\Factory::create();
|
|
|
|
|
|
|
|
$this->withoutMiddleware(
|
|
|
|
ThrottleRequests::class
|
|
|
|
);
|
|
|
|
|
2023-08-21 03:29:31 +02:00
|
|
|
// $this->withoutExceptionHandling();
|
2023-04-24 06:55:56 +02:00
|
|
|
$this->makeTestData();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-08-27 14:02:55 +02:00
|
|
|
|
|
|
|
public function testActivityCSVExport()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/activities', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-04-24 06:55:56 +02:00
|
|
|
public function testUserSalesReportApiRoute()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/user_sales_report', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testTaxSummaryReportApiRoute()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/tax_summary_report', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testClientSalesReportApiRoute()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/client_sales_report', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testArDetailReportApiRoute()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/ar_detail_report', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testArSummaryReportApiRoute()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/ar_summary_report', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-08-27 14:02:55 +02:00
|
|
|
|
|
|
|
|
2023-04-24 06:55:56 +02:00
|
|
|
public function testClientBalanceReportApiRoute()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'send_email' => false,
|
|
|
|
'date_range' => 'all',
|
|
|
|
'report_keys' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/reports/client_balance_report', $data)
|
|
|
|
->assertStatus(200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|