13697.diff

Administrator Admin, 2010-03-08 18:51

Download (3.71 KB)

View differences:

tests/t3lib/fixtures/ext_emconf.php (revision 0)
1
<?php
2
$EM_CONF[$_EXTKEY] = array(
3
	'title' => '',
4
	'description' => 'This is a fixture extension configuration file used for unit tests.',
5
	'category' => '',
6
	'shy' => 1,
7
	'dependencies' => '',
8
	'conflicts' => '',
9
	'priority' => '',
10
	'loadOrder' => '',
11
	'module' => '',
12
	'state' => 'stable',
13
	'internal' => 1,
14
	'uploadfolder' => 0,
15
	'createDirs' => '',
16
	'modify_tables' => '',
17
	'clearCacheOnLoad' => 0,
18
	'lockType' => '',
19
	'author' => '',
20
	'author_email' => '',
21
	'author_company' => '',
22
	'CGLcompliance' => '',
23
	'CGLcompliance_note' => '',
24
	'version' => '1.2.3',
25
	'_md5_values_when_last_written' => '',
26
	'constraints' => array(
27
		'depends' => array(
28
		),
29
		'conflicts' => array(
30
		),
31
		'suggests' => array(
32
		),
33
	),
34
	'suggests' => array(
35
	),
36
);
37
?>
tests/t3lib/t3lib_extmgm_testcase.php (working copy)
401 401
			'newA, newB, fieldX', $GLOBALS['TCA'][$table]['palettes']['generatedFor-fieldA']['showitem']
402 402
		);
403 403
	}
404

  
405

  
406
	/////////////////////////////////////////
407
	// Tests concerning getExtensionVersion
408
	/////////////////////////////////////////
409

  
410
	/**
411
	 * @test
412
	 */
413
	public function getExtensionVersionForEmptyExtensionKeyThrowsException() {
414
		$this->setExpectedException(
415
			't3lib_exception', '$key must not be empty.'
416
		);
417

  
418
		t3lib_extMgm::getExtensionVersion('');
419
	}
420

  
421
	/**
422
	 * @test
423
	 */
424
	public function getExtensionVersionForNotLoadedExtensionThrowsException() {
425
		t3lib_extMgm::clearExtensionKeyMap();
426

  
427
		$uniqueSuffix = uniqid('test');
428
		$extensionKey = 'unloadedextension' . $uniqueSuffix;
429

  
430
		$this->setExpectedException(
431
			't3lib_exception',
432
			'The extension ' . $extensionKey . ' is not installed.'
433
		);
434
		t3lib_extMgm::getExtensionVersion($extensionKey);
435
	}
436

  
437
	/**
438
	 * @test
439
	 */
440
	public function getExtensionVersionForLoadedExtensionReturnsExtensionVersion() {
441
		t3lib_extMgm::clearExtensionKeyMap();
442

  
443
		$uniqueSuffix = uniqid('test');
444
		$extensionKey = 'unloadedextension' . $uniqueSuffix;
445

  
446
		$GLOBALS['TYPO3_LOADED_EXT'][$extensionKey] = array(
447
			'siteRelPath' => 'typo3_src/tests/t3lib/fixtures/',
448
		);
449
		$this->assertEquals(
450
			'1.2.3',
451
			t3lib_extMgm::getExtensionVersion($extensionKey)
452
		);
453
	}
404 454
}
405 455
?>
t3lib/class.t3lib_extmgm.php (working copy)
229 229
		self::$extensionKeyMap = NULL;
230 230
	}
231 231

  
232
	/**
233
	 * Retrieves the version of an installed extension.
234
	 *
235
	 * @param string $key the key of the extension to look up, must not be empty
236
	 *
237
	 * @return string the extension version as a string in the format "x.y.z"
238
	 */
239
	static public function getExtensionVersion($key) {
240
		global $_EXTKEY;
241

  
242
		if ($key === '') {
243
			throw new t3lib_exception('$key must not be empty.');
244
		}
245
		if (!self::isLoaded($key)) {
246
			throw new t3lib_exception(
247
				'The extension ' . $key . ' is not installed.'
248
			);
249
		}
232 250

  
251
		$_EXTKEY = $key;
252
		include(t3lib_extMgm::extPath($key) . 'ext_emconf.php');
233 253

  
254
		return $EM_CONF[$key]['version'];
255
	}
256

  
257

  
234 258

  
235 259

  
236 260