Created
August 26, 2020 10:49
-
-
Save Shtangatopor/15402c71be7a03fb7a835478c2bc6394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Tests; | |
use App\Tests\ApiTester; | |
use App\Tests\Helper\Api; | |
class categoriesCest | |
{ | |
public function _before(ApiTester $I) | |
{ | |
} | |
// tests | |
public function checkPagesIntoCategories(ApiTester $I, Api $api) | |
{ | |
$api->authorization('1', '1'); | |
$categories = $api->getCategoriesId(); | |
foreach ($categories as $category) { | |
$uri = '/api/categories/' . $category . '/pages'; | |
$I->sendGET("$uri"); | |
$I->seeResponseCodeIs('200'); | |
} | |
} | |
public function checkAllowedCategories(ApiTester $I, Api $api) | |
{ | |
$api->authorization('1', '1'); | |
$categories = $api->getCategoriesId(); | |
foreach ($categories as $category) { | |
$uri = '/api/categories/' . $category . '/categories'; | |
$I->sendGET("$uri"); | |
$I->seeResponseCodeIs('200'); | |
$I->makeHtmlSnapshot(); | |
} | |
} | |
public function cantSeeNotAllowedCategories(ApiTester $I, Api $api) | |
{ | |
$all_categories = $api->getAllCategories(); | |
$api->authorization('1', '1'); | |
$allowed_categories = $api->getCategoriesId(); | |
$not_allowed_categories = array_diff($all_categories, $allowed_categories); | |
foreach ($not_allowed_categories as $category) { | |
$uri = '/' . $category; | |
$I->sendGET("$uri"); | |
$I->seeResponseCodeIs('403'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment