From aaee0841e13f46614911e05e83670a60fe2bc1e7 Mon Sep 17 00:00:00 2001 From: Maxim Shcherbakov Date: Thu, 14 Jul 2016 19:20:28 +0300 Subject: [PATCH] Acceptance tests refactoring (#1) --- .../codeception/_support/AcceptanceTester.php | 26 +++++++++++++ .../codeception/_support/FunctionalTester.php | 26 +++++++++++++ tests/codeception/_support/UnitTester.php | 26 +++++++++++++ .../_support/_generated/.gitignore | 2 + tests/codeception/acceptance.suite.yml | 2 + tests/codeception/acceptance/AboutCept.php | 10 ----- tests/codeception/acceptance/AboutCest.php | 11 ++++++ tests/codeception/acceptance/HomeCept.php | 11 ------ tests/codeception/acceptance/HomeCest.php | 16 ++++++++ tests/codeception/acceptance/LoginCept.php | 37 ------------------- tests/codeception/acceptance/LoginCest.php | 19 ++++++++++ 11 files changed, 128 insertions(+), 58 deletions(-) create mode 100644 tests/codeception/_support/AcceptanceTester.php create mode 100644 tests/codeception/_support/FunctionalTester.php create mode 100644 tests/codeception/_support/UnitTester.php create mode 100644 tests/codeception/_support/_generated/.gitignore delete mode 100644 tests/codeception/acceptance/AboutCept.php create mode 100644 tests/codeception/acceptance/AboutCest.php delete mode 100644 tests/codeception/acceptance/HomeCept.php create mode 100644 tests/codeception/acceptance/HomeCest.php delete mode 100644 tests/codeception/acceptance/LoginCept.php create mode 100644 tests/codeception/acceptance/LoginCest.php diff --git a/tests/codeception/_support/AcceptanceTester.php b/tests/codeception/_support/AcceptanceTester.php new file mode 100644 index 0000000..4c7dcbb --- /dev/null +++ b/tests/codeception/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +wantTo('ensure that about works'); -AboutPage::openBy($I); -$I->see('About', 'h1'); diff --git a/tests/codeception/acceptance/AboutCest.php b/tests/codeception/acceptance/AboutCest.php new file mode 100644 index 0000000..a3cbef6 --- /dev/null +++ b/tests/codeception/acceptance/AboutCest.php @@ -0,0 +1,11 @@ +amOnPage(['site/about']); + $I->amOnPage('index.php?r=site%2Fabout'); + $I->see('About', 'h1'); + } +} diff --git a/tests/codeception/acceptance/HomeCept.php b/tests/codeception/acceptance/HomeCept.php deleted file mode 100644 index 1f93535..0000000 --- a/tests/codeception/acceptance/HomeCept.php +++ /dev/null @@ -1,11 +0,0 @@ -wantTo('ensure that home page works'); -$I->amOnPage(Yii::$app->homeUrl); -$I->see('My Company'); -$I->seeLink('About'); -$I->click('About'); -$I->see('This is the About page.'); diff --git a/tests/codeception/acceptance/HomeCest.php b/tests/codeception/acceptance/HomeCest.php new file mode 100644 index 0000000..cd7b224 --- /dev/null +++ b/tests/codeception/acceptance/HomeCest.php @@ -0,0 +1,16 @@ +amOnPage(Yii::$app->homeUrl); + $I->amOnPage('index.php?r=site%2Findex'); + $I->see('My Company'); + + $I->seeLink('About'); + $I->click('About'); + + $I->see('This is the About page.'); + } +} diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php deleted file mode 100644 index 90d0635..0000000 --- a/tests/codeception/acceptance/LoginCept.php +++ /dev/null @@ -1,37 +0,0 @@ -wantTo('ensure that login works'); - -$loginPage = LoginPage::openBy($I); - -$I->see('Login', 'h1'); - -$I->amGoingTo('try to login with empty credentials'); -$loginPage->login('', ''); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see validations errors'); -$I->see('Username cannot be blank.'); -$I->see('Password cannot be blank.'); - -$I->amGoingTo('try to login with wrong credentials'); -$loginPage->login('admin', 'wrong'); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see validations errors'); -$I->see('Incorrect username or password.'); - -$I->amGoingTo('try to login with correct credentials'); -$loginPage->login('admin', 'admin'); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see user info'); -$I->see('Logout (admin)'); diff --git a/tests/codeception/acceptance/LoginCest.php b/tests/codeception/acceptance/LoginCest.php new file mode 100644 index 0000000..97f3980 --- /dev/null +++ b/tests/codeception/acceptance/LoginCest.php @@ -0,0 +1,19 @@ +amOnPage(['site/login']); + $I->amOnPage('index.php?r=site%2Flogin'); + $I->see('Login', 'h1'); + + $I->amGoingTo('try to login with correct credentials'); + $I->fillField('input[name="LoginForm[username]"]', 'admin'); + $I->fillField('input[name="LoginForm[password]"]', 'admin'); + $I->click('login-button'); + + $I->expectTo('see user info'); + $I->see('Logout (admin)'); + } +}