菜谱项目

TokenValidatorTest.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of jwt-auth.
  4. *
  5. * (c) Sean Tymon <tymon148@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Tymon\JWTAuth\Test;
  11. use Tymon\JWTAuth\Validators\TokenValidator;
  12. class TokenValidatorTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function setUp()
  15. {
  16. $this->validator = new TokenValidator();
  17. }
  18. /** @test */
  19. public function it_should_return_true_when_providing_a_well_formed_token()
  20. {
  21. $this->assertTrue($this->validator->isValid('one.two.three'));
  22. }
  23. /** @test */
  24. public function it_should_return_false_when_providing_a_malformed_token()
  25. {
  26. $this->assertFalse($this->validator->isValid('one.two.three.four.five'));
  27. }
  28. /** @test */
  29. public function it_should_throw_an_axception_when_providing_a_malformed_token()
  30. {
  31. $this->setExpectedException('Tymon\JWTAuth\Exceptions\TokenInvalidException');
  32. $this->validator->check('one.two.three.four.five');
  33. }
  34. }