ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ChangeTimezoneTest Class Reference
+ Inheritance diagram for ChangeTimezoneTest:
+ Collaboration diagram for ChangeTimezoneTest:

Public Member Functions

 testTransform ()
 
 testTransformValues ()
 
 testNullTransform ()
 
 testInvalidTransform ()
 
 testInvoke ()
 
 testApplyToOK ()
 
 testApplyToFail ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

DateTime Group $dt
 

Detailed Description

Definition at line 25 of file ChangeTimezoneTest.php.

Member Function Documentation

◆ setUp()

ChangeTimezoneTest::setUp ( )
protected

Definition at line 29 of file ChangeTimezoneTest.php.

References ILIAS\ILIASObject\Creation\Group.

29  : void
30  {
31  $this->dt = new DateTime\Group();
32  }

◆ testApplyToFail()

ChangeTimezoneTest::testApplyToFail ( )

Definition at line 102 of file ChangeTimezoneTest.php.

102  : void
103  {
104  $trans = $this->dt->changeTimezone('Europe/London');
105  $df = new DataFactory();
106  $ok = $df->ok('not_a_date');
107 
108  $result = $trans->applyTo($ok);
109  $this->assertTrue($result->isError());
110  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testApplyToOK()

ChangeTimezoneTest::testApplyToOK ( )

Definition at line 87 of file ChangeTimezoneTest.php.

87  : void
88  {
89  $trans = $this->dt->changeTimezone('Europe/London');
90  $value = '2019/05/26';
91  $origin = new DateTimeImmutable($value);
92  $expected = new DateTimeImmutable($value, new DateTimeZone('Europe/London'));
93 
94  $df = new DataFactory();
95  $ok = $df->ok($origin);
96 
97  $result = $trans->applyTo($ok);
98  $this->assertEquals($expected, $result->value());
99  $this->assertFalse($result->isError());
100  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testInvalidTransform()

ChangeTimezoneTest::testInvalidTransform ( )

Definition at line 69 of file ChangeTimezoneTest.php.

69  : void
70  {
71  $this->expectException(InvalidArgumentException::class);
72  $trans = $this->dt->changeTimezone('Europe/Berlin');
73  $trans->transform('erroneous');
74  }

◆ testInvoke()

ChangeTimezoneTest::testInvoke ( )

Definition at line 76 of file ChangeTimezoneTest.php.

76  : void
77  {
78  $dat = '2019/05/26 16:05:22';
79  $origin_tz = 'Europe/Berlin';
80  $target_tz = 'Europe/London';
81  $origin = new DateTimeImmutable($dat, new DateTimeZone($origin_tz));
82  $expected = new DateTimeImmutable($dat, new DateTimeZone($target_tz));
83  $trans = $this->dt->changeTimezone($target_tz);
84  $this->assertEquals($expected, $trans($origin));
85  }

◆ testNullTransform()

ChangeTimezoneTest::testNullTransform ( )

Definition at line 62 of file ChangeTimezoneTest.php.

References null.

62  : void
63  {
64  $trans = $this->dt->changeTimezone('Europe/Berlin');
65  $this->expectException(InvalidArgumentException::class);
66  $trans->transform(null);
67  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ testTransform()

ChangeTimezoneTest::testTransform ( )

Definition at line 34 of file ChangeTimezoneTest.php.

34  : void
35  {
36  $dat = '2019-05-26 13:15:01';
37  $origin_tz = 'Europe/Berlin';
38  $target_tz = 'Europe/London';
39  $origin = new DateTimeImmutable($dat, new DateTimeZone($origin_tz));
40  $expected = new DateTimeImmutable($dat, new DateTimeZone($target_tz));
41  $trans = $this->dt->changeTimezone($target_tz);
42 
43  $this->assertEquals(
44  $expected,
45  $trans->transform($origin)
46  );
47  }

◆ testTransformValues()

ChangeTimezoneTest::testTransformValues ( )

Definition at line 49 of file ChangeTimezoneTest.php.

49  : void
50  {
51  $dat = '2019-05-26 13:15:01';
52  $origin_tz = 'Europe/Berlin';
53  $target_tz = 'America/El_Salvador';
54  $origin = new DateTimeImmutable($dat, new DateTimeZone($origin_tz));
55  $trans = $this->dt->changeTimezone($target_tz);
56  $this->assertEquals(
57  $dat,
58  date_format($trans->transform($origin), 'Y-m-d H:i:s')
59  );
60  }

Field Documentation

◆ $dt

DateTime Group ChangeTimezoneTest::$dt
private

Definition at line 27 of file ChangeTimezoneTest.php.


The documentation for this class was generated from the following file: