1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/tests/Integration/UpdateCompanyUserTest.php
Shift 4f7a8f9752
Set return type of base TestCase methods
From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html
2022-06-21 10:00:57 +00:00

71 lines
1.8 KiB
PHP

<?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\Integration;
use App\Models\CompanyUser;
use App\Models\User;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Http\Controllers\CompanyUserController
*/
class UpdateCompanyUserTest extends TestCase
{
use MakesHash;
use MockAccountData;
use DatabaseTransactions;
protected function setUp() :void
{
parent::setUp();
$this->makeTestData();
}
public function testUpdatingCompanyUserAsAdmin()
{
// User::unguard();
$settings = new \stdClass;
$settings->invoice = 'ninja';
$company_user = CompanyUser::whereUserId($this->user->id)->whereCompanyId($this->company->id)->first();
$company_user->settings = $settings;
$this->user->company_user = $company_user;
$user['company_user'] = $company_user->toArray();
$response = null;
try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/company_users/'.$this->encodePrimaryKey($this->user->id), $user);
} catch (ValidationException $e) {
$message = json_decode($e->validator->getMessageBag(), 1);
$this->assertNotNull($message);
}
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals('ninja', $arr['data']['settings']['invoice']);
}
}