StrictModeTest.php 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\CarbonPeriod;
  12. use BadMethodCallException;
  13. use Carbon\Carbon;
  14. use Tests\AbstractTestCase;
  15. class StrictModeTest extends AbstractTestCase
  16. {
  17. public function testCallWithStrictMode()
  18. {
  19. $this->expectExceptionObject(new BadMethodCallException(
  20. 'Method foobar does not exist.'
  21. ));
  22. $periodClass = $this->periodClass;
  23. /** @var mixed $period */
  24. $period = $periodClass::create();
  25. $period->foobar();
  26. }
  27. public function testCallWithoutStrictMode()
  28. {
  29. Carbon::useStrictMode(false);
  30. $periodClass = $this->periodClass;
  31. /** @var mixed $period */
  32. $period = $periodClass::create();
  33. $this->assertSame($period, $period->foobar());
  34. }
  35. }