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