BasicTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /**
  9. * @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
  10. * @since 2.0.0
  11. */
  12. class BasicTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @test
  16. *
  17. * @covers Lcobucci\JWT\Claim\Basic::__construct
  18. */
  19. public function constructorShouldConfigureTheAttributes()
  20. {
  21. $claim = new Basic('test', 1);
  22. $this->assertAttributeEquals('test', 'name', $claim);
  23. $this->assertAttributeEquals(1, 'value', $claim);
  24. }
  25. /**
  26. * @test
  27. *
  28. * @uses Lcobucci\JWT\Claim\Basic::__construct
  29. *
  30. * @covers Lcobucci\JWT\Claim\Basic::getName
  31. */
  32. public function getNameShouldReturnTheClaimName()
  33. {
  34. $claim = new Basic('test', 1);
  35. $this->assertEquals('test', $claim->getName());
  36. }
  37. /**
  38. * @test
  39. *
  40. * @uses Lcobucci\JWT\Claim\Basic::__construct
  41. *
  42. * @covers Lcobucci\JWT\Claim\Basic::getValue
  43. */
  44. public function getValueShouldReturnTheClaimValue()
  45. {
  46. $claim = new Basic('test', 1);
  47. $this->assertEquals(1, $claim->getValue());
  48. }
  49. /**
  50. * @test
  51. *
  52. * @uses Lcobucci\JWT\Claim\Basic::__construct
  53. *
  54. * @covers Lcobucci\JWT\Claim\Basic::jsonSerialize
  55. */
  56. public function jsonSerializeShouldReturnTheClaimValue()
  57. {
  58. $claim = new Basic('test', 1);
  59. $this->assertEquals(1, $claim->jsonSerialize());
  60. }
  61. /**
  62. * @test
  63. *
  64. * @uses Lcobucci\JWT\Claim\Basic::__construct
  65. *
  66. * @covers Lcobucci\JWT\Claim\Basic::__toString
  67. */
  68. public function toStringShouldReturnTheClaimValue()
  69. {
  70. $claim = new Basic('test', 1);
  71. $this->assertEquals('1', (string) $claim);
  72. }
  73. }