OSDN Git Service

Исправлен фильтр в моделях по наименованию.
[invent/invent.git] / tests / functional / ItemsCreateCest.php
1 <?php
2
3 use Codeception\Util\Locator;
4 use app\models\User;
5
6 class ItemsCreateCest
7 {
8     public function _before(FunctionalTester $I)
9     {
10         $I->amLoggedInAs(User::findByUsername('user'));
11         $I->amOnRoute('items/create');
12     }
13
14     // tests
15     // Открыта страница добавления
16     public function openCreatePage(FunctionalTester $I)
17     {
18         // Заголовок
19         $I->see(Yii::t('items', 'Create Items'), 'h1');
20         // Поля
21         $I->see(Yii::t('items', 'Item network name'), 'label');
22         $I->see(Yii::t('items', 'Model'), 'label');
23         $I->see(Yii::t('items', 'Operating system'), 'label');
24         $I->see(Yii::t('items', 'MAC address'), 'label');
25         $I->see(Yii::t('items', 'Serial number'), 'label');
26         $I->see(Yii::t('items', 'Inventory number'), 'label');
27         $I->see(Yii::t('items', 'Additional Information'), 'label');
28         $I->see(Yii::t('moving', 'Moving date'), 'label');
29         $I->see(Yii::t('status', 'Status'), 'label');
30         $I->see(Yii::t('locations', 'Location'), 'label');
31         // Кнопки
32         $I->see(Yii::t('app', 'Save'), 'button');
33         $I->see(Yii::t('app', 'Cancel'), 'a.btn');
34     }
35
36     // Заполнение формы
37     public function enterData(FunctionalTester $I)
38     {
39         $I->submitForm('#ItemForm', [
40             'Items[name]'         => 'TEST-WS-0001',
41             'Items[model_id]'     => 1,
42             'Items[os]'           => 'Тестовая ОС',
43             'Items[mac]'          => '00:00-MAC-:00:00',
44             'Items[serial]'       => '*TEST SERIAL NUMBER*',
45             'Items[invent]'       => '*TEST INVENTORY NUMBER*',
46             'Items[comment]'      => 'Тестирование. Это тестовая запись.',
47             'Moving[date]'        => '01.01.2020',
48             'Moving[state_id]'    => '1',
49             'Moving[location_id]' => '1',
50         ]);
51         $I->see(Yii::t('items', 'Items'), 'h1');
52         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
53     }
54
55     // Нажатие на кнопку "Модели"
56     public function pushModels(FunctionalTester $I)
57     {
58         $I->click(Locator::contains('div a', Yii::t('models', 'Models')));
59         $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
60         $I->see(Yii::t('models', 'Models'), 'h1');
61         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
62     }
63
64     // Нажатие на кнопку "Места размещения"
65     public function pushLocations(FunctionalTester $I)
66     {
67         $I->click(Locator::contains('div a', Yii::t('locations', 'Locations')));
68         $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
69         $I->see(Yii::t('locations', 'Locations'), 'h1');
70         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
71     }
72
73     // Нажатие на кнопку "Отмена"
74     public function pushCancel(FunctionalTester $I)
75     {
76         $I->click(Locator::contains('div a', Yii::t('app', 'Cancel')));
77         $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
78         $I->see(Yii::t('items', 'Items'), 'h1');
79         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
80     }
81 }