LanguageDbTest::getFallBackOrderMultipleTimes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace AOE\Languagevisibility\Tests\Functional;
4
use AOE\Languagevisibility\Language;
5
use AOE\Languagevisibility\LanguageRepository;
6
7
/***************************************************************
8
 * Copyright notice
9
 *
10
 * (c) 2016 AOE GmbH <[email protected]>
11
 * All rights reserved
12
 *
13
 * This script is part of the TYPO3 project. The TYPO3 project is
14
 * free software; you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation; either version 2 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * The GNU General Public License can be found at
20
 * http://www.gnu.org/copyleft/gpl.html.
21
 *
22
 * This script is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * This copyright notice MUST APPEAR in all copies of the script!
28
 ***************************************************************/
29
30
class LanguageDbTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
31
32
	/**
33
	 * @var array
34
	 */
35
	protected $coreExtensionsToLoad = array('version', 'workspaces');
36
37
	/**
38
	 * @var array
39
	 */
40
	protected $testExtensionsToLoad = array('typo3conf/ext/languagevisibility');
41
42
	public function setUp(){
43
		parent::setUp();
44
		$this->importDataSet(__DIR__ . '/Fixtures/dbDefaultLangs.xml');
45
		unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']);
46
	}
47
48
	/**
49
	 * The fallback order property is cached. This testcase
50
	 * should ensure that it can be read multiple times.
51
	 *
52
	 * @test
53
	 * @return void
54
	 */
55
	public function getFallBackOrderMultipleTimes() {
56
57
		$el = $this->getMockForAbstractClass('AOE\\Languagevisibility\\Element', array(), '', FALSE);
58
59
		$languageRepository = new LanguageRepository();
60
61
		/* @var $language Language */
62
		$language = $languageRepository->getLanguageById(1);
63
64
		$this->assertEquals(array(0 => 0 ), $language->getFallbackOrder($el));
65
		$this->assertEquals(count(array(0 => 0 )), 1);
66
		$this->assertEquals(array(0 => 0 ), $language->getFallbackOrder($el));
67
68
		$this->assertFalse($language->isLanguageUidInFallbackOrder(22, $el));
69
		$this->assertTrue($language->isLanguageUidInFallbackOrder(0, $el));
70
	}
71
}
72