CompareTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Tests\CarbonInterval;
  12. use Carbon\CarbonInterval;
  13. use Tests\AbstractTestCase;
  14. class CompareTest extends AbstractTestCase
  15. {
  16. public function testNegative()
  17. {
  18. $first = CarbonInterval::minute();
  19. $second = CarbonInterval::minutes(2);
  20. $result = $first->compare($second);
  21. $this->assertSame(-1, $result);
  22. }
  23. public function testPositive()
  24. {
  25. $first = CarbonInterval::day();
  26. $second = CarbonInterval::hour();
  27. $result = $first->compare($second);
  28. $this->assertSame(1, $result);
  29. }
  30. public function testEqual()
  31. {
  32. $first = CarbonInterval::year();
  33. $second = CarbonInterval::year();
  34. $result = $first->compare($second);
  35. $this->assertSame(0, $result);
  36. }
  37. }