‪TYPO3CMS  10.4
ValuePickerItemDataProviderTest.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 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 class ‪ValuePickerItemDataProviderTest extends UnitTestCase
26 {
28  'tableName' => 'sys_redirect',
29  'processedTca' => [
30  'columns' => [
31  'source_host' => [
32  'config' => [
33  'valuePicker' => [
34  'items' => []
35  ]
36  ]
37  ]
38  ]
39  ]
40  ];
41 
46  {
47  $result = [
48  'tableName' => 'tt_content',
49  ];
50 
51  $siteFinderProphecy = $this->prophesize(SiteFinder::class);
52  $siteFinderProphecy->getAllSites()->willReturn([]);
53  $valuePickerItemDataProvider = new ‪ValuePickerItemDataProvider($siteFinderProphecy->reveal());
54  $actualResult = $valuePickerItemDataProvider->addData($result);
55  self::assertSame($result, $actualResult);
56  }
57 
62  {
63  // no results for now
64  $siteFinderProphecy = $this->prophesize(SiteFinder::class);
65  $siteFinderProphecy->getAllSites()->willReturn([
66  new ‪Site('bar', 13, ['base' => 'bar.test']),
67  new ‪Site('foo', 14, ['base' => 'foo.test'])
68  ]);
69  $valuePickerItemDataProvider = new ‪ValuePickerItemDataProvider($siteFinderProphecy->reveal());
70  $actualResult = $valuePickerItemDataProvider->addData($this->sysRedirectResultSet);
72  $expected['processedTca']['columns']['source_host']['config']['valuePicker']['items'] = [
73  ['bar.test', 'bar.test'],
74  ['foo.test', 'foo.test'],
75  ];
76  self::assertSame($expected, $actualResult);
77  }
78 
83  {
84  $siteFinderProphecy = $this->prophesize(SiteFinder::class);
85  $siteFinderProphecy->getAllSites()->willReturn([]);
86  $valuePickerItemDataProvider = new ‪ValuePickerItemDataProvider($siteFinderProphecy->reveal());
87  $actualResult = $valuePickerItemDataProvider->addData($this->sysRedirectResultSet);
88 
89  self::assertSame($this->sysRedirectResultSet, $actualResult);
90  }
91 }
‪TYPO3\CMS\Redirects\Tests\Unit\FormDataProvider\ValuePickerItemDataProviderTest\addDataDoesNotChangeResultSetIfNoSitesAreFound
‪addDataDoesNotChangeResultSetIfNoSitesAreFound()
Definition: ValuePickerItemDataProviderTest.php:82
‪TYPO3\CMS\Redirects\Tests\Unit\FormDataProvider
Definition: ValuePickerItemDataProviderTest.php:18
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:40
‪TYPO3\CMS\Redirects\Tests\Unit\FormDataProvider\ValuePickerItemDataProviderTest\$sysRedirectResultSet
‪$sysRedirectResultSet
Definition: ValuePickerItemDataProviderTest.php:27
‪TYPO3\CMS\Redirects\Tests\Unit\FormDataProvider\ValuePickerItemDataProviderTest\addDataDoesNothingIfNoRedirectDataGiven
‪addDataDoesNothingIfNoRedirectDataGiven()
Definition: ValuePickerItemDataProviderTest.php:45
‪TYPO3\CMS\Redirects\Tests\Unit\FormDataProvider\ValuePickerItemDataProviderTest\addDataAddsHostsAsKeyAndValueToRedirectValuePicker
‪addDataAddsHostsAsKeyAndValueToRedirectValuePicker()
Definition: ValuePickerItemDataProviderTest.php:61
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider
Definition: ValuePickerItemDataProvider.php:29
‪TYPO3\CMS\Redirects\Tests\Unit\FormDataProvider\ValuePickerItemDataProviderTest
Definition: ValuePickerItemDataProviderTest.php:26