Skip to content

Instantly share code, notes, and snippets.

@Shtangatopor
Created August 26, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shtangatopor/15402c71be7a03fb7a835478c2bc6394 to your computer and use it in GitHub Desktop.
Save Shtangatopor/15402c71be7a03fb7a835478c2bc6394 to your computer and use it in GitHub Desktop.
<?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