EqualsToTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS
  4. *
  5. * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
  6. */
  7. namespace Lcobucci\JWT\Claim;
  8. use Lcobucci\JWT\ValidationData;
  9. /**
  10. * @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
  11. * @since 2.0.0
  12. */
  13. class EqualsToTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @test
  17. *
  18. * @uses Lcobucci\JWT\Claim\Basic::__construct
  19. * @uses Lcobucci\JWT\Claim\Basic::getName
  20. * @uses Lcobucci\JWT\ValidationData::__construct
  21. * @uses Lcobucci\JWT\ValidationData::has
  22. *
  23. * @covers Lcobucci\JWT\Claim\EqualsTo::validate
  24. */
  25. public function validateShouldReturnTrueWhenValidationDontHaveTheClaim()
  26. {
  27. $claim = new EqualsTo('iss', 'test');
  28. $this->assertTrue($claim->validate(new ValidationData()));
  29. }
  30. /**
  31. * @test
  32. *
  33. * @uses Lcobucci\JWT\Claim\Basic::__construct
  34. * @uses Lcobucci\JWT\Claim\Basic::getName
  35. * @uses Lcobucci\JWT\Claim\Basic::getValue
  36. * @uses Lcobucci\JWT\ValidationData::__construct
  37. * @uses Lcobucci\JWT\ValidationData::setIssuer
  38. * @uses Lcobucci\JWT\ValidationData::has
  39. * @uses Lcobucci\JWT\ValidationData::get
  40. *
  41. * @covers Lcobucci\JWT\Claim\EqualsTo::validate
  42. */
  43. public function validateShouldReturnTrueWhenValueIsEqualsToValidationData()
  44. {
  45. $claim = new EqualsTo('iss', 'test');
  46. $data = new ValidationData();
  47. $data->setIssuer('test');
  48. $this->assertTrue($claim->validate($data));
  49. }
  50. /**
  51. * @test
  52. *
  53. * @uses Lcobucci\JWT\Claim\Basic::__construct
  54. * @uses Lcobucci\JWT\Claim\Basic::getName
  55. * @uses Lcobucci\JWT\Claim\Basic::getValue
  56. * @uses Lcobucci\JWT\ValidationData::__construct
  57. * @uses Lcobucci\JWT\ValidationData::setIssuer
  58. * @uses Lcobucci\JWT\ValidationData::has
  59. * @uses Lcobucci\JWT\ValidationData::get
  60. *
  61. * @covers Lcobucci\JWT\Claim\EqualsTo::validate
  62. */
  63. public function validateShouldReturnFalseWhenValueIsNotEqualsToValidationData()
  64. {
  65. $claim = new EqualsTo('iss', 'test');
  66. $data = new ValidationData();
  67. $data->setIssuer('test1');
  68. $this->assertFalse($claim->validate($data));
  69. }
  70. }