Информация о моём окружении:
**Codeception version is 2.5.1**
**DBMS is Oracle**
**Application framework is Yii2**
Миграция для создания таблицы.
Код: Выделить всё
private $tableName = 'fixture_test';
public function up()
{
$this->createTable($this->tableName, [
'ID_FIXTURE' => $this->primaryKey()->autoIncrement(),
'TEST_DATA1' => $this->string('200 CHAR')->comment('Test data 1'),
'TEST_DATA2' => $this->string('200 CHAR')->comment('Test data 2'),
'TEST_DATA3' => $this->string('200 CHAR')->comment('Test data 3'),
'TEST_DATA4' => $this->integer()->comment('Test data 4'),
]);
}
Код: Выделить всё
namespace app\models;
class FixtModel extends \yii\db\ActiveRecord
{
public static function tableName()
{
return 'FIXTURE_TEST';
}
public function rules()
{
return [
[['ID_FIXTURE'], 'required'],
[['ID_FIXTURE', 'TEST_DATA4'], 'integer'],
[['TEST_DATA1', 'TEST_DATA2', 'TEST_DATA3'], 'string', 'max' => 200],
[['ID_FIXTURE'], 'unique'],
];
}
}
Лежат здесь: tests/fixtures/data/test.php
Код: Выделить всё
<?php
return [
'test1' => [
'TEST_DATA1' => 'asdfg',
'TEST_DATA2' => 'asdfg',
'TEST_DATA3' => 'asdfg',
'TEST_DATA4' => 1,
],
];
Код: Выделить всё
<?php
namespace app\tests\fixtures;
class TestFixture extends ActiveFixture
{
public $modelClass = 'app\models\FixtModel';
public $dataFile = __DIR__ . '../fixtures/data/test.php';
}
И наконец то сам класс юнит-теста
Код: Выделить всё
class FixtureTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;
public function _fixtures() {
return [
'test' => 'app\tests\fixtures\TestFixture',
];
}
protected function _before()
{
}
protected function _after()
{
}
public function testSomeFeature()
{
$this->tester->grabFixture('test', 'test1');
}
}
Код: Выделить всё
Test tests/unit/FixtureTest.php:testSomeFeature
[yii\base\ErrorException] array_merge() expects at least 1 parameter, 0 given
#1 /var/www/ozon/tests/_support/_generated/UnitTesterActions.php:692
#2 /var/www/ozon/tests/unit/FixtureTest.php:26
#3 /var/www/ozon/vendor/symfony/console/Application.php:262
#4 /var/www/ozon/vendor/symfony/console/Application.php:145