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

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