‪TYPO3CMS  ‪main
VersionStateTest.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 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪VersionStateTest extends UnitTestCase
26 {
27  #[Test]
28  public function ‪canBeCreated(): void
29  {
30  $versionState = VersionState::MOVE_POINTER;
31  self::assertSame(4, $versionState->value);
32  }
33 
34  public static function ‪canBeCastedDataProvider(): \Generator
35  {
36  yield [4, 4];
37  yield ['4', 4];
38  yield [VersionState::MOVE_POINTER, 4];
39  yield ['zero-casted', 0];
40  yield [12345, null];
41  }
42 
43  #[DataProvider('canBeCastedDataProvider')]
44  #[Test]
45  public function ‪canBeCasted(mixed $value, ?int $expectation): void
46  {
47  self::assertSame($expectation, VersionState::cast($value)?->value);
48  }
49 
50  public static function ‪canBeComparedDataProvider(): \Generator
51  {
52  yield [0, false];
53  yield ['0', false];
54  yield [VersionState::DEFAULT_STATE, false];
55 
56  yield [4, true];
57  yield ['4', true];
58  yield [VersionState::MOVE_POINTER, true];
59  }
60 
61  #[DataProvider('canBeComparedDataProvider')]
62  #[Test]
63  public function ‪canBeCompared(mixed $value, bool $expectation): void
64  {
65  self::assertSame($expectation, VersionState::MOVE_POINTER->equals($value));
66  }
67 }
‪TYPO3\CMS\Core\Versioning\VersionState
‪VersionState
Definition: VersionState.php:22
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning\VersionStateTest\canBeCastedDataProvider
‪static canBeCastedDataProvider()
Definition: VersionStateTest.php:34
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning\VersionStateTest
Definition: VersionStateTest.php:26
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning
Definition: VersionStateTest.php:18
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning\VersionStateTest\canBeComparedDataProvider
‪static canBeComparedDataProvider()
Definition: VersionStateTest.php:50
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning\VersionStateTest\canBeCasted
‪canBeCasted(mixed $value, ?int $expectation)
Definition: VersionStateTest.php:45
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning\VersionStateTest\canBeCompared
‪canBeCompared(mixed $value, bool $expectation)
Definition: VersionStateTest.php:63
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Versioning\VersionStateTest\canBeCreated
‪canBeCreated()
Definition: VersionStateTest.php:28