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