I tried looking for answer in forum and google but none answer my question directly, and i need help desperately to get my unit test with Fixtures running, so here am i with my code snippet seeking help from experts here:
namespace common\tests\unit\provider;
use Yii;
use \common\models\provider\ProviderCalculation;
use \common\tests\fixtures\CompanyFixture;
use \common\tests\fixtures\ProviderFixture;
class ProviderCalculationTest extends \Codeception\Test\Unit
{
use \Codeception\Specify;
public function _fixtures()
{
return [
'company' => [
'class' => CompanyFixture::className(),
// fixture data located in tests/_data/company.php
'dataFile' => codecept_data_dir() .'company.php'
],
'provider' => [
'class' => ProviderFixture::className(),
'dataFile' => codecept_data_dir() . 'provider.php'
],
];
}
public function _before()
{
}
public function _after()
{
}
public function testProviderCalculation(UnitTester $I){
$this->specify("Provider calculation is wrong", function() {
$providerCalculation = new ProviderCalculation();
$companyType = $I->grabFixture('Provider', 'accrualOnly');
//codecept_debug($companyLeaveType);
$calculated_value = $providerCalculation->getAccrualProduct(
$companyType
);
$expected_value = 14;
$this->assertEquals($expected_value, $calculated_value);
});
}
}`
Everytime i run the test it gives me this error:
[yii\base\ErrorException] Argument 1 passed to common\tests\unit\leave\ProviderCalculationTest::testProviderCalculation() must be an instance of common\tests\unit\leave\UnitTester, none given
where have i done wrong?