‪TYPO3CMS  ‪main
AfterLinkResolvedByStringRepresentationEventTest.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\Test;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
26 {
27  #[Test]
28  public function ‪gettersReturnInitializedObjects(): void
29  {
30  $result = [
31  'type' => 'url',
32  ];
33  $urn = 'myhandler://123';
34  $resolveException = new ‪UnknownLinkHandlerException('Unknown LinkHandler', 1705660731);
35 
37  result: $result,
38  urn: $urn,
39  resolveException: $resolveException
40  );
41 
42  self::assertSame($result, $event->getResult());
43  self::assertSame($urn, $event->getUrn());
44  self::assertSame($resolveException, $event->getResolveException());
45  }
46 
47  #[Test]
48  public function ‪setterOverwritesResult(): void
49  {
50  $result = [
51  'type' => 'url',
52  ];
53  $urn = 'myhandler://123';
54  $resolveException = new ‪UnknownLinkHandlerException('Unknown LinkHandler', 1705660732);
55 
57  result: $result,
58  urn: $urn,
59  resolveException: $resolveException
60  );
61 
62  self::assertSame($result, $event->getResult());
63  self::assertSame($urn, $event->getUrn());
64  self::assertSame($resolveException, $event->getResolveException());
65 
66  $newResult = ['type' => 'my-type'];
67  $event->setResult($newResult);
68 
69  self::assertSame($newResult, $event->getResult());
70  }
71 }