1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/tests/Feature/ActivityApiTest.php

92 lines
2.2 KiB
PHP
Raw Normal View History

<?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;
2023-07-18 05:15:40 +02:00
use Illuminate\Foundation\Testing\DatabaseTransactions;
2023-11-26 08:41:42 +01:00
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Validation\ValidationException;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Http\Controllers\ActivityController
*/
class ActivityApiTest extends TestCase
{
use DatabaseTransactions;
use MockAccountData;
protected function setUp() :void
{
parent::setUp();
$this->makeTestData();
2020-10-22 12:14:14 +02:00
$this->withoutMiddleware(
ThrottleRequests::class
);
2023-07-18 05:15:40 +02:00
$this->withoutExceptionHandling();
}
public function testActivityEntity()
{
$invoice = $this->company->invoices()->first();
$invoice->service()->markSent()->markPaid()->markDeleted()->handleRestore()->save();
$data = [
'entity' => 'invoice',
'entity_id' => $invoice->hashed_id
];
$response = false;
try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/activities/entity', $data);
} catch (ValidationException $e) {
$message = json_decode($e->validator->getMessageBag(), 1);
nlog($message);
}
$response->assertStatus(200);
}
public function testActivityGet()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/activities/');
$response->assertStatus(200);
}
public function testActivityGetWithReact()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/activities?react=true');
$response->assertStatus(200);
}
}