PhyrePanel-mirror/web/tests/Unit/HostingSubscriptionsTest.php
2024-04-22 14:14:05 +03:00

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');
}
}