TYPO3 CMS  TYPO3_6-2
BootstrapTest.php
Go to the documentation of this file.
1 <?php
3 
23 
25  // Tests concerning loadCachedTCA
27 
31  public function loadCachedTcaRequiresCacheFileIfCacheEntryExists() {
33  $bootstrapInstance = $this->getAccessibleMock(
34  'TYPO3\\CMS\\Core\\Core\\Bootstrap',
35  array('dummy'),
36  array(),
37  '',
38  FALSE
39  );
40  $mockCache = $this->getMock(
41  'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
42  array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
43  array(),
44  '',
45  FALSE
46  );
47  $mockCacheManager = $this->getMock(
48  'TYPO3\\CMS\\Core\\Cache\\CacheManager',
49  array('getCache')
50  );
51  $mockCacheManager
52  ->expects($this->any())
53  ->method('getCache')
54  ->will($this->returnValue($mockCache));
55  $mockCache
56  ->expects($this->any())
57  ->method('has')
58  ->will($this->returnValue(TRUE));
59  $mockCache
60  ->expects($this->once())
61  ->method('get');
62  $bootstrapInstance->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
63  $bootstrapInstance->loadCachedTca();
64  }
65 
69  public function loadCachedTcaSetsCacheEntryIfNoCacheEntryExists() {
71  $bootstrapInstance = $this->getAccessibleMock(
72  'TYPO3\\CMS\\Core\\Core\\Bootstrap',
73  array('loadExtensionTables'),
74  array(),
75  '',
76  FALSE
77  );
78  $mockCache = $this->getMock(
79  'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
80  array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
81  array(),
82  '',
83  FALSE
84  );
85  $mockCacheManager = $this->getMock(
86  'TYPO3\\CMS\\Core\\Cache\\CacheManager',
87  array('getCache')
88  );
89  $mockCacheManager
90  ->expects($this->any())
91  ->method('getCache')
92  ->will($this->returnValue($mockCache));
93  $mockCache
94  ->expects($this->any())
95  ->method('has')
96  ->will($this->returnValue(FALSE));
97  $mockCache
98  ->expects($this->once())
99  ->method('set');
100  $bootstrapInstance->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
101  $bootstrapInstance->loadCachedTca();
102  }
103 
110  return array(
111  array('http://proxy:3128/', 'proxy', '3128'),
112  array('http://proxy:3128', 'proxy', '3128'),
113  array('proxy:3128', 'proxy', '3128'),
114  array('https://proxy:3128/', 'proxy', '3128'),
115  );
116  }
117 
122  public function transferDeprecatedCurlSettings($curlProxyServer, $proxyHost, $proxyPort) {
124  $bootstrapInstance = $this->getAccessibleMock(
125  'TYPO3\\CMS\\Core\\Core\\Bootstrap',
126  array('dummy'),
127  array(),
128  '',
129  FALSE
130  );
131  $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'] = $curlProxyServer;
132  $bootstrapInstance->_call('transferDeprecatedCurlSettings');
133  $this->assertEquals($proxyHost, $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host']);
134  $this->assertEquals($proxyPort, $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port']);
135  }
136 
140  public function curlProxyServerDoesNotOverwriteHttpSettings() {
142  $bootstrapInstance = $this->getAccessibleMock(
143  'TYPO3\\CMS\\Core\\Core\\Bootstrap',
144  array('dummy'),
145  array(),
146  '',
147  FALSE
148  );
149 
150  $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'] = 'http://proxyOld:3128/';
151  $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'] = 'userOld:passOld';
152  $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = 'proxyNew';
153  $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = '3128';
154  $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = 'userNew';
155  $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_pass'] = 'passNew';
156 
157  $bootstrapInstance->_call('transferDeprecatedCurlSettings');
158  $this->assertEquals('http://proxyOld:3128/', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']);
159  $this->assertEquals('userOld:passOld', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']);
160  $this->assertEquals('proxyNew', $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host']);
161  $this->assertEquals('3128', $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port']);
162  $this->assertEquals('userNew', $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user']);
163  $this->assertEquals('passNew', $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_pass']);
164  }
165 
169  public function curlAdapterUsedIfCurlUse() {
171  $bootstrapInstance = $this->getAccessibleMock(
172  'TYPO3\\CMS\\Core\\Core\\Bootstrap',
173  array('dummy'),
174  array(),
175  '',
176  FALSE
177  );
178 
179  $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] = TRUE;
180  $bootstrapInstance->_call('transferDeprecatedCurlSettings');
181  $this->assertEquals('curl', $GLOBALS['TYPO3_CONF_VARS']['HTTP']['adapter']);
182  }
183 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]