Hello everybody!
When i run api test with phpBrowser and controller has other errors (domain, error, throwable), i see this error in json response:
1) AuthCest: Try to test
Test tests/api/AuthCest.php:tryToTest
Step See response contains json {"data":[]}
Fail Response JSON does not contain the provided JSON
- Expected | + Actual
@@ @@
Array (
- 'data' => Array ()
+ 'errors' => Array (...)
)
Scenario Steps:
2. $I->seeResponseContainsJson({"data":[]}) at tests/api/AuthCest.php:23
1. $I->sendPost("/brand/list") at tests/api/AuthCest.php:20
When i use functional tests, i have error in tests. I see this:
How can i change this behaviour and see like api tests?
I change some settings in error handler component silentExitOnException => true and YII_ENV_TEST => true , but nothing.
I got error because DomainExeception is not HttpException:
My config in api.suite.yml:
actor: ApiTester
modules:
enabled:
- Yii2
- REST:
depends: Yii2
part: json
shortDebugResponse: 600
- Db
- \Helper\Api
Code for test:
<?php
use Codeception\Util\Debug;
use cosmetic\entity\user\User;
use cosmetic\store\db\UsersStore;
use yii\helpers\VarDumper;
class AuthCest
{
public function _before(ApiTester $I)
{
}
// tests
public function tryToTest(ApiTester $I)
{
$I->sendPost("/brand/list");
$I->seeResponseContainsJson([
'data' => []
]);
}
}