TYPO3 CMS  TYPO3_6-2
DataProviderCollectionTest.php
Go to the documentation of this file.
1 <?php
3 
23 
28 
32  protected function setUp() {
33  $this->dataProviderCollection = new \TYPO3\CMS\Backend\View\BackendLayout\DataProviderCollection();
34  }
35 
41  $identifier = $this->getUniqueId('identifier__');
42  $dataProviderMock = $this->getMock('stdClass');
43 
44  $this->dataProviderCollection->add($identifier, get_class($dataProviderMock));
45  }
46 
52  $identifier = $this->getUniqueId('identifier');
53  $dataProviderMock = $this->getMock('stdClass');
54 
55  $this->dataProviderCollection->add($identifier, get_class($dataProviderMock));
56  }
57 
61  public function defaultBackendLayoutIsFound() {
62  $backendLayoutIdentifier = $this->getUniqueId('identifier');
63 
64  $dataProviderMock = $this->getMock('TYPO3\\CMS\\Backend\\View\\BackendLayout\\DefaultDataProvider', array('getBackendLayout'), array(), '', FALSE);
65  $backendLayoutMock = $this->getMock('TYPO3\\CMS\\Backend\\View\\BackendLayout\\BackendLayout', array('getIdentifier'), array(), '', FALSE);
66  $backendLayoutMock->expects($this->any())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
67  $dataProviderMock->expects($this->once())->method('getBackendLayout')->will($this->returnValue($backendLayoutMock));
68 
69  $this->dataProviderCollection->add('default', $dataProviderMock);
70  $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($backendLayoutIdentifier, 123);
71 
72  $this->assertNotNull($providedBackendLayout);
73  $this->assertEquals($backendLayoutIdentifier, $providedBackendLayout->getIdentifier());
74  }
75 
79  public function providedBackendLayoutIsFound() {
80  $dataProviderIdentifier = $this->getUniqueId('custom');
81  $backendLayoutIdentifier = $this->getUniqueId('identifier');
82 
83  $dataProviderMock = $this->getMock('TYPO3\\CMS\\Backend\\View\\BackendLayout\\DefaultDataProvider', array('getBackendLayout'), array(), '', FALSE);
84  $backendLayoutMock = $this->getMock('TYPO3\\CMS\\Backend\\View\\BackendLayout\\BackendLayout', array('getIdentifier'), array(), '', FALSE);
85  $backendLayoutMock->expects($this->any())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
86  $dataProviderMock->expects($this->once())->method('getBackendLayout')->will($this->returnValue($backendLayoutMock));
87 
88  $this->dataProviderCollection->add($dataProviderIdentifier, $dataProviderMock);
89  $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($dataProviderIdentifier . '__' . $backendLayoutIdentifier, 123);
90 
91  $this->assertNotNull($providedBackendLayout);
92  $this->assertEquals($backendLayoutIdentifier, $providedBackendLayout->getIdentifier());
93  }
94 
95 }