[TASK] EXT:lang unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Tests / Unit / Domain / Model / LanguageTest.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 Language
31 *
32 * @author Wouter Wolters <typo3@wouterwolters.nl>
33 * @package TYPO3
34 * @subpackage lang
35 */
36 class LanguageTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
37
38 /**
39 * @var \TYPO3\CMS\Lang\Domain\Model\Language
40 */
41 protected $fixture = NULL;
42
43 /**
44 * Set up
45 */
46 public function setUp() {
47 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Language();
48 }
49
50 /**
51 * Tear down
52 */
53 public function tearDown() {
54 $this->fixture = NULL;
55 }
56
57 /**
58 * @test
59 */
60 public function getLocaleInitiallyReturnsEmptyString() {
61 $this->assertSame(
62 '',
63 $this->fixture->getLocale()
64 );
65 }
66
67 /**
68 * @test
69 */
70 public function getLocaleInitiallyReturnsGivenLocaleFromConstruct() {
71 $locale = 'nl';
72 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Language($locale);
73
74 $this->assertSame(
75 $locale,
76 $this->fixture->getLocale()
77 );
78 }
79
80 /**
81 * @test
82 */
83 public function setLocaleSetsLocale() {
84 $locale = 'nl';
85 $this->fixture->setLocale($locale);
86
87 $this->assertSame(
88 $locale,
89 $this->fixture->getLocale()
90 );
91 }
92
93 /**
94 * @test
95 */
96 public function getLanguageInitiallyReturnsEmptyString() {
97 $this->assertSame(
98 '',
99 $this->fixture->getLanguage()
100 );
101 }
102
103 /**
104 * @test
105 */
106 public function getLanguageInitiallyReturnsGivenLanguageFromConstruct() {
107 $language = 'nl';
108 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Language('', $language);
109
110 $this->assertSame(
111 $language,
112 $this->fixture->getLanguage()
113 );
114 }
115
116 /**
117 * @test
118 */
119 public function setLanguageSetsLanguage() {
120 $language = 'nl';
121 $this->fixture->setLanguage($language);
122
123 $this->assertSame(
124 $language,
125 $this->fixture->getLanguage()
126 );
127 }
128
129 /**
130 * @test
131 */
132 public function getSelectedInitiallyReturnsFalse() {
133 $this->assertSame(
134 FALSE,
135 $this->fixture->getSelected()
136 );
137 }
138
139 /**
140 * @test
141 */
142 public function getSelectedInitiallyReturnsGivenSelectedFromConstruct() {
143 $selected = FALSE;
144 $this->fixture = new \TYPO3\CMS\Lang\Domain\Model\Language('', '', FALSE);
145
146 $this->assertSame(
147 $selected,
148 $this->fixture->getSelected()
149 );
150 }
151
152 /**
153 * @test
154 */
155 public function setSelectedSetsSelected() {
156 $selected = TRUE;
157 $this->fixture->setSelected($selected);
158
159 $this->assertSame(
160 $selected,
161 $this->fixture->getSelected()
162 );
163 }
164
165 }
166 ?>