From f30f957448882d538be03fdc1e2ec1856ef95994 Mon Sep 17 00:00:00 2001 From: Dmitry Dobryshin Date: Tue, 22 Sep 2020 15:13:30 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D1=84=D1=83=D0=BD?= =?utf8?q?=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB=D0=B0=20=D0=BD=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20site/index?= =?utf8?q?,=20site/contact,=20site/login,=20site/about,=20items/index,=20i?= =?utf8?q?tems/create,=20items/update,=20items/print?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ned --- tests/functional/ItemsCreateCest.php | 59 ++++++++++++++++++++++++++ tests/functional/ItemsIndexCest.php | 82 ++++++++++++++++++++++++++++++++++++ tests/functional/ItemsUpdateCest.php | 38 +++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 tests/functional/ItemsCreateCest.php create mode 100644 tests/functional/ItemsIndexCest.php create mode 100644 tests/functional/ItemsUpdateCest.php diff --git a/tests/functional/ItemsCreateCest.php b/tests/functional/ItemsCreateCest.php new file mode 100644 index 0000000..42d9ab0 --- /dev/null +++ b/tests/functional/ItemsCreateCest.php @@ -0,0 +1,59 @@ +amOnRoute('items/create'); + } + + // tests + // Открыта страница добавления + public function openCreatePage(\FunctionalTester $I) + { + $I->amOnPage([ 'items/create' ]); + $I->see(Yii::t('items', 'Create Items'), 'h1'); + } + + // Заполнение формы + public function enterData(\FunctionalTester $I) + { + $I->submitForm('#ItemForm', [ + 'Items[type_id]' => '1', + 'Items[name]' => 'TEST-WS-0001', + 'Items[model]' => 'Тестовый компьютер', + 'Items[os]' => 'Тестовая ОС', + 'Items[mac]' => '00:00-MAC-:00:00', + 'Items[serial]' => '*TEST SERIAL NUMBER*', + 'Items[product]' => 'TEST PRODUCT', + 'Items[modelnumber]' => 'TEST MODEL NUMBER', + 'Items[invent]' => '*TEST INVENTORY NUMBER*', + 'Items[comment]' => 'Тестирование. Это тестовая запись.', + 'Moving[date]' => '01.01.2020', + 'Moving[state_id]' => '1', + 'Moving[location_id]' => '1', + ]); + $I->see(Yii::t('items', 'Items'), 'h1'); + $I->dontSee(Yii::t('items', 'Create Items'), 'h1'); + $I->haveInDatabase('items', ['name' => 'TEST-WS-0001', 'model' => 'Тестовый компьютер', 'serial' => '*TEST SERIAL NUMBER*', 'invent' => '*TEST INVENTORY NUMBER*']); + } + + // Нажатие на кнопку "Типы" + public function pushTypes(\FunctionalTester $I) + { + $I->click(Locator::contains('div a', Yii::t('types', 'Types'))); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + $I->see(Yii::t('types', 'Types'), 'h1'); + } + + // Нажатие на кнопку "Места размещения" + public function pushLocations(\FunctionalTester $I) + { + $I->click(Locator::contains('div a', Yii::t('locations', 'Locations'))); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + $I->see(Yii::t('locations', 'Locations'), 'h1'); + } + +} diff --git a/tests/functional/ItemsIndexCest.php b/tests/functional/ItemsIndexCest.php new file mode 100644 index 0000000..f08badc --- /dev/null +++ b/tests/functional/ItemsIndexCest.php @@ -0,0 +1,82 @@ +amOnPage(['items/index']); + } + + // Есть заголовок + public function openItemsPage(\FunctionalTester $I) + { + $I->see(Yii::t('items', 'Items'), 'h1'); + } + + // Переход к странице добавления + public function pushCreateItem(\FunctionalTester $I) + { + $I->click(Locator::contains('div a', Yii::t('items', 'Create Items'))); + $I->see(Yii::t('items', 'Create Items'), 'h1'); + } + + // Переход к странице импорта + public function pushImportItems(\FunctionalTester $I) + { + $I->click(Locator::contains('div a', Yii::t('items', 'Import'))); + $I->see(Yii::t('items', 'Import Items'), 'h1'); + } + + // Формирование печатной формы PDF + public function moveToPrintItemsCheck(\FunctionalTester $I) + { + $I->click(Locator::contains('div a', Yii::t('items', 'Print Items'))); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + + // Этот участок кода пока не понятно как включить, но функционал обязательно добавлю. + // Точно .pdf + //$I->canSeeHttpHeader('Content-type', 'application/pdf'); + //$I->canSeeHttpHeader('Content-disposition', 'attachment; filename="' . Yii::t('app', Yii::$app->name) . ' (' . Yii::t('items', 'Items') . ').pdf"'); + $I->see('%PDF'); + + // Не пустой документ + //$I->canSeeHttpHeader('Content-length', '1024'); + // или + //$actualLength= $I->grabHttpHeader('Content-length'); + //$I->assertGreaterThan(1024, $actualLength); + } + + // Начало инвентаризации + public function startInventoryCheck(\FunctionalTester $I) + { + $I->click(Locator::contains('div a', Yii::t('items', 'Start checking'))); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + $I->see('', 'tr.danger'); + } + + //* // Нажатие на кнопку "Удалить" + public function deleteItemCheck(\FunctionalTester $I) + { + $I->click(Locator::find('a', [ 'title' => Yii::t('yii', 'Delete') ])); + $I->seeResponseCodeIs(405); + //$I->see(Yii::t('yii', 'Are you sure you want to delete this item?')); + } // */ + + // Печать отдельной наклейки + public function printItemCheck(\FunctionalTester $I) + { + $I->click(Locator::find('a', [ 'title' => Yii::t('items', 'Print selected labels') ])); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + $I->see('%PDF'); + } + + // переход к редактированию элемента + public function clickItemCheck(\FunctionalTester $I) + { + $I->click(Locator::contains('tr td a', '')); + $I->see(Yii::t('items', 'Update Items: {name}', [ 'name' => '', ]), 'h1'); + } +} diff --git a/tests/functional/ItemsUpdateCest.php b/tests/functional/ItemsUpdateCest.php new file mode 100644 index 0000000..cd5bc84 --- /dev/null +++ b/tests/functional/ItemsUpdateCest.php @@ -0,0 +1,38 @@ +amOnRoute('items/Update'); + } + + // tests + // Открыта страница добавления + public function openCreatePage(\FunctionalTester $I) + { + $I->amOnRoute('items/update', [ 'id' => '1' ]); + $I->see(Yii::t('items', 'Update Items: {name}', ['name' => '',]), 'h1'); + } + + // Заполнение формы + public function enterData(\FunctionalTester $I) + { + $I->amOnRoute('items/update', ['id' => '1']); + $I->submitForm('#ItemForm', []); + $I->see(Yii::t('items', 'Items'), 'h1'); + $I->dontSee(Yii::t('items', 'Update Items: {name}', ['name' => '',]), 'h1'); + } + + // Нажатие на кнопку "Типы" + public function pushTypes(\FunctionalTester $I) + { + $I->amOnRoute('items/update', ['id' => '1']); + $I->click(Locator::contains('div a', Yii::t('types', 'Types'))); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + $I->see(Yii::t('types', 'Types'), 'h1'); + } + +} -- 2.11.0