Yii

Yii 2 Codeception Fixtures Gotcha

We use MongoDB (important point) with our Yii 2 applicaton. While setting up our API test fixtures in our Cest file, $I->grabFixture was not able to find the data we wanted eventhough we have defined it within the dataFile. [yii\base\ErrorException] Trying to get property 'client_id' of non-object Here’s what the dataFile looks like. <?php // This doesn't work. return [ 'client_one' => [ 'client_id' => 'mytestclient', ], ]; After some experimentation, we’ve found that we need to set the _id within the dataFile in order to get $I->grabFixture to work properly. ...

<span title='2021-07-17 13:00:00.017 +0800 +0800'>July 17, 2021</span>
Yii

Yii 2 Codeception API Test

My API uses the Yii2 advanced template. It uses symfony/dotenv to read the .env. The .env is loaded in all the configurations. $dotenv = new Symfony\Component\Dotenv\Dotenv; $dotenv->load(__DIR__ . '/../../.env'); While running the Codeception api test, I came across this error. [PHPUnit\Framework\Exception] Undefined index: HOST at ../common/config/main-local.php:7 After much digging around, I’ve realized that I need to load Symfony\Component\Dotenv\Dotenv in common/config/codeception-local.php Thus, I have updated that file in the environment folder, and reran php init. ...

<span title='2021-06-30 21:00:00.016 +0800 +0800'>June 30, 2021</span>
Yii

Testing Yii with Codeception

We have an application written in Yii. Up til this point, it has been manually tested. Since it’s more efficient to automate the testing of this application, we have decided to set up Codeception to assist us with this task. Set up was easy and straight forward - this said after spending countless hours understanding the correct way to set it up. To illustrate the set up process, we’ll create a skeleton Yii app. ...

<span title='2016-02-02 18:19:00.001 +0800 +0800'>February 2, 2016</span>