@@ 431-444 (lines=14) @@ | ||
428 | * |
|
429 | * @Given /^the current date is "([^"]*)"$/ |
|
430 | */ |
|
431 | public function givenTheCurrentDateIs($date) |
|
432 | { |
|
433 | $newDatetime = \DateTime::createFromFormat('Y-m-d', $date); |
|
434 | if (!$newDatetime) { |
|
435 | throw new InvalidArgumentException(sprintf('Invalid date format: %s (requires "Y-m-d")', $date)); |
|
436 | } |
|
437 | ||
438 | $state = $this->testSessionEnvironment->getState(); |
|
439 | $oldDatetime = \DateTime::createFromFormat('Y-m-d H:i:s', isset($state->datetime) ? $state->datetime : null); |
|
440 | if ($oldDatetime) { |
|
441 | $newDatetime->setTime($oldDatetime->format('H'), $oldDatetime->format('i'), $oldDatetime->format('s')); |
|
442 | } |
|
443 | $state->datetime = $newDatetime->format('Y-m-d H:i:s'); |
|
444 | $this->testSessionEnvironment->applyState($state); |
|
445 | } |
|
446 | ||
447 | /** |
|
@@ 455-468 (lines=14) @@ | ||
452 | * |
|
453 | * @Given /^the current time is "([^"]*)"$/ |
|
454 | */ |
|
455 | public function givenTheCurrentTimeIs($time) |
|
456 | { |
|
457 | $newDatetime = \DateTime::createFromFormat('H:i:s', $date); |
|
458 | if (!$newDatetime) { |
|
459 | throw new InvalidArgumentException(sprintf('Invalid date format: %s (requires "H:i:s")', $date)); |
|
460 | } |
|
461 | ||
462 | $state = $this->testSessionEnvironment->getState(); |
|
463 | $oldDatetime = \DateTime::createFromFormat('Y-m-d H:i:s', isset($state->datetime) ? $state->datetime : null); |
|
464 | if ($oldDatetime) { |
|
465 | $newDatetime->setDate($oldDatetime->format('Y'), $oldDatetime->format('m'), $oldDatetime->format('d')); |
|
466 | } |
|
467 | $state->datetime = $newDatetime->format('Y-m-d H:i:s'); |
|
468 | $this->testSessionEnvironment->applyState($state); |
|
469 | } |
|
470 | ||
471 | /** |