1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Updated test files to be PSR-4 compliant

Closes #1924
This commit is contained in:
Dan Brown
2020-04-04 01:16:05 +01:00
parent 3500182c5f
commit f84bf8e883
33 changed files with 89 additions and 62 deletions

View File

@ -1,10 +1,9 @@
<?php
namespace Tests;
<?php namespace Tests\Api;
use BookStack\Auth\Permissions\RolePermission;
use BookStack\Auth\User;
use Carbon\Carbon;
use Tests\TestCase;
class ApiAuthTest extends TestCase
{

View File

@ -1,9 +1,6 @@
<?php
<?php namespace Tests\Api;
namespace Tests;
use BookStack\Auth\Permissions\RolePermission;
use Carbon\Carbon;
use Tests\TestCase;
class ApiConfigTest extends TestCase
{

View File

@ -1,6 +1,6 @@
<?php
<?php namespace Tests\Api;
namespace Tests;
use Tests\TestCase;
class ApiDocsTest extends TestCase
{

View File

@ -1,8 +1,7 @@
<?php
namespace Tests;
<?php namespace Tests\Api;
use BookStack\Entities\Book;
use Tests\TestCase;
class ApiListingTest extends TestCase
{

View File

@ -1,6 +1,7 @@
<?php namespace Tests;
<?php namespace Tests\Api;
use BookStack\Entities\Book;
use Tests\TestCase;
class BooksApiTest extends TestCase
{

36
tests/Api/TestsApi.php Normal file
View File

@ -0,0 +1,36 @@
<?php namespace Tests\Api;
trait TestsApi
{
protected $apiTokenId = 'apitoken';
protected $apiTokenSecret = 'password';
/**
* Set the API editor role as the current user via the API driver.
*/
protected function actingAsApiEditor()
{
$this->actingAs($this->getEditor(), 'api');
return $this;
}
/**
* Format the given items into a standardised error format.
*/
protected function errorResponse(string $message, int $code): array
{
return ["error" => ["code" => $code, "message" => $message]];
}
/**
* Get an approved API auth header.
*/
protected function apiAuthHeader(): array
{
return [
"Authorization" => "Token {$this->apiTokenId}:{$this->apiTokenSecret}"
];
}
}