Answer the question
In order to leave comments, you need to log in
Codeception + yii2, who will explain the truthway for working with behaviors (upload pictures), working with databases and fixtures?
A short introduction:
We have many large and medium-sized projects written in Yii2. The problem is as old as the world: testing is needed to reduce the time it takes to maintain existing applications. In tests, we only understand that they are needed like air;)
- I decided to use Codeception,
- We deployed it, made basic tests, + - I understand where everything is and why.
- I deployed the project specifically with a bug, which I try to catch but it doesn't work - the test completes successfully.
Urgent questions:
- There is a site with goods, there are labels for goods (ala action, discount, etc.) It looks like this: joxi.ru/4AkOBRPfMzdVnA On the left is a display on the site, on the right is a form for editing.
- The bug I'm trying to catch, (the picture for the sticker is required) - when editing an existing sticker, and saving it unchanged, an error is generated: "It is necessary to fill in the "Image."" Screen shot: joxi.ru/ZrJq8oLH14X04A
- The test code looks like this:
$I->amOnPage('/admin/products/site-stickers/update/5');
$I->attachFile('#sitestickers-image', 'lace.png');
$I->See('StickerForTest');
$I->click('Сохранить');
$I->dontSeeElement('.has-error');
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if (YII_ENV=='test') {
$model->detachBehavior('photo');
}
$model->save( false );
return $this->redirect(['index']);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
Answer the question
In order to leave comments, you need to log in
Colleagues, we are looking for an enthusiast who is ready to explain for $ on Skype or in an office in Moscow, the main approaches, and, for example, cover a working application with tests with my hands.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question