‪TYPO3CMS  10.4
CorrelationIdTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪CorrelationIdTest extends UnitTestCase
27 {
28  public function ‪canBeParsedDataProvider(): array
29  {
30  return [
31  [
32  '0400$subject',
33  ['scope' => null, 'subject' => 'subject', 'aspects' => []],
34  ],
35  [
36  '0400$scope:subject',
37  ['scope' => 'scope', 'subject' => 'subject', 'aspects' => []],
38  ],
39  [
40  '0400$scope:subject/aspect-a',
41  ['scope' => 'scope', 'subject' => 'subject', 'aspects' => ['aspect-a']],
42  ],
43  [
44  '0400$scope:subject/aspect-a/aspect-b',
45  ['scope' => 'scope', 'subject' => 'subject', 'aspects' => ['aspect-a', 'aspect-b']],
46  ],
47  ];
48  }
49 
57  public function ‪canBeParsed(string $string, array $expectations): void
58  {
59  $correlationId = ‪CorrelationId::fromString($string);
60  foreach ($expectations as $propertyName => $propertyValue) {
61  self::assertSame(
62  $propertyValue,
63  $correlationId->{'get' . ucfirst($propertyName)}()
64  );
65  }
66  }
67 
71  public function ‪subjectIsConsidered(): void
72  {
73  $correlationId = ‪CorrelationId::forSubject('subject')
74  ->withAspects('aspect-a');
75  self::assertSame('0400$subject/aspect-a', (string)$correlationId);
76  }
77 
81  public function ‪scopeIsConsidered(): void
82  {
83  $correlationId = ‪CorrelationId::forScope('scope')
84  ->withSubject('subject')
85  ->withAspects('aspect-a');
86  self::assertSame('0400$scope:subject/aspect-a', (string)$correlationId);
87  }
88 
92  public function ‪doesNotVary(): void
93  {
94  $correlationId = '0400$scope:subject/aspect-a/aspect-b';
95  self::assertSame(
96  $correlationId,
97  (string)‪CorrelationId::fromString($correlationId)
98  );
99  }
100 }
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model
Definition: CorrelationIdTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model\CorrelationIdTest\canBeParsedDataProvider
‪canBeParsedDataProvider()
Definition: CorrelationIdTest.php:28
‪TYPO3\CMS\Core\DataHandling\Model\CorrelationId\fromString
‪static static fromString(string $correlationId)
Definition: CorrelationId.php:75
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model\CorrelationIdTest\scopeIsConsidered
‪scopeIsConsidered()
Definition: CorrelationIdTest.php:81
‪TYPO3\CMS\Core\DataHandling\Model\CorrelationId
Definition: CorrelationId.php:29
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model\CorrelationIdTest\subjectIsConsidered
‪subjectIsConsidered()
Definition: CorrelationIdTest.php:71
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model\CorrelationIdTest
Definition: CorrelationIdTest.php:27
‪TYPO3\CMS\Core\DataHandling\Model\CorrelationId\forSubject
‪static forSubject(string $subject, string ... $aspects)
Definition: CorrelationId.php:64
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model\CorrelationIdTest\canBeParsed
‪canBeParsed(string $string, array $expectations)
Definition: CorrelationIdTest.php:57
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Model\CorrelationIdTest\doesNotVary
‪doesNotVary()
Definition: CorrelationIdTest.php:92
‪TYPO3\CMS\Core\DataHandling\Model\CorrelationId\forScope
‪static static forScope(string $scope)
Definition: CorrelationId.php:57