‪TYPO3CMS  9.5
DateTimeAspectTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
22 class ‪DateTimeAspectTest extends UnitTestCase
23 {
28  {
29  $dateObject = new \DateTimeImmutable('2018-07-15', new \DateTimeZone('Europe/Moscow'));
30  $subject = new ‪DateTimeAspect($dateObject);
31  $result = $subject->getDateTime();
32  $this->assertSame($dateObject, $result);
33  }
34 
39  {
40  $this->expectException(AspectPropertyNotFoundException::class);
41  $this->expectExceptionCode(1527778767);
42  $dateObject = new \DateTimeImmutable('2018-07-15', new \DateTimeZone('Europe/Moscow'));
43  $subject = new ‪DateTimeAspect($dateObject);
44  $subject->get('football');
45  }
46 
51  {
52  return [
53  'timestamp' => [
54  'timestamp',
55  '1531648805'
56  ],
57  'iso' => [
58  'iso',
59  '2018-07-15T13:00:05+03:00'
60  ],
61  'timezone' => [
62  'timezone',
63  'Europe/Moscow'
64  ],
65  'full' => [
66  'full',
67  new \DateTimeImmutable('2018-07-15T13:00:05', new \DateTimeZone('Europe/Moscow'))
68  ],
69  ];
70  }
71 
78  public function ‪getReturnsValidInformationFromProperty($key, $expectedResult)
79  {
80  $dateObject = new \DateTimeImmutable('2018-07-15T13:00:05', new \DateTimeZone('Europe/Moscow'));
81  $subject = new ‪DateTimeAspect($dateObject);
82  $this->assertEquals($expectedResult, $subject->get($key));
83  }
84 }
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\getThrowsExceptionOnInvalidArgument
‪getThrowsExceptionOnInvalidArgument()
Definition: DateTimeAspectTest.php:38
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest
Definition: DateTimeAspectTest.php:23
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\getReturnsValidInformationFromProperty
‪getReturnsValidInformationFromProperty($key, $expectedResult)
Definition: DateTimeAspectTest.php:78
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\getDateTimeReturnsSameObject
‪getDateTimeReturnsSameObject()
Definition: DateTimeAspectTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\dateFormatValuesDataProvider
‪array dateFormatValuesDataProvider()
Definition: DateTimeAspectTest.php:50
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:33
‪TYPO3\CMS\Core\Context\Exception\AspectPropertyNotFoundException
Definition: AspectPropertyNotFoundException.php:24
‪TYPO3\CMS\Core\Tests\Unit\Context
Definition: ContextTest.php:3