From 95bd8f4409e4275dbd7e2265d2bf29ea2dc52cad Mon Sep 17 00:00:00 2001 From: Davert Date: Mon, 18 Jul 2016 20:33:45 +0300 Subject: [PATCH] added tests for amLoggedIn method --- composer.json | 1 - composer.lock | 128 +---------------------------- tests/_bootstrap.php | 4 +- tests/functional/LoginFormCest.php | 17 ++++ tests/unit/models/UserTest.php | 3 +- 5 files changed, 21 insertions(+), 132 deletions(-) diff --git a/composer.json b/composer.json index b97bcd9..5849d04 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,6 @@ "yiisoft/yii2-swiftmailer": "*" }, "require-dev": { - "codeception/base": "^2.2.3", "codeception/verify": "*", "yiisoft/yii2-debug": "*", "yiisoft/yii2-gii": "*", diff --git a/composer.lock b/composer.lock index ce0248c..c0d86f4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "93894a180950d67c2b9edc7a95038f87", - "content-hash": "c8959aaf297f5e79479a01ef1dd73b02", + "hash": "5a52c83f9793fadbf22499b59bdb56f9", + "content-hash": "865dca284280bd582c54b70ef5cf23a6", "packages": [ { "name": "bower-asset/bootstrap", @@ -622,43 +622,6 @@ "bower-asset-main": "dist/typeahead.bundle.js" } }, - { - "name": "codeception/specify", - "version": "0.4.3", - "source": { - "type": "git", - "url": "https://github.com/Codeception/Specify.git", - "reference": "8efcd017687ebdae9c4d95bcbc1dc22a28561874" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Codeception/Specify/zipball/8efcd017687ebdae9c4d95bcbc1dc22a28561874", - "reference": "8efcd017687ebdae9c4d95bcbc1dc22a28561874", - "shasum": "" - }, - "require": { - "myclabs/deep-copy": "~1.1", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Codeception\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "authors": [ - { - "name": "Michael Bodnarchuk", - "email": "davert.php@mailican.com" - } - ], - "description": "BDD code blocks for PHPUnit and Codeception", - "time": "2015-11-26 23:35:52" - }, { "name": "codeception/verify", "version": "0.3.0", @@ -740,48 +703,6 @@ ], "time": "2016-04-29 12:21:54" }, - { - "name": "myclabs/deep-copy", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "a8773992b362b58498eed24bf85005f363c34771" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a8773992b362b58498eed24bf85005f363c34771", - "reference": "a8773992b362b58498eed24bf85005f363c34771", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2015-11-20 12:04:31" - }, { "name": "phpspec/php-diff", "version": "v1.1.0", @@ -820,51 +741,6 @@ "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", "time": "2016-04-07 12:29:16" }, - { - "name": "yiisoft/yii2-codeception", - "version": "2.0.5", - "source": { - "type": "git", - "url": "https://github.com/yiisoft/yii2-codeception.git", - "reference": "c916a36d09fc128b05a374e7922bc56854334d56" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-codeception/zipball/c916a36d09fc128b05a374e7922bc56854334d56", - "reference": "c916a36d09fc128b05a374e7922bc56854334d56", - "shasum": "" - }, - "require": { - "yiisoft/yii2": ">=2.0.4" - }, - "type": "yii2-extension", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "yii\\codeception\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Mark Jebri", - "email": "mark.github@yandex.ru" - } - ], - "description": "The Codeception integration for the Yii framework", - "keywords": [ - "codeception", - "yii2" - ], - "time": "2016-03-17 03:41:26" - }, { "name": "yiisoft/yii2-debug", "version": "2.0.6", diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 6a86590..969c089 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -3,6 +3,4 @@ define('YII_ENV', 'test'); defined('YII_DEBUG') or define('YII_DEBUG', true); require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); -require __DIR__ .'/../vendor/autoload.php'; - -\Codeception\Specify\Config::setDeepClone(false); \ No newline at end of file +require __DIR__ .'/../vendor/autoload.php'; \ No newline at end of file diff --git a/tests/functional/LoginFormCest.php b/tests/functional/LoginFormCest.php index 869925e..47b1b0d 100644 --- a/tests/functional/LoginFormCest.php +++ b/tests/functional/LoginFormCest.php @@ -9,6 +9,23 @@ class LoginFormCest public function openLoginPage(\FunctionalTester $I) { $I->see('Login', 'h1'); + + } + + // demonstrates `amLoggedAs` method + public function internalLoginById(\FunctionalTester $I) + { + $I->amLoggedAs(100); + $I->amOnPage('/'); + $I->see('Logout (admin)'); + } + + // demonstrates `amLoggedAs` method + public function internalLoginBy(\FunctionalTester $I) + { + $I->amLoggedAs(\app\models\User::findByUsername('admin')); + $I->amOnPage('/'); + $I->see('Logout (admin)'); } public function loginWithEmptyCredentials(\FunctionalTester $I) diff --git a/tests/unit/models/UserTest.php b/tests/unit/models/UserTest.php index 46dbb44..2187ab8 100644 --- a/tests/unit/models/UserTest.php +++ b/tests/unit/models/UserTest.php @@ -36,8 +36,7 @@ class UserTest extends \Codeception\Test\Unit expect_not($user->validateAuthKey('test102key')); expect_that($user->validatePassword('admin')); - expect_not($user->validatePassword('123456')); - + expect_not($user->validatePassword('123456')); } }