‪TYPO3CMS  10.4
DateTimeAspectTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 class ‪DateTimeAspectTest extends UnitTestCase
25 {
30  {
31  $dateObject = new \DateTimeImmutable('2018-07-15', new \DateTimeZone('Europe/Moscow'));
32  $subject = new ‪DateTimeAspect($dateObject);
33  $result = $subject->getDateTime();
34  self::assertSame($dateObject, $result);
35  }
36 
41  {
42  $this->expectException(AspectPropertyNotFoundException::class);
43  $this->expectExceptionCode(1527778767);
44  $dateObject = new \DateTimeImmutable('2018-07-15', new \DateTimeZone('Europe/Moscow'));
45  $subject = new ‪DateTimeAspect($dateObject);
46  $subject->get('football');
47  }
48 
53  {
54  return [
55  'timestamp' => [
56  'timestamp',
57  '1531648805'
58  ],
59  'iso' => [
60  'iso',
61  '2018-07-15T13:00:05+03:00'
62  ],
63  'timezone' => [
64  'timezone',
65  'Europe/Moscow'
66  ],
67  'full' => [
68  'full',
69  new \DateTimeImmutable('2018-07-15T13:00:05', new \DateTimeZone('Europe/Moscow'))
70  ],
71  ];
72  }
73 
80  public function ‪getReturnsValidInformationFromProperty($key, $expectedResult)
81  {
82  $dateObject = new \DateTimeImmutable('2018-07-15T13:00:05', new \DateTimeZone('Europe/Moscow'));
83  $subject = new ‪DateTimeAspect($dateObject);
84  self::assertEquals($expectedResult, $subject->get($key));
85  }
86 }
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\getThrowsExceptionOnInvalidArgument
‪getThrowsExceptionOnInvalidArgument()
Definition: DateTimeAspectTest.php:40
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest
Definition: DateTimeAspectTest.php:25
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\getReturnsValidInformationFromProperty
‪getReturnsValidInformationFromProperty($key, $expectedResult)
Definition: DateTimeAspectTest.php:80
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\getDateTimeReturnsSameObject
‪getDateTimeReturnsSameObject()
Definition: DateTimeAspectTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Context\DateTimeAspectTest\dateFormatValuesDataProvider
‪array dateFormatValuesDataProvider()
Definition: DateTimeAspectTest.php:52
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:35
‪TYPO3\CMS\Core\Context\Exception\AspectPropertyNotFoundException
Definition: AspectPropertyNotFoundException.php:26
‪TYPO3\CMS\Core\Tests\Unit\Context
Definition: ContextTest.php:18