5f43f7653f421715328f3d28810b094e50a40f48
[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 * 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
17 /**
18 * Testcase for Extension
19 *
20 * @author Wouter Wolters <typo3@wouterwolters.nl>
21 */
22 class ExtensionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Lang\Domain\Model\Extension
26 */
27 protected $fixture = NULL;
28
29 /**
30 * Set up
31 */
32 protected function setUp() {
33 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension();
34 }
35
36 /**
37 * @test
38 */
39 public function getKeyInitiallyReturnsEmptyString() {
40 $this->assertSame(
41 '',
42 $this->fixture->getKey()
43 );
44 }
45
46 /**
47 * @test
48 */
49 public function getKeyInitiallyReturnsGivenKeyFromConstruct() {
50 $key = 'foo bar';
51 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension($key);
52
53 $this->assertSame(
54 $key,
55 $this->fixture->getKey()
56 );
57 }
58
59 /**
60 * @test
61 */
62 public function setKeySetsKey() {
63 $key = 'foo bar';
64 $this->fixture->setKey($key);
65
66 $this->assertSame(
67 $key,
68 $this->fixture->getKey()
69 );
70 }
71
72 /**
73 * @test
74 */
75 public function getTitleInitiallyReturnsEmptyString() {
76 $this->assertSame(
77 '',
78 $this->fixture->getTitle()
79 );
80 }
81
82 /**
83 * @test
84 */
85 public function getTitleInitiallyReturnsGivenTitleFromConstruct() {
86 $title = 'foo bar';
87 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension('', $title);
88
89 $this->assertSame(
90 $title,
91 $this->fixture->getTitle()
92 );
93 }
94
95 /**
96 * @test
97 */
98 public function setTitleSetsTitle() {
99 $title = 'foo bar';
100 $this->fixture->setTitle($title);
101
102 $this->assertSame(
103 $title,
104 $this->fixture->getTitle()
105 );
106 }
107
108 /**
109 * @test
110 */
111 public function getIconInitiallyReturnsEmptyString() {
112 $this->assertSame(
113 '',
114 $this->fixture->getIcon()
115 );
116 }
117
118 /**
119 * @test
120 */
121 public function getIconInitiallyReturnsGivenIconFromConstruct() {
122 $icon = 'foo bar';
123 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Extension('', '', $icon);
124
125 $this->assertSame(
126 $icon,
127 $this->fixture->getIcon()
128 );
129 }
130
131 /**
132 * @test
133 */
134 public function setIconSetsIcon() {
135 $icon = 'foo bar';
136 $this->fixture->setIcon($icon);
137
138 $this->assertSame(
139 $icon,
140 $this->fixture->getIcon()
141 );
142 }
143
144 /**
145 * @test
146 */
147 public function getVersionInitiallyReturnsEmptyString() {
148 $this->assertSame(
149 '',
150 $this->fixture->getVersion()
151 );
152 }
153
154 /**
155 * @test
156 */
157 public function setVersionSetsVersion() {
158 $version = 10;
159 $this->fixture->setVersion($version);
160
161 $this->assertSame(
162 $version,
163 $this->fixture->getVersion()
164 );
165 }
166
167 /**
168 * @test
169 */
170 public function setVersionSetsVersionFromString() {
171 $version = 4012003;
172 $this->fixture->setVersionFromString('4.12.3');
173
174 $this->assertSame(
175 $version,
176 $this->fixture->getVersion()
177 );
178 }
179
180 /**
181 * @test
182 */
183 public function getUpdateResultInitiallyReturnsEmptyArray() {
184 $this->assertSame(
185 array(),
186 $this->fixture->getUpdateResult()
187 );
188 }
189
190 /**
191 * @test
192 */
193 public function setUpdateResultSetsUpdateResult() {
194 $updateResult = array(
195 'nl' => array(
196 'icon' => '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-info">&nbsp;</span>',
197 'message' => 'translation_n_a'
198 ),
199 );
200
201 $this->fixture->setUpdateResult($updateResult);
202
203 $this->assertSame(
204 $updateResult,
205 $this->fixture->getUpdateResult()
206 );
207 }
208
209 }