Yii Framework Forum: [SOLVED] Backend testing fixtures fails - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] Backend testing fixtures fails call to undefined method backend\tests\UnitTester::haveFixtu

#1 User is offline   ateshabaev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 19-August 15

Posted 07 August 2017 - 03:32 AM

Hi,

I am having problem with testing backend tests.

When I run test on the backend I have the following error:
Test  tests/unit/models/TestNameTest.php:testFeature
                                                                                      
  [RuntimeException] Call to undefined method backend\tests\UnitTester::haveFixtures 


TestNameTest class:
<?php

namespace backend\tests\models;

use Codeception\Util\Debug;
use common\fixtures\SomeModel as SomeModelFixture;


class TestNameTest extends \Codeception\Test\Unit
{
    /**
     * @var \backend\tests\UnitTester
     */
    protected $tester;


    public function _before()
    {
        $this->tester->haveFixtures([
            'data' => [
                'class' => SomeModelFixture::className(),
                'dataFile' => codecept_data_dir() . 'some_modal_data.php'
            ],
        ]);
    }


    public function testFeature() {
        $data = $this->tester->grabFixture('data', 0);
        $model = new SomeModel(['scenario' => SomeModel::SCENARIO_ADMIN]);

        expect_not($model->save());
    }

}



Could anybody tell what is wrong with the test above?

\backend\tests\UnitTester (code below) exists in _support folder and it has correct namespacing as well.

<?php
namespace backend\tests;

/**
 * Inherited Methods
 * @method void wantToTest($text)
 * @method void wantTo($text)
 * @method void execute($callable)
 * @method void expectTo($prediction)
 * @method void expect($prediction)
 * @method void amGoingTo($argumentation)
 * @method void am($role)
 * @method void lookForwardTo($achieveValue)
 * @method void comment($description)
 * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
 *
 * @SuppressWarnings(PHPMD)
 */
class UnitTester extends \Codeception\Actor
{
    use _generated\UnitTesterActions;
   /**
    * Define custom actions here
    */
}


Gues, any ideas? Maybe somebody already crossed this issue?
0

#2 User is offline   ateshabaev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 19-August 15

Posted 07 August 2017 - 03:47 AM

Solved, needed to add the following to `unit.suite.yml` file:

class_name: UnitTester
modules:
    enabled:
        - Yii2:
            part: [orm, email, fixtures]
        - Asserts


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users