freeze() public static method

Freezes time to a specific point or current time if no time is given.
public static freeze ( null $date = null )
$date null
Example #1
0
 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 . ']');
 }
Example #3
0
 /**
  * @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);
 }
Example #4
0
 /**
  * @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());
 }
Example #5
0
<?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();
Example #6
0
 protected function tearDown()
 {
     parent::tearDown();
     Clock::freeze();
 }