Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4498ccd4
Commit
4498ccd4
authored
Jun 09, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic application template tests adjusted
parent
de8ba900
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
ContactFormTest.php
apps/basic/tests/unit/models/ContactFormTest.php
+3
-1
LoginFormTest.php
apps/basic/tests/unit/models/LoginFormTest.php
+15
-21
No files found.
apps/basic/tests/unit/models/ContactFormTest.php
View file @
4498ccd4
...
...
@@ -4,10 +4,11 @@ namespace tests\unit\models;
use
Yii
;
use
yii\codeception\TestCase
;
use
Codeception\Specify
;
class
ContactFormTest
extends
TestCase
{
use
\Codeception\
Specify
;
use
Specify
;
protected
function
setUp
()
{
...
...
@@ -55,4 +56,5 @@ class ContactFormTest extends TestCase
{
return
Yii
::
getAlias
(
Yii
::
$app
->
mail
->
fileTransportPath
)
.
'/testing_message.eml'
;
}
}
apps/basic/tests/unit/models/LoginFormTest.php
View file @
4498ccd4
...
...
@@ -4,11 +4,12 @@ namespace tests\unit\models;
use
Yii
;
use
yii\codeception\TestCase
;
use
app\models\User
;
use
app\models\LoginForm
;
use
Codeception\Specify
;
class
LoginFormTest
extends
TestCase
{
use
\Codeception\
Specify
;
use
Specify
;
protected
function
tearDown
()
{
...
...
@@ -18,10 +19,10 @@ class LoginFormTest extends TestCase
public
function
testLoginNoUser
()
{
$model
=
$this
->
mockUser
(
null
);
$model
->
username
=
'some_username'
;
$model
->
password
=
'some_password'
;
$model
=
new
LoginForm
([
'username'
=>
'not_existing_username'
,
'password'
=>
'not_existing_password'
,
])
;
$this
->
specify
(
'user should not be able to login, when there is no identity'
,
function
()
use
(
$model
)
{
expect
(
'model should not login user'
,
$model
->
login
())
->
false
();
...
...
@@ -31,10 +32,10 @@ class LoginFormTest extends TestCase
public
function
testLoginWrongPassword
()
{
$model
=
$this
->
mockUser
(
new
User
);
$model
->
username
=
'demo'
;
$model
->
password
=
'wrong-password'
;
$model
=
new
LoginForm
([
'username'
=>
'demo'
,
'password'
=>
'wrong_password'
,
])
;
$this
->
specify
(
'user should not be able to login with wrong password'
,
function
()
use
(
$model
)
{
expect
(
'model should not login user'
,
$model
->
login
())
->
false
();
...
...
@@ -45,10 +46,10 @@ class LoginFormTest extends TestCase
public
function
testLoginCorrect
()
{
$model
=
$this
->
mockUser
(
new
User
([
'password'
=>
'demo'
]));
$model
->
username
=
'demo'
;
$model
->
password
=
'demo'
;
$model
=
new
LoginForm
([
'username'
=>
'demo'
,
'password'
=>
'demo'
,
])
;
$this
->
specify
(
'user should be able to login with correct credentials'
,
function
()
use
(
$model
)
{
expect
(
'model should login user'
,
$model
->
login
())
->
true
();
...
...
@@ -57,11 +58,4 @@ class LoginFormTest extends TestCase
});
}
private
function
mockUser
(
$user
)
{
$loginForm
=
$this
->
getMock
(
'app\models\LoginForm'
,
[
'getUser'
]);
$loginForm
->
expects
(
$this
->
any
())
->
method
(
'getUser'
)
->
will
(
$this
->
returnValue
(
$user
));
return
$loginForm
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment