TYPO3 CMS  TYPO3_6-2
AbstractControllerTest.php
Go to the documentation of this file.
1 <?php
3 
21 
26  $className = $this->getUniqueId('Tx_Extbase_Tests_Fixtures_Controller');
27  eval('class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController { function getExtensionName() { return $this->extensionName; } }');
28  $mockController = new $className();
29  $expectedResult = 'Extbase';
30  $actualResult = $mockController->getExtensionName();
31  $this->assertEquals($expectedResult, $actualResult);
32  }
33 
38  $className = $this->getUniqueId('DummyController');
39  eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController { function getExtensionName() { return $this->extensionName; } }');
40  $classNameNamespaced = __NAMESPACE__ . '\\' . $className;
41  $mockController = new $classNameNamespaced();
42  $expectedResult = 'Extbase';
43  $actualResult = $mockController->getExtensionName();
44  $this->assertEquals($expectedResult, $actualResult);
45  }
46 
50  public function addFlashMessageDataProvider() {
51  return array(
52  array(
53  new \TYPO3\CMS\Core\Messaging\FlashMessage('Simple Message'),
54  'Simple Message',
55  '',
56  \TYPO3\CMS\Core\Messaging\FlashMessage::OK,
57  FALSE
58  ),
59  array(
60  new \TYPO3\CMS\Core\Messaging\FlashMessage('Some OK', 'Message Title', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, TRUE),
61  'Some OK',
62  'Message Title',
63  \TYPO3\CMS\Core\Messaging\FlashMessage::OK,
64  TRUE
65  ),
66  array(
67  new \TYPO3\CMS\Core\Messaging\FlashMessage('Some Info', 'Message Title', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, TRUE),
68  'Some Info',
69  'Message Title',
70  \TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
71  TRUE
72  ),
73  array(
74  new \TYPO3\CMS\Core\Messaging\FlashMessage('Some Notice', 'Message Title', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE, TRUE),
75  'Some Notice',
76  'Message Title',
77  \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE,
78  TRUE
79  ),
80 
81  array(
82  new \TYPO3\CMS\Core\Messaging\FlashMessage('Some Warning', 'Message Title', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, TRUE),
83  'Some Warning',
84  'Message Title',
85  \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
86  TRUE
87  ),
88  array(
89  new \TYPO3\CMS\Core\Messaging\FlashMessage('Some Error', 'Message Title', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE),
90  'Some Error',
91  'Message Title',
92  \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
93  TRUE
94  )
95  );
96  }
97 
102  public function addFlashMessageAddsFlashMessageObjectToFlashMessageQueue($expectedMessage, $messageBody, $messageTitle = '', $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK, $storeInSession = TRUE) {
103  $flashMessageQueue = $this->getMock(
104  'TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue',
105  array('enqueue'),
106  array($this->getUniqueId('identifier_'))
107  );
108  $flashMessageQueue->expects($this->once())->method('enqueue')->with($this->equalTo($expectedMessage));
109 
110  $controllerContext = $this->getMock(
111  '\\TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext',
112  array('getFlashMessageQueue')
113  );
114  $controllerContext->expects($this->once())->method('getFlashMessageQueue')->will($this->returnValue($flashMessageQueue));
115 
116  $controller = $this->getMockForAbstractClass('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController',
117  array(),
118  '',
119  FALSE,
120  TRUE,
121  TRUE,
122  array('dummy')
123  );
124  $this->inject($controller, 'controllerContext', $controllerContext);
125 
126  $controller->addFlashMessage($messageBody, $messageTitle, $severity, $storeInSession);
127  }
128 
134  $controller = $this->getMockForAbstractClass('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController',
135  array(),
136  '',
137  FALSE,
138  TRUE,
139  TRUE,
140  array('dummy')
141  );
142 
143  $controller->addFlashMessage(new \stdClass());
144  }
145 }
inject($target, $name, $dependency)
addFlashMessageAddsFlashMessageObjectToFlashMessageQueue($expectedMessage, $messageBody, $messageTitle='', $severity=\TYPO3\CMS\Core\Messaging\FlashMessage::OK, $storeInSession=TRUE)