Привожу пример теста:
Код: Выделить всё
class ServiceTest extends \Codeception\Test\Unit
{
protected $tester;
protected function loadFixture()
{
$this->tester->haveFixtures(['user' => ['class' => UserFixture::class]]);
}
protected function unLoadFixture()
{
$this->tester->grabFixture('user')->db->close();
}
public function testSuccessSignin()
{
$this->loadFixture();
$form = new SigninForm([
'email' => 'brady.renner@rutherford.com',
'password' => '123456',
]);
$result = Service::signin($form, new \yii\web\User([
'identityClass' => Identity::class,
]));
$this->assertTrue($result);
$this->unLoadFixture();
}
}
Не хотелось бы ковыряться в MySQL, а хотелось бы сделать тест, работающий везде без танцев.