Codeception with Yii2 Advance Template

I am totally lost my mind on testing using codeception with Yii2 advance template.

Yii2 Testing section points to Codeception which discusses setup, environment as a general, separate from Yii2.

Then, there are Yii2 Modules in Codeception (http://codeception.com/docs/modules/Yii2). I am having a brain damage trying to figure out to write a simple Test.

Google does not help much as Yii2 developers dont like to test ??? It is so hard to find a Codception + Yii2 Advance Template Unit test example including config, fixture, and data.

My goal is to test this 1 function as a starting point:




class TimeEntry extends ActiveRecord {

public static function getManhours($projectId)

{

        

        $query->andFilterWhere([

            'between', 'employee_time_entry.date', $startDate, $endDate

        ]);

        

        return $query->sum('[[st_hours]] + [[ot_hours]] + [[dt_hours]] + [[travel_time_hours]]');

    }

}



I am new to testing so please bare with me. I know I need a Unit Test and I need to feed some data( also called Fixtures ??) so I can test. I am stuck here.

Can some codeception yii2 pro developers please shred some lights so I can move forward ?

You are not alone :)

What I did was realize that I was better off using the basic application because the increased complexities of the advanced application really did not justify itself.

Especially considering that I am writing a fairly complex application.

But, yes you are right: Codeception with Yii is not well documented.

I would like to offer you solid advice about how to do things, but I barely know what I am doing myself :P

You can take a look, though, at the code I have pieced together for Bugitor: https://github.com/j...sts/codeception

Take notice of _support/FixtureHelper and unit/fixtures :)

Edit:

  1. In codeception.yml I have added a line at the top to set the namespace - [i]namespace: bugitor\tests

[/i]2) In functional.suite.yml and acceptance.suite.yml I have (or Codeception has - can’t remember) added the FixtureHelper Do a ‘codecept build’ after adding the fixture helper and see what it does.

  1. I checked - and probably modified config/config.php so that the paths and namespaces for the fixtures was correct.

  2. I am not really using the fixture templates, but they should work.

  3. When I use the fixtures - either in unit or acceptance/functional, they are generated (inserted into the test db)