This repository has been archived on 2025-08-22. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dumbo/vendor/nesbot/carbon/tests/TestingAidsTest.php
2014-11-25 16:42:40 +01:00

62 lines
1.6 KiB
PHP

<?php
/*
* 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.
*/
use Carbon\Carbon;
class TestingAidsTest extends TestFixture
{
public function testTestingAidsWithTestNowNotSet()
{
Carbon::setTestNow();
$this->assertFalse(Carbon::hasTestNow());
$this->assertNull(Carbon::getTestNow());
}
public function testTestingAidsWithTestNowSet()
{
$notNow = Carbon::yesterday();
Carbon::setTestNow($notNow);
$this->assertTrue(Carbon::hasTestNow());
$this->assertSame($notNow, Carbon::getTestNow());
}
public function testConstructorWithTestValueSet()
{
$notNow = Carbon::yesterday();
Carbon::setTestNow($notNow);
$this->assertEquals($notNow, new Carbon());
$this->assertEquals($notNow, new Carbon(null));
$this->assertEquals($notNow, new Carbon(''));
$this->assertEquals($notNow, new Carbon('now'));
}
public function testNowWithTestValueSet()
{
$notNow = Carbon::yesterday();
Carbon::setTestNow($notNow);
$this->assertEquals($notNow, Carbon::now());
}
public function testParseWithTestValueSet()
{
$notNow = Carbon::yesterday();
Carbon::setTestNow($notNow);
$this->assertEquals($notNow, Carbon::parse());
$this->assertEquals($notNow, Carbon::parse(null));
$this->assertEquals($notNow, Carbon::parse(''));
$this->assertEquals($notNow, Carbon::parse('now'));
}
}