I have the following configuration in my api.suite.yml
file:
actor: ApiTester
modules:
enabled:
- \common\tests\Helper\Api
- Yii2:
part:
- orm
- fixtures
- REST:
url: http://***ru-local/api/v1/
depends: PhpBrowser
In codeception.yml
:
modules:
config:
Yii2:
configFile: 'config/test-local.php'
Db:
dsn: 'mysql:host=db;dbname=***_test;charset=utf8mb4'
user: 'root'
password: ''
databases:
db:
dsn: 'mysql:host=db;dbname=***_test;charset=utf8mb4'
user: 'root'
password: ''
reconnect: true
In the tests:
public function _fixtures(): array
{
return [
'customers' => [
'class' => CustomersFixture::class,
'dataFile' => $this->getDataDir() . 'customers.php',
],
'customerSubscribes' => [
'class' => CustomerSubscribesFixture::class,
'dataFile' => $this->getDataDir() . 'customer_subscribes.php',
],
];
}
public function testGetActiveExpertSubscribe(ApiTester $I)
{
$I->haveHttpHeader('accept', 'application/json');
$I->haveHttpHeader('content-type', 'application/json');
$I->haveHttpHeader('Cookie', 'webapp-backend=mahgr8qki47aef5c2a27n0tsum');
$I->sendGET("/customers/{$this->customer->id}/active-expert-subscribe");
}
During the execution of sendGET
, it returns values from the main database instead of from the fixtures.