ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
DateTimeTransformationTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
7require_once('./libs/composer/vendor/autoload.php');
8
10use PHPUnit\Framework\TestCase as TestCase;
13
18{
22 private $trans;
23
24 protected function setUp() : void
25 {
26 $df = new Factory();
27 $this->trans = new DateTimeTransformation($df);
28 }
29
30 public function testTransform()
31 {
32 $value = '26.05.1977';
33 $expected = new \DateTimeImmutable($value);
34
35 $this->assertEquals(
36 $expected,
37 $this->trans->transform($value)
38 );
39 }
40
41 public function testInvalidTransform()
42 {
43 $this->expectException(\InvalidArgumentException::class);
44 $this->trans->transform('erroneous');
45 }
46
47 public function testInvoke()
48 {
49 $value = '2019/05/26';
50 $expected = new \DateTimeImmutable($value);
51 $t = $this->trans;
52
53 $this->assertEquals($expected, $t($value));
54 }
55}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
Transform a string representing a datetime-value to php's DateTimeImmutable see https://www....