13697_v2.diff

Administrator Admin, 2010-03-25 14:02

Download (3.66 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 getExtensionVersionForNotLoadedExtensionReturnsEmptyString() {
425
		t3lib_extMgm::clearExtensionKeyMap();
426

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

  
430
		$this->assertEquals(
431
			'',
432
			t3lib_extMgm::getExtensionVersion($extensionKey)
433
		);
434
	}
435

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

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

  
445
		$GLOBALS['TYPO3_LOADED_EXT'][$extensionKey] = array(
446
			'siteRelPath' => 'typo3_src/tests/t3lib/fixtures/',
447
		);
448
		$this->assertEquals(
449
			'1.2.3',
450
			t3lib_extMgm::getExtensionVersion($extensionKey)
451
		);
452
	}
404 453
}
405 454
?>
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
	 * If the extension is not installed, this function returns an empty string.
236
	 *
237
	 * @param string $key the key of the extension to look up, must not be empty
238
	 *
239
	 * @return string the extension version as a string in the format "x.y.z",
240
	 *                will be an empty string if the extension is not loaded
241
	 */
242
	static public function getExtensionVersion($key) {
243
		if ($key === '') {
244
			throw new t3lib_exception('$key must not be empty.');
245
		}
246
		if (!self::isLoaded($key)) {
247
			return '';
248
		}
232 249

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

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

  
235 256

  
236 257