protected function setUp() { parent::setUp(); Clock::freeze('2014-01-01 11:11:11'); StreamStub::register('test'); $this->logger = new StdOutputLogger('TEST', 'default', 'test'); }
/** * @test * @dataProvider dates * @param string $currentDate * @param string $date * @param string $expectedText */ public function shouldCreateTranslatableTimeAgo($currentDate, $date, $expectedText) { //given Clock::freeze($currentDate); //when $translatableTimeAgo = TranslatableTimeAgo::create($date)->asString(); //then $this->assertEquals($expectedText, $translatableTimeAgo, 'Error in [' . $date . '] with expected [' . $expectedText . ']'); }
/** * @test */ public function shouldReturnTimestamp() { //given Clock::freeze('2011-01-02 12:34'); //when $timestamp = Clock::now()->getTimestamp(); //then $dateTime = new DateTime('2011-01-02 12:34'); $this->assertEquals($dateTime->getTimestamp(), $timestamp); }
/** * @test * @dataProvider dates * @param string $currentDate * @param string $date * @param string $expectedKey * @param array $expectedParams */ public function shouldCreateTimeAgo($currentDate, $date, $expectedKey, $expectedParams) { //given Clock::freeze($currentDate); //when $timeAgo = TimeAgo::create($date); //then $this->assertEquals($expectedKey, $timeAgo->getKey()); $this->assertEquals($expectedParams, $timeAgo->getParams()); }
<?php use Ouzo\Utilities\Clock; use Ouzo\Utilities\Files; use Ouzo\Utilities\Path; error_reporting(E_ALL); putenv('environment=test'); define('ROOT_PATH', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR); require 'vendor/autoload.php'; Files::loadIfExists(Path::join(ROOT_PATH, 'config', 'error_codes.php')); Files::loadIfExists(Path::join(ROOT_PATH, 'config', 'routes.php')); Clock::freeze();
protected function tearDown() { parent::tearDown(); Clock::freeze(); }