Completed
Push — 7LTS_compatible ( 4a528e...8b7547 )
by Tomas Norre
02:51
created

DatabaseTtContentTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
c 1
b 0
f 0
lcom 2
cbo 2
dl 0
loc 71
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A _loadWorkspaces() 0 3 1
A _fakeWorkspaceContext() 0 3 1
A _getLang() 0 5 1
A _getContent() 0 7 1
A makeSureLanguagesImported() 0 6 2
A makeSureContentElementsImported() 0 6 2
A flushCache() 0 5 1
1
<?php
2
3
namespace AOE\Languagevisibility\Tests\Functional;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2014 AOE GmbH <[email protected]>
9
 *
10
 *  All rights reserved
11
 *
12
 *  This script is part of the TYPO3 project. The TYPO3 project is
13
 *  free software; you can redistribute it and/or modify
14
 *  it under the terms of the GNU General Public License as published by
15
 *  the Free Software Foundation; either version 3 of the License, or
16
 *  (at your option) any later version.
17
 *
18
 *  The GNU General Public License can be found at
19
 *  http://www.gnu.org/copyleft/gpl.html.
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
use AOE\Languagevisibility\Dao\DaoCommon;
29
use AOE\Languagevisibility\ElementFactory;
30
31
/**
32
 * Class tx_languagevisibility_databaseTtContentTestcase
33
 */
34
abstract class DatabaseTtContentTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
35
36
	/**
37
	 * @var array
38
	 */
39
	protected $coreExtensionsToLoad = array('version', 'workspaces');
40
41
	/**
42
	 * @var array
43
	 */
44
	protected $testExtensionsToLoad = array('typo3conf/ext/languagevisibility');
45
46
	/**
47
	 * @var bool
48
	 */
49
	protected $_langImport = FALSE;
50
51
	/**
52
	 * @var bool
53
	 */
54
	protected $_ceImport = FALSE;
55
56
	public function setUp() {
57
		parent::setUp();
58
		$GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
59
		$this->_loadWorkspaces();
60
		$this->flushCache();
61
	}
62
63
	protected function _loadWorkspaces() {
64
		$this->importDataSet(__DIR__ . '/Fixtures/dbDefaultWorkspaces.xml');
65
	}
66
67
	protected function _fakeWorkspaceContext($uid) {
68
		$GLOBALS['BE_USER']->workspace = $uid;
69
	}
70
71
	protected function _getLang($uid) {
72
		$this->makeSureLanguagesImported();
73
		$languageRep = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\AOE\\Languagevisibility\\LanguageRepository');
74
		return $languageRep->getLanguageById($uid);
75
	}
76
77
	protected function _getContent($table, $uid) {
78
		$this->makeSureContentElementsImported();
79
		$dao = new DaoCommon();
80
81
		$factory = new ElementFactory($dao);
82
		return $factory->getElementForTable($table, $uid);
83
	}
84
85
	protected function makeSureLanguagesImported() {
86
		if (!$this->_langImport) {
87
			$this->_langImport = TRUE;
88
			$this->importDataSet(__DIR__ . '/Fixtures/dbDefaultLangs.xml');
89
		}
90
	}
91
92
	protected function makeSureContentElementsImported() {
93
		if (!$this->_ceImport) {
94
			$this->_ceImport = TRUE;
95
			$this->importDataSet(__DIR__ . '/Fixtures/dbContentWithVisibilityTestdata.xml');
96
		}
97
	}
98
99
	protected function flushCache() {
100
		\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')
101
			->getCache('tx_languagevisibility')
102
			->flush();
103
	}
104
}
105