‪TYPO3CMS  10.4
RecordLinkHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
21 class ‪RecordLinkHandlerTest extends UnitTestCase
22 {
26  public function ‪asStringReturnsUrl()
27  {
28  $subject = new ‪RecordLinkHandler();
29  $parameters = [
30  'identifier' => 'tx_identifier',
31  'uid' => 123
32  ];
33  $url = sprintf(
34  't3://record?identifier=%s&uid=%s',
35  $parameters['identifier'],
36  $parameters['uid']
37  );
38 
39  self::assertEquals($url, $subject->asString($parameters));
40  }
41 
45  public function ‪missingParameterDataProvider(): array
46  {
47  return [
48  'identifier is missing' => [
49  [
50  'uid' => 123
51  ]
52  ],
53  'uid is missing' => [
54  [
55  'identifier' => 'identifier',
56  ]
57  ]
58  ];
59  }
60 
67  {
68  $this->expectException(\InvalidArgumentException::class);
69  $this->expectExceptionCode(1486155151);
70 
71  $subject = new ‪RecordLinkHandler();
72  $subject->resolveHandlerData($parameters);
73  }
74 
80  public function ‪asStringThrowsExceptionIfParameterIsMissing(array $parameters)
81  {
82  $this->expectException(\InvalidArgumentException::class);
83  $this->expectExceptionCode(1486155150);
84 
85  $subject = new ‪RecordLinkHandler();
86  $subject->asString($parameters);
87  }
88 }