‪TYPO3CMS  ‪main
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 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪RecordLinkHandlerTest extends UnitTestCase
26 {
27  #[Test]
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 
44  public static function ‪missingParameterDataProvider(): array
45  {
46  return [
47  'identifier is missing' => [
48  [
49  'uid' => 123,
50  ],
51  ],
52  'uid is missing' => [
53  [
54  'identifier' => 'identifier',
55  ],
56  ],
57  ];
58  }
59 
60  #[DataProvider('missingParameterDataProvider')]
61  #[Test]
62  public function ‪resolveHandlerDataThrowsExceptionIfParameterIsMissing(array $parameters): void
63  {
64  $this->expectException(\InvalidArgumentException::class);
65  $this->expectExceptionCode(1486155151);
66 
67  $subject = new ‪RecordLinkHandler();
68  $subject->resolveHandlerData($parameters);
69  }
70 
71  #[DataProvider('missingParameterDataProvider')]
72  #[Test]
73  public function ‪asStringThrowsExceptionIfParameterIsMissing(array $parameters): void
74  {
75  $this->expectException(\InvalidArgumentException::class);
76  $this->expectExceptionCode(1486155150);
77 
78  $subject = new ‪RecordLinkHandler();
79  $subject->asString($parameters);
80  }
81 }
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36