Pārlūkot izejas kodu

added tests for amLoggedIn method

Davert 9 gadi atpakaļ
vecāks
revīzija
95bd8f4409

+ 0 - 1
composer.json

@@ -20,7 +20,6 @@
         "yiisoft/yii2-swiftmailer": "*"
     },
     "require-dev": {
-        "codeception/base": "^2.2.3",
         "codeception/verify": "*",
         "yiisoft/yii2-debug": "*",
         "yiisoft/yii2-gii": "*",

+ 2 - 126
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",
@@ -623,43 +623,6 @@
             }
         },
         {
-            "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",
             "source": {
@@ -741,48 +704,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",
             "source": {
@@ -821,51 +742,6 @@
             "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",
             "source": {

+ 1 - 3
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);
+require __DIR__ .'/../vendor/autoload.php';

+ 17 - 0
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)

+ 1 - 2
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'));        
     }
 
 }