Files
Alexander Makarov 7eb403bf45 Codeception test adjustments for basic and advanced applications
- Moved everything test-related into `tests` directory. Codeception tests are in `codeception`.
- Removed database module since we're using fixtures and migrations.
- Moved console entry points and bootstrap into `tests/codeception/bin`.
- Adjusted travis build scripts.
- Adjusted documentation to be consistent and reflect changes made.
2014-08-15 19:09:52 +04:00

54 lines
1.5 KiB
PHP

<?php
namespace codeception\frontend\unit\models;
use codeception\frontend\unit\DbTestCase;
use codeception\common\fixtures\UserFixture;
use Codeception\Specify;
use frontend\models\SignupForm;
class SignupFormTest extends DbTestCase
{
use Specify;
public function testCorrectSignup()
{
$model = new SignupForm([
'username' => 'some_username',
'email' => 'some_email@example.com',
'password' => 'some_password',
]);
$user = $model->signup();
$this->assertInstanceOf('common\models\User', $user, 'user should be valid');
expect('username should be correct', $user->username)->equals('some_username');
expect('email should be correct', $user->email)->equals('some_email@example.com');
expect('password should be correct', $user->validatePassword('some_password'))->true();
}
public function testNotCorrectSignup()
{
$model = new SignupForm([
'username' => 'troy.becker',
'email' => 'nicolas.dianna@hotmail.com',
'password' => 'some_password',
]);
expect('username and email are in use, user should not be created', $model->signup())->null();
}
public function fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => '@codeception/frontend/unit/fixtures/data/models/user.php',
],
];
}
}