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