BooleanFormatterTest.php 957 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Test\Unit;
  3. use InvalidArgumentException;
  4. use Test\TestCase;
  5. use Web3\Formatters\BooleanFormatter;
  6. class BooleanFormatterTest extends TestCase
  7. {
  8. /**
  9. * formatter
  10. *
  11. * @var \Web3\Formatters\BooleanFormatter
  12. */
  13. protected $formatter;
  14. /**
  15. * setUp
  16. *
  17. * @return void
  18. */
  19. public function setUp()
  20. {
  21. parent::setUp();
  22. $this->formatter = new BooleanFormatter;
  23. }
  24. /**
  25. * testFormat
  26. *
  27. * @return void
  28. */
  29. public function testFormat()
  30. {
  31. $formatter = $this->formatter;
  32. $boolean = $formatter->format(true);
  33. $this->assertEquals($boolean, true);
  34. $boolean = $formatter->format(1);
  35. $this->assertEquals($boolean, true);
  36. $boolean = $formatter->format(false);
  37. $this->assertEquals($boolean, false);
  38. $boolean = $formatter->format(0);
  39. $this->assertEquals($boolean, false);
  40. }
  41. }