‪TYPO3CMS  11.5
RecordLinkHandlerTest.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 
23 class ‪RecordLinkHandlerTest extends UnitTestCase
24 {
28  public function ‪asStringReturnsUrl(): void
29  {
30  $subject = new ‪RecordLinkHandler();
31  $parameters = [
32  'identifier' => 'tx_identifier',
33  'uid' => 123,
34  ];
35  $url = sprintf(
36  't3://record?identifier=%s&uid=%s',
37  $parameters['identifier'],
38  $parameters['uid']
39  );
40 
41  self::assertEquals($url, $subject->asString($parameters));
42  }
43 
47  public function ‪missingParameterDataProvider(): array
48  {
49  return [
50  'identifier is missing' => [
51  [
52  'uid' => 123,
53  ],
54  ],
55  'uid is missing' => [
56  [
57  'identifier' => 'identifier',
58  ],
59  ],
60  ];
61  }
62 
68  public function ‪resolveHandlerDataThrowsExceptionIfParameterIsMissing(array $parameters): void
69  {
70  $this->expectException(\InvalidArgumentException::class);
71  $this->expectExceptionCode(1486155151);
72 
73  $subject = new ‪RecordLinkHandler();
74  $subject->resolveHandlerData($parameters);
75  }
76 
82  public function ‪asStringThrowsExceptionIfParameterIsMissing(array $parameters): void
83  {
84  $this->expectException(\InvalidArgumentException::class);
85  $this->expectExceptionCode(1486155150);
86 
87  $subject = new ‪RecordLinkHandler();
88  $subject->asString($parameters);
89  }
90 }