TYPO3 CMS  TYPO3_8-7
RecordLinkHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
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 
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  $this->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 
66  public function resolveHandlerDataThrowsExceptionIfParameterIsMissing(array $parameters)
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 }