OSDN Git Service

Добавлены и исправлены тесты. Внесены незначительные правки в надписи.
[invent/invent.git] / tests / functional / MovingInsertCest.php
1 <?php
2
3 use Codeception\Util\Locator;
4
5 class MovingInsertCest
6 {
7     public function _before(\FunctionalTester $I)
8     {
9         $I->amOnRoute('items/update', ['id' => '1']);
10         $I->click(Yii::t('moving', 'Create Moving'), 'a.btn');
11      }
12
13     // tests
14     // Проверка открытия страницы на добавление
15     public function openInsertPage(\FunctionalTester $I)
16     {
17         // Заголовок
18         $I->see(Yii::t('moving', 'Create Moving'), 'h1');
19         // Поля
20         $I->dontSee(Yii::t('items', 'Update Items: {name}', [ 'name' => '', ]), 'h1');
21         $I->see(Yii::t('moving', 'Moving date'), 'label');
22         $I->see(Yii::t('status', 'Status'), 'label');
23         $I->see(Yii::t('locations', 'Location'), 'label');
24         $I->see(Yii::t('moving', 'Comment'), 'label');
25         // Кнопки
26         $I->see(Yii::t('app', 'Save'), 'button');
27         $I->see(Yii::t('app', 'Cancel'), 'a.btn');
28     }
29
30     // Нажатие кнопки "Места размещения"
31     public function clickLocations(\FunctionalTester $I)
32     {
33         $I->click(Locator::contains('div a', Yii::t('locations', 'Locations')));
34         $I->see(Yii::t('locations', 'Locations'), 'h1');
35         $I->dontSee(Yii::t('moving', 'Create Moving'), 'h1');
36     }
37
38     // Нажатие сохранение данных
39     public function enterData(\FunctionalTester $I)
40     {
41         $I->submitForm('#MovingForm', [
42             'Moving[date]'        => '20.09.2020',
43             'Moving[state_id]'    => '1',
44             'Moving[location_id]' => '1',
45             'Moving[comment]'     => '*TEST MOVE COMMENT*',
46         ]);
47         $I->see(Yii::t('items', 'Update Items: {name}', [ 'name' => '', ]), 'h1');
48         $I->dontSee(Yii::t('moving', 'Create Moving'), 'h1');
49         $I->see('20.09.2020', '#MovingTable a');
50     }
51
52     // Нажатие кнопки попытка сохранить неправильную дату
53     public function enterWrongAboveTodayData(\FunctionalTester $I)
54     {
55         $I->submitForm('#MovingForm', [
56             'Moving[date]'        => '20.09.2200',
57             'Moving[state_id]'    => '1',
58             'Moving[location_id]' => '1',
59             'Moving[comment]'     => '*TEST MOVE COMMENT*',
60         ]);
61         $I->dontSee(Yii::t('items', 'Update Items: {name}', [ 'name' => '', ]), 'h1');
62         $I->see(Yii::t('moving', 'Create Moving'), 'h1');
63         $I->see(Yii::t('moving', 'The date cannot be more than today'));
64     }
65
66     // Нажатие кнопки попытка сохранить неправильную дату
67     public function enterWrongDataBeforeFirst(\FunctionalTester $I)
68     {
69         $I->submitForm('#MovingForm', [
70             'Moving[date]'        => '01.01.2010',
71             'Moving[state_id]'    => '1',
72             'Moving[location_id]' => '1',
73             'Moving[comment]'     => '*TEST MOVE COMMENT*',
74         ]);
75         $I->dontSee(Yii::t('items', 'Update Items: {name}', [ 'name' => '', ]), 'h1');
76         $I->see(Yii::t('moving', 'Create Moving'), 'h1');
77         $I->see(Yii::t('moving', 'Дата не может быть меньше, чем {date}', [ 'date' => '' ]));
78     }
79
80 }