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 ?
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
Take notice of _support/FixtureHelper and unit/fixtures
Edit:
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.
I checked - and probably modified config/config.php so that the paths and namespaces for the fixtures was correct.
I am not really using the fixture templates, but they should work.
When I use the fixtures - either in unit or acceptance/functional, they are generated (inserted into the test db)