LesserOrEqualsToTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 LesserOrEqualsToTest 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\LesserOrEqualsTo::validate
  24. */
  25. public function validateShouldReturnTrueWhenValidationDontHaveTheClaim()
  26. {
  27. $claim = new LesserOrEqualsTo('iss', 10);
  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\LesserOrEqualsTo::validate
  42. */
  43. public function validateShouldReturnTrueWhenValueIsLesserThanValidationData()
  44. {
  45. $claim = new LesserOrEqualsTo('iss', 10);
  46. $data = new ValidationData();
  47. $data->setIssuer(11);
  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\LesserOrEqualsTo::validate
  62. */
  63. public function validateShouldReturnTrueWhenValueIsEqualsToValidationData()
  64. {
  65. $claim = new LesserOrEqualsTo('iss', 10);
  66. $data = new ValidationData();
  67. $data->setIssuer(10);
  68. $this->assertTrue($claim->validate($data));
  69. }
  70. /**
  71. * @test
  72. *
  73. * @uses Lcobucci\JWT\Claim\Basic::__construct
  74. * @uses Lcobucci\JWT\Claim\Basic::getName
  75. * @uses Lcobucci\JWT\Claim\Basic::getValue
  76. * @uses Lcobucci\JWT\ValidationData::__construct
  77. * @uses Lcobucci\JWT\ValidationData::setIssuer
  78. * @uses Lcobucci\JWT\ValidationData::has
  79. * @uses Lcobucci\JWT\ValidationData::get
  80. *
  81. * @covers Lcobucci\JWT\Claim\LesserOrEqualsTo::validate
  82. */
  83. public function validateShouldReturnFalseWhenValueIsGreaterThanValidationData()
  84. {
  85. $claim = new LesserOrEqualsTo('iss', 11);
  86. $data = new ValidationData();
  87. $data->setIssuer(10);
  88. $this->assertFalse($claim->validate($data));
  89. }
  90. }