Aucune description

CopyTest.php 1013B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Carbon package.
  4. *
  5. * (c) Brian Nesbitt <brian@nesbot.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Carbon\Carbon;
  11. class CopyTest extends TestFixture
  12. {
  13. public function testCopy()
  14. {
  15. $dating = Carbon::now();
  16. $dating2 = $dating->copy();
  17. $this->assertNotSame($dating, $dating2);
  18. }
  19. public function testCopyEnsureTzIsCopied()
  20. {
  21. $dating = Carbon::createFromDate(2000, 1, 1, 'Europe/London');
  22. $dating2 = $dating->copy();
  23. $this->assertSame($dating->tzName, $dating2->tzName);
  24. $this->assertSame($dating->offset, $dating2->offset);
  25. }
  26. public function testCopyEnsureMicrosAreCopied()
  27. {
  28. $micro = 254687;
  29. $dating = Carbon::createFromFormat('Y-m-d H:i:s.u', '2014-02-01 03:45:27.'.$micro);
  30. $dating2 = $dating->copy();
  31. $this->assertSame($micro, $dating2->micro);
  32. }
  33. }