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
ee0c105b
Commit
ee0c105b
authored
Jan 05, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests improved, verify added
parent
9411429d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
14 deletions
+15
-14
README.md
apps/basic/tests/README.md
+1
-1
ContactFormTest.php
apps/basic/tests/unit/models/ContactFormTest.php
+6
-5
LoginFormTest.php
apps/basic/tests/unit/models/LoginFormTest.php
+8
-8
No files found.
apps/basic/tests/README.md
View file @
ee0c105b
...
@@ -6,7 +6,7 @@ After creating the basic application, follow these steps to prepare for the test
...
@@ -6,7 +6,7 @@ After creating the basic application, follow these steps to prepare for the test
1.
To install
`Codeception`
and its dependencies through composer, run the following commands:
1.
To install
`Codeception`
and its dependencies through composer, run the following commands:
```
```
php composer.phar require --dev "codeception/codeception *" "codeception/specify *"
php composer.phar require --dev "codeception/codeception *" "codeception/specify *"
"codeception/verify *"
```
```
2. In the file `_bootstrap.php`, modify the definition of the constant `TEST_ENTRY_URL` so
2. In the file `_bootstrap.php`, modify the definition of the constant `TEST_ENTRY_URL` so
...
...
apps/basic/tests/unit/models/ContactFormTest.php
View file @
ee0c105b
...
@@ -39,15 +39,16 @@ class ContactFormTest extends TestCase
...
@@ -39,15 +39,16 @@ class ContactFormTest extends TestCase
$model
->
contact
(
'admin@example.com'
);
$model
->
contact
(
'admin@example.com'
);
$this
->
specify
(
'email should be send'
,
function
()
{
$this
->
specify
(
'email should be send'
,
function
()
{
$this
->
assertFileExists
(
$this
->
getMessageFile
(),
'email file should exist'
);
expect
(
'email file should exist'
,
file_exists
(
$this
->
getMessageFile
()))
->
true
(
);
});
});
$this
->
specify
(
'message should contain correct data'
,
function
()
use
(
$model
)
{
$this
->
specify
(
'message should contain correct data'
,
function
()
use
(
$model
)
{
$emailMessage
=
file_get_contents
(
$this
->
getMessageFile
());
$emailMessage
=
file_get_contents
(
$this
->
getMessageFile
());
$this
->
assertContains
(
$model
->
name
,
$emailMessage
,
'email should contain user name'
);
$this
->
assertContains
(
$model
->
email
,
$emailMessage
,
'email should contain sender email'
);
expect
(
'email should contain user name'
,
$emailMessage
)
->
contains
(
$model
->
name
);
$this
->
assertContains
(
$model
->
subject
,
$emailMessage
,
'email should contain subject'
);
expect
(
'email should contain sender email'
,
$emailMessage
)
->
contains
(
$model
->
email
);
$this
->
assertContains
(
$model
->
body
,
$emailMessage
,
'email should contain body'
);
expect
(
'email should contain subject'
,
$emailMessage
)
->
contains
(
$model
->
subject
);
expect
(
'email should contain body'
,
$emailMessage
)
->
contains
(
$model
->
body
);
});
});
}
}
...
...
apps/basic/tests/unit/models/LoginFormTest.php
View file @
ee0c105b
...
@@ -19,8 +19,8 @@ class LoginFormTest extends TestCase
...
@@ -19,8 +19,8 @@ class LoginFormTest extends TestCase
$model
->
password
=
'some_password'
;
$model
->
password
=
'some_password'
;
$this
->
specify
(
'user should not be able to login, when there is no identity'
,
function
()
use
(
$model
)
{
$this
->
specify
(
'user should not be able to login, when there is no identity'
,
function
()
use
(
$model
)
{
$this
->
assertFalse
(
$model
->
login
()
);
expect
(
'model should not login user'
,
$model
->
login
())
->
false
(
);
$this
->
assertTrue
(
Yii
::
$app
->
user
->
isGuest
,
'user should not be logged in'
);
expect
(
'user should not be logged in'
,
Yii
::
$app
->
user
->
isGuest
)
->
true
(
);
});
});
}
}
...
@@ -32,9 +32,9 @@ class LoginFormTest extends TestCase
...
@@ -32,9 +32,9 @@ class LoginFormTest extends TestCase
$model
->
password
=
'wrong-password'
;
$model
->
password
=
'wrong-password'
;
$this
->
specify
(
'user should not be able to login with wrong password'
,
function
()
use
(
$model
)
{
$this
->
specify
(
'user should not be able to login with wrong password'
,
function
()
use
(
$model
)
{
$this
->
assertFalse
(
$model
->
login
()
);
expect
(
'model should not login user'
,
$model
->
login
())
->
false
(
);
$this
->
assertArrayHasKey
(
'password'
,
$model
->
errors
);
expect
(
'error message should be set'
,
$model
->
errors
)
->
hasKey
(
'password'
);
$this
->
assertTrue
(
Yii
::
$app
->
user
->
isGuest
,
'user should not be logged in'
);
expect
(
'user should not be logged in'
,
Yii
::
$app
->
user
->
isGuest
)
->
true
(
);
});
});
}
}
...
@@ -46,9 +46,9 @@ class LoginFormTest extends TestCase
...
@@ -46,9 +46,9 @@ class LoginFormTest extends TestCase
$model
->
password
=
'demo'
;
$model
->
password
=
'demo'
;
$this
->
specify
(
'user should be able to login with correct credentials'
,
function
()
use
(
$model
)
{
$this
->
specify
(
'user should be able to login with correct credentials'
,
function
()
use
(
$model
)
{
$this
->
assertTrue
(
$model
->
login
()
);
expect
(
'model should login user'
,
$model
->
login
())
->
true
(
);
$this
->
assertArrayNotHasKey
(
'password'
,
$model
->
errors
);
expect
(
'error message should not be set'
,
$model
->
errors
)
->
hasntKey
(
'password'
);
$this
->
assertFalse
(
Yii
::
$app
->
user
->
isGuest
,
'user should be logged in'
);
expect
(
'user should be logged in'
,
Yii
::
$app
->
user
->
isGuest
)
->
false
(
);
});
});
}
}
...
...
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