OSDN Git Service

Настройка travis-CI/CD
[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 type'), 'label');
22         $I->see(Yii::t('items', 'Item network name'), 'label');
23         $I->see(Yii::t('items', 'Model'), 'label');
24         $I->see(Yii::t('items', 'Operating system'), 'label');
25         $I->see(Yii::t('items', 'MAC address'), 'label');
26         $I->see(Yii::t('items', 'Serial number'), 'label');
27         $I->see(Yii::t('items', 'Product number'), 'label');
28         $I->see(Yii::t('items', 'Model number'), 'label');
29         $I->see(Yii::t('items', 'Inventory number'), 'label');
30         $I->see(Yii::t('items', 'Additional Information'), 'label');
31         $I->see(Yii::t('moving', 'Moving date'), 'label');
32         $I->see(Yii::t('status', 'Status'), 'label');
33         $I->see(Yii::t('locations', 'Location'), 'label');
34         // Кнопки
35         $I->see(Yii::t('app', 'Save'), 'button');
36         $I->see(Yii::t('app', 'Cancel'), 'a.btn');
37     }
38
39     // Заполнение формы
40     public function enterData(FunctionalTester $I)
41     {
42         $I->submitForm('#ItemForm', [
43             'Items[type_id]'      => '1',
44             'Items[name]'         => 'TEST-WS-0001',
45             'Items[model]'        => 'Тестовый компьютер',
46             'Items[os]'           => 'Тестовая ОС',
47             'Items[mac]'          => '00:00-MAC-:00:00',
48             'Items[serial]'       => '*TEST SERIAL NUMBER*',
49             'Items[product]'      => 'TEST PRODUCT',
50             'Items[modelnumber]'  => 'TEST MODEL NUMBER',
51             'Items[invent]'       => '*TEST INVENTORY NUMBER*',
52             'Items[comment]'      => 'Тестирование. Это тестовая запись.',
53             'Moving[date]'        => '01.01.2020',
54             'Moving[state_id]'    => '1',
55             'Moving[location_id]' => '1',
56         ]);
57         $I->see(Yii::t('items', 'Items'), 'h1');
58         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
59     }
60
61     // Нажатие на кнопку "Типы"
62     public function pushTypes(FunctionalTester $I)
63     {
64         $I->click(Locator::contains('div a', Yii::t('types', 'Types')));
65         $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
66         $I->see(Yii::t('types', 'Types'), 'h1');
67         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
68     }
69
70     // Нажатие на кнопку "Места размещения"
71     public function pushLocations(FunctionalTester $I)
72     {
73         $I->click(Locator::contains('div a', Yii::t('locations', 'Locations')));
74         $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
75         $I->see(Yii::t('locations', 'Locations'), 'h1');
76         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
77     }
78
79     // Нажатие на кнопку "Отмена"
80     public function pushCancel(FunctionalTester $I)
81     {
82         $I->click(Locator::contains('div a', Yii::t('app', 'Cancel')));
83         $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
84         $I->see(Yii::t('items', 'Items'), 'h1');
85         $I->dontSee(Yii::t('items', 'Create Items'), 'h1');
86     }
87 }