mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 17:10:29 +00:00
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Unit;
|
||
|
|
||
|
use App\Http\Middleware\ApiKeyMiddleware;
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use Tests\Feature\Api\ActionTestCase;
|
||
|
|
||
|
class HostingSubscriptionsTest extends ActionTestCase
|
||
|
{
|
||
|
|
||
|
function test_route_contains_middleware()
|
||
|
{
|
||
|
$this->assertRouteContainsMiddleware(
|
||
|
'api.hosting-subscriptions.index',
|
||
|
ApiKeyMiddleware::class
|
||
|
);
|
||
|
$this->assertRouteContainsMiddleware(
|
||
|
'api.hosting-subscriptions.store',
|
||
|
ApiKeyMiddleware::class
|
||
|
);
|
||
|
$this->assertRouteContainsMiddleware(
|
||
|
'api.hosting-subscriptions.update',
|
||
|
ApiKeyMiddleware::class
|
||
|
);
|
||
|
$this->assertRouteContainsMiddleware(
|
||
|
'api.hosting-subscriptions.destroy',
|
||
|
ApiKeyMiddleware::class
|
||
|
);
|
||
|
}
|
||
|
|
||
|
function test_index()
|
||
|
{
|
||
|
// Make unauthorized call
|
||
|
$callUnauthorizedResponse = $this->callRouteAction('api.hosting-subscriptions.index')->json();
|
||
|
$this->assertArrayHasKey('error', $callUnauthorizedResponse);
|
||
|
$this->assertTrue($callUnauthorizedResponse['error'] == 'Unauthorized');
|
||
|
|
||
|
// Make authorized call
|
||
|
$callResponse = $this->callApiAuthorizedRouteAction('api.hosting-subscriptions.index')->json();
|
||
|
|
||
|
$this->assertArrayHasKey('data', $callResponse);
|
||
|
$this->assertArrayHasKey('message', $callResponse);
|
||
|
$this->assertArrayHasKey('status', $callResponse);
|
||
|
$this->assertArrayHasKey('hostingSubscriptions', $callResponse['data']);
|
||
|
$this->assertIsArray($callResponse['data']['hostingSubscriptions']);
|
||
|
$this->assertIsString($callResponse['message']);
|
||
|
$this->assertIsString($callResponse['status']);
|
||
|
$this->assertTrue($callResponse['status'] == 'ok');
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|