‪TYPO3CMS  9.5
DataProviderCollectionTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪DataProviderCollectionTest extends UnitTestCase
23 {
28 
32  protected function ‪setUp()
33  {
34  $this->dataProviderCollection = new \TYPO3\CMS\Backend\View\BackendLayout\DataProviderCollection();
35  }
36 
41  {
42  $this->expectException(\UnexpectedValueException::class);
43  $this->expectExceptionCode(1381597629);
44  $identifier = $this->getUniqueId('identifier__');
45  $dataProviderMock = $this->getMockBuilder('stdClass')->getMock();
46 
47  $this->dataProviderCollection->add($identifier, get_class($dataProviderMock));
48  }
49 
54  {
55  $this->expectException(\LogicException::class);
56  $this->expectExceptionCode(1381269811);
57  $identifier = $this->getUniqueId('identifier');
58  $dataProviderMock = $this->getMockBuilder('stdClass')->getMock();
59 
60  $this->dataProviderCollection->add($identifier, get_class($dataProviderMock));
61  }
62 
66  public function ‪defaultBackendLayoutIsFound()
67  {
68  $backendLayoutIdentifier = $this->getUniqueId('identifier');
69 
70  $dataProviderMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\DefaultDataProvider::class)
71  ->setMethods(['getBackendLayout'])
72  ->disableOriginalConstructor()
73  ->getMock();
74  $backendLayoutMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
75  ->setMethods(['getIdentifier'])
76  ->disableOriginalConstructor()
77  ->getMock();
78  $backendLayoutMock->expects($this->any())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
79  $dataProviderMock->expects($this->once())->method('getBackendLayout')->will($this->returnValue($backendLayoutMock));
80 
81  $this->dataProviderCollection->add('default', $dataProviderMock);
82  $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($backendLayoutIdentifier, 123);
83 
84  $this->assertNotNull($providedBackendLayout);
85  $this->assertEquals($backendLayoutIdentifier, $providedBackendLayout->getIdentifier());
86  }
87 
91  public function ‪providedBackendLayoutIsFound()
92  {
93  $dataProviderIdentifier = $this->getUniqueId('custom');
94  $backendLayoutIdentifier = $this->getUniqueId('identifier');
95 
96  $dataProviderMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\DefaultDataProvider::class)
97  ->setMethods(['getBackendLayout'])
98  ->disableOriginalConstructor()
99  ->getMock();
100  $backendLayoutMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
101  ->setMethods(['getIdentifier'])
102  ->disableOriginalConstructor()
103  ->getMock();
104  $backendLayoutMock->expects($this->any())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
105  $dataProviderMock->expects($this->once())->method('getBackendLayout')->will($this->returnValue($backendLayoutMock));
106 
107  $this->dataProviderCollection->add($dataProviderIdentifier, $dataProviderMock);
108  $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($dataProviderIdentifier . '__' . $backendLayoutIdentifier, 123);
109 
110  $this->assertNotNull($providedBackendLayout);
111  $this->assertEquals($backendLayoutIdentifier, $providedBackendLayout->getIdentifier());
112  }
113 }
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest\$dataProviderCollection
‪TYPO3 CMS Backend View BackendLayout DataProviderCollection $dataProviderCollection
Definition: DataProviderCollectionTest.php:26
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest\defaultBackendLayoutIsFound
‪defaultBackendLayoutIsFound()
Definition: DataProviderCollectionTest.php:65
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest\setUp
‪setUp()
Definition: DataProviderCollectionTest.php:31
‪TYPO3
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest
Definition: DataProviderCollectionTest.php:23
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout
Definition: BackendLayoutCollectionTest.php:2
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest\invalidIdentifierIsRecognizedOnAdding
‪invalidIdentifierIsRecognizedOnAdding()
Definition: DataProviderCollectionTest.php:39
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest\invalidInterfaceIsRecognizedOnAdding
‪invalidInterfaceIsRecognizedOnAdding()
Definition: DataProviderCollectionTest.php:52
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\DataProviderCollectionTest\providedBackendLayoutIsFound
‪providedBackendLayoutIsFound()
Definition: DataProviderCollectionTest.php:90