1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 00:53:10 +01:00
invoiceninja/tests/Feature/GroupSettingTest.php

98 lines
2.3 KiB
PHP
Raw Normal View History

<?php
2020-09-14 13:11:46 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-09-14 13:11:46 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
namespace Tests\Feature;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
class GroupSettingTest extends TestCase
{
use MakesHash;
2020-11-17 11:26:45 +01:00
//use DatabaseTransactions;
use MockAccountData;
public function setUp(): void
{
parent::setUp();
Session::start();
$this->faker = \Faker\Factory::create();
Model::reguard();
$this->makeTestData();
}
public function testAddGroupSettings()
{
$settings = new \stdClass;
2020-11-17 11:26:45 +01:00
$settings->currency_id = '1';
$data = [
2020-09-08 12:44:32 +02:00
'name' => 'testX',
'settings' => $settings,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/group_settings', $data);
$response->assertStatus(200);
$arr = $response->json();
2020-09-08 12:44:32 +02:00
$this->assertEquals('testX', $arr['data']['name']);
$this->assertEquals(0, $arr['data']['archived_at']);
}
public function testArchiveGroupSettings()
{
$settings = new \stdClass;
2020-11-17 11:26:45 +01:00
$settings->currency_id = '1';
$data = [
2020-09-08 12:44:32 +02:00
'name' => 'testY',
'settings' => $settings,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/group_settings', $data);
$response->assertStatus(200);
$arr = $response->json();
$data = [
'action' => 'archive',
'ids' => [$arr['data']['id']],
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/group_settings/bulk', $data);
$response->assertStatus(200);
$arr = $response->json();
2020-08-02 12:34:16 +02:00
$this->assertNotNull($arr['data'][0]['archived_at']);
}
}