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