TYPO3 CMS  TYPO3_6-2
ModuleControllerTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $moduleController;
28 
29  protected function setUp() {
30  $this->moduleController = $this->getAccessibleMock('TYPO3\\CMS\\Backend\\Module\\ModuleController', array('getLanguageService'), array(), '', FALSE);
31  }
32 
37  $entry = $this->moduleController->_call('createEntryFromRawData', array());
38  $this->assertInstanceOf('TYPO3\\CMS\\Backend\\Domain\\Model\\Module\\BackendModule', $entry);
39  }
40 
44  public function createEntryFromRawDataSetsPropertiesInEntryObject() {
45  $rawModule = array(
46  'name' => 'nameTest',
47  'title' => 'titleTest',
48  'onclick' => 'onclickTest',
49  'icon' => array(
50  'test' => '123'
51  ),
52  'link' => 'linkTest',
53  'description' => 'descriptionTest',
54  'navigationComponentId' => 'navigationComponentIdTest'
55  );
56 
57  $languageServiceMock = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService', array(), array(), '', FALSE);
58  $languageServiceMock->expects($this->once())->method('sL')->will($this->returnValue('titleTest'));
59  $this->moduleController->expects($this->once())->method('getLanguageService')->will($this->returnValue($languageServiceMock));
60 
62  $entry = $this->moduleController->_call('createEntryFromRawData', $rawModule);
63  $this->assertEquals('nameTest', $entry->getName());
64  $this->assertEquals('titleTest', $entry->getTitle());
65  $this->assertEquals('linkTest', $entry->getLink());
66  $this->assertEquals('onclickTest', $entry->getOnClick());
67  $this->assertEquals('navigationComponentIdTest', $entry->getNavigationComponentId());
68  $this->assertEquals('descriptionTest', $entry->getDescription());
69  $this->assertEquals(array('test' => '123'), $entry->getIcon());
70  }
71 
75  public function createEntryFromRawDataSetsLinkIfPathIsGivenInEntryObject() {
76  $rawModule = array(
77  'path' => 'pathTest'
78  );
80  $entry = $this->moduleController->_call('createEntryFromRawData', $rawModule);
81  $this->assertEquals('pathTest', $entry->getLink());
82  }
83 
84 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)