Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

54 rindas
1.5KB

  1. <?php
  2. namespace tests\codeception\frontend\unit\models;
  3. use tests\codeception\frontend\unit\DbTestCase;
  4. use tests\codeception\common\fixtures\UserFixture;
  5. use Codeception\Specify;
  6. use frontend\models\SignupForm;
  7. class SignupFormTest extends DbTestCase
  8. {
  9. use Specify;
  10. public function testCorrectSignup()
  11. {
  12. $model = new SignupForm([
  13. 'username' => 'some_username',
  14. 'email' => 'some_email@example.com',
  15. 'password' => 'some_password',
  16. ]);
  17. $user = $model->signup();
  18. $this->assertInstanceOf('common\models\User', $user, 'user should be valid');
  19. expect('username should be correct', $user->username)->equals('some_username');
  20. expect('email should be correct', $user->email)->equals('some_email@example.com');
  21. expect('password should be correct', $user->validatePassword('some_password'))->true();
  22. }
  23. public function testNotCorrectSignup()
  24. {
  25. $model = new SignupForm([
  26. 'username' => 'troy.becker',
  27. 'email' => 'nicolas.dianna@hotmail.com',
  28. 'password' => 'some_password',
  29. ]);
  30. expect('username and email are in use, user should not be created', $model->signup())->null();
  31. }
  32. public function fixtures()
  33. {
  34. return [
  35. 'user' => [
  36. 'class' => UserFixture::className(),
  37. 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php',
  38. ],
  39. ];
  40. }
  41. }