[TASK] EXT:lang unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Tests / Unit / Domain / Model / ExtensionTest.php
1 <?php
2 namespace TYPO3\CMS\Lang\Tests\Unit\Domain\Model;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Wouter Wolters <typo3@wouterwolters.nl>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28
29 /**
30 * Testcase for Extension
31 *
32 * @author Wouter Wolters <typo3@wouterwolters.nl>
33 * @package TYPO3
34 * @subpackage lang
35 */
36 class ExtensionTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
37
38 /**
39 * @var \TYPO3\CMS\Lang\Domain\Model\Extension
40 */
41 protected $fixture = NULL;
42
43 /**
44 * Set up
45 */
46 public function setUp() {
47 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension();
48 }
49
50 /**
51 * Tear down
52 */
53 public function tearDown() {
54 $this->fixture = NULL;
55 }
56
57 /**
58 * @test
59 */
60 public function getKeyInitiallyReturnsEmptyString() {
61 $this->assertSame(
62 '',
63 $this->fixture->getKey()
64 );
65 }
66
67 /**
68 * @test
69 */
70 public function getKeyInitiallyReturnsGivenKeyFromConstruct() {
71 $key = 'foo bar';
72 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension($key);
73
74 $this->assertSame(
75 $key,
76 $this->fixture->getKey()
77 );
78 }
79
80 /**
81 * @test
82 */
83 public function setKeySetsKey() {
84 $key = 'foo bar';
85 $this->fixture->setKey($key);
86
87 $this->assertSame(
88 $key,
89 $this->fixture->getKey()
90 );
91 }
92
93 /**
94 * @test
95 */
96 public function getTitleInitiallyReturnsEmptyString() {
97 $this->assertSame(
98 '',
99 $this->fixture->getTitle()
100 );
101 }
102
103 /**
104 * @test
105 */
106 public function getTitleInitiallyReturnsGivenTitleFromConstruct() {
107 $title = 'foo bar';
108 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension('', $title);
109
110 $this->assertSame(
111 $title,
112 $this->fixture->getTitle()
113 );
114 }
115
116 /**
117 * @test
118 */
119 public function setTitleSetsTitle() {
120 $title = 'foo bar';
121 $this->fixture->setTitle($title);
122
123 $this->assertSame(
124 $title,
125 $this->fixture->getTitle()
126 );
127 }
128
129 /**
130 * @test
131 */
132 public function getIconInitiallyReturnsEmptyString() {
133 $this->assertSame(
134 '',
135 $this->fixture->getIcon()
136 );
137 }
138
139 /**
140 * @test
141 */
142 public function getIconInitiallyReturnsGivenIconFromConstruct() {
143 $icon = 'foo bar';
144 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension('', '', $icon);
145
146 $this->assertSame(
147 $icon,
148 $this->fixture->getIcon()
149 );
150 }
151
152 /**
153 * @test
154 */
155 public function setIconSetsIcon() {
156 $icon = 'foo bar';
157 $this->fixture->setIcon($icon);
158
159 $this->assertSame(
160 $icon,
161 $this->fixture->getIcon()
162 );
163 }
164
165 /**
166 * @test
167 */
168 public function getVersionInitiallyReturnsEmptyString() {
169 $this->assertSame(
170 '',
171 $this->fixture->getVersion()
172 );
173 }
174
175 /**
176 * @test
177 */
178 public function setVersionSetsVersion() {
179 $version = 10;
180 $this->fixture->setVersion($version);
181
182 $this->assertSame(
183 $version,
184 $this->fixture->getVersion()
185 );
186 }
187
188 /**
189 * @test
190 */
191 public function setVersionSetsVersionFromString() {
192 $version = 4012003;
193 $this->fixture->setVersionFromString('4.12.3');
194
195 $this->assertSame(
196 $version,
197 $this->fixture->getVersion()
198 );
199 }
200
201 /**
202 * @test
203 */
204 public function getUpdateResultInitiallyReturnsEmptyArray() {
205 $this->assertSame(
206 array(),
207 $this->fixture->getUpdateResult()
208 );
209 }
210
211 /**
212 * @test
213 */
214 public function setUpdateResultSetsUpdateResult() {
215 $updateResult = array(
216 'nl' => array(
217 'icon' => '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-info">&nbsp;</span>',
218 'message' => 'translation_n_a'
219 ),
220 );
221
222 $this->fixture->setUpdateResult($updateResult);
223
224 $this->assertSame(
225 $updateResult,
226 $this->fixture->getUpdateResult()
227 );
228 }
229
230 }
231 ?>