0013697_v3.patch

Administrator Admin, 2010-03-26 23:11

Download (3.81 KB)

View differences:

tests/t3lib/t3lib_extmgm_testcase.php (Arbeitskopie)
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
	 * Data provider for negative getExtensionVersion() tests.
412
	 *
413
	 * @return array
414
	 */
415
	public function getExtensionVersionFaultyDataProvider() {
416
		return array(
417
			array(''),
418
			array(0),
419
			array(new stdClass()),
420
			array(TRUE),
421
		);
422
	}
423

  
424
	/**
425
	 * @test
426
	 * @expectedException InvalidArgumentException
427
	 * @dataProvider getExtensionVersionFaultyDataProvider
428
	 */
429
	public function getExtensionVersionForFaultyExtensionKeyThrowsException($key) {
430
		t3lib_extMgm::getExtensionVersion($key);
431
	}
432

  
433
	/**
434
	 * @test
435
	 */
436
	public function getExtensionVersionForNotLoadedExtensionReturnsEmptyString() {
437
		t3lib_extMgm::clearExtensionKeyMap();
438

  
439
		$uniqueSuffix = uniqid('test');
440
		$extensionKey = 'unloadedextension' . $uniqueSuffix;
441

  
442
		$this->assertEquals(
443
			'',
444
			t3lib_extMgm::getExtensionVersion($extensionKey)
445
		);
446
	}
447

  
448
	/**
449
	 * @test
450
	 */
451
	public function getExtensionVersionForLoadedExtensionReturnsExtensionVersion() {
452
		t3lib_extMgm::clearExtensionKeyMap();
453

  
454
		$uniqueSuffix = uniqid('test');
455
		$extensionKey = 'unloadedextension' . $uniqueSuffix;
456

  
457
		$GLOBALS['TYPO3_LOADED_EXT'][$extensionKey] = array(
458
			'siteRelPath' => 'typo3_src/tests/t3lib/fixtures/',
459
		);
460
		$this->assertEquals(
461
			'1.2.3',
462
			t3lib_extMgm::getExtensionVersion($extensionKey)
463
		);
464
	}
404 465
}
405 466
?>
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
?>
t3lib/class.t3lib_extmgm.php (Arbeitskopie)
229 229
		self::$extensionKeyMap = NULL;
230 230
	}
231 231

  
232
	/**
233
	 * Retrieves the version of an installed extension.
234
	 * If the extension is not installed, this function returns an empty string.
235
	 *
236
	 * @param string $key the key of the extension to look up, must not be empty
237
	 * @return string the extension version as a string in the format "x.y.z",
238
	 *                will be an empty string if the extension is not loaded
239
	 */
240
	public static function getExtensionVersion($key) {
241
		if (!is_string($key) || empty($key)) {
242
			throw new InvalidArgumentException('Extension key must be a non-empty string.');
243
		}
244
		if (!self::isLoaded($key)) {
245
			return '';
246
		}
232 247

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

  
251
		return $EM_CONF[$key]['version'];
252
	}
234 253

  
235 254

  
236 255