ResetPasswordFormTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace frontend\tests\unit\models;
  3. use common\fixtures\UserFixture;
  4. use frontend\models\ResetPasswordForm;
  5. class ResetPasswordFormTest extends \Codeception\Test\Unit
  6. {
  7. /**
  8. * @var \frontend\tests\UnitTester
  9. */
  10. protected $tester;
  11. public function _before()
  12. {
  13. $this->tester->haveFixtures([
  14. 'user' => [
  15. 'class' => UserFixture::className(),
  16. 'dataFile' => codecept_data_dir() . 'user.php'
  17. ],
  18. ]);
  19. }
  20. public function testResetWrongToken()
  21. {
  22. $this->tester->expectException('yii\base\InvalidParamException', function() {
  23. new ResetPasswordForm('');
  24. });
  25. $this->tester->expectException('yii\base\InvalidParamException', function() {
  26. new ResetPasswordForm('notexistingtoken_1391882543');
  27. });
  28. }
  29. public function testResetCorrectToken()
  30. {
  31. $user = $this->tester->grabFixture('user', 0);
  32. $form = new ResetPasswordForm($user['password_reset_token']);
  33. expect_that($form->resetPassword());
  34. }
  35. }