TYPO3 CMS  TYPO3_7-6
ModuleControllerTest.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 
21 {
25  protected $moduleController;
26 
27  protected function setUp()
28  {
29  $this->moduleController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Module\ModuleController::class, ['getLanguageService'], [], '', false);
30  }
31 
36  {
37  $entry = $this->moduleController->_call('createEntryFromRawData', []);
38  $this->assertInstanceOf(\TYPO3\CMS\Backend\Domain\Model\Module\BackendModule::class, $entry);
39  }
40 
44  public function createEntryFromRawDataSetsPropertiesInEntryObject()
45  {
46  $rawModule = [
47  'name' => 'nameTest',
48  'title' => 'titleTest',
49  'onclick' => 'onclickTest',
50  'icon' => [
51  'test' => '123'
52  ],
53  'link' => 'linkTest',
54  'description' => 'descriptionTest',
55  'navigationComponentId' => 'navigationComponentIdTest'
56  ];
57 
58  $languageServiceMock = $this->getMock(\TYPO3\CMS\Lang\LanguageService::class, [], [], '', false);
59  $languageServiceMock->expects($this->once())->method('sL')->will($this->returnValue('titleTest'));
60  $this->moduleController->expects($this->once())->method('getLanguageService')->will($this->returnValue($languageServiceMock));
61 
63  $entry = $this->moduleController->_call('createEntryFromRawData', $rawModule);
64  $this->assertEquals('nameTest', $entry->getName());
65  $this->assertEquals('titleTest', $entry->getTitle());
66  $this->assertEquals('linkTest', $entry->getLink());
67  $this->assertEquals('onclickTest', $entry->getOnClick());
68  $this->assertEquals('navigationComponentIdTest', $entry->getNavigationComponentId());
69  $this->assertEquals('descriptionTest', $entry->getDescription());
70  $this->assertEquals(['test' => '123'], $entry->getIcon());
71  }
72 
76  public function createEntryFromRawDataSetsLinkIfPathIsGivenInEntryObject()
77  {
78  $rawModule = [
79  'path' => 'pathTest'
80  ];
82  $entry = $this->moduleController->_call('createEntryFromRawData', $rawModule);
83  $this->assertEquals('pathTest', $entry->getLink());
84  }
85 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)