Unable to replicate Codeception dependency injection example from docs

I am following the example from http://codeception.com/docs/07-AdvancedUsage#Dependency-Injection

I currently have this in my Cest:

/**
 * @var Helper\MyHelper
 */
protected $myHelper;

protected function _inject(\Helper\MyHelper $myHelper)
{
    $this->myHelper = $myHelper;
}

      

And generates the following error:

Failed to inject dependencies in instance of 'HomeCest'. Failed to create instance of 'Helper\MyHelper'. Failed to create instance of 'Codeception\Lib\ModuleContainer'. Parameter 'config' must have default value.

This is my helper:

<?php
namespace Helper;

class MyHelper extends \Codeception\Module
{
    public function login($email, $password = '')
    {
        $I = $this->getModule('PhpBrowser');

        $I->fillField('email', $email);
        $I->fillField('password', $password);
        $I->click('Ok!');
    }
}

      

My goal is that if I can get this working, it would be create BaseCest

where I can insert all the helpers, page objects, and staged objects.

Assistant loaded correctly in acceptance.suite.yml

.

+3


source to share


1 answer


The bug was in a previous version of Codeception: https://github.com/Codeception/Codeception/issues/2230



In versions of Codeception version 2.1.2, this error should not be present.

0


source







All Articles