Zum Inhalt springen

PHPUnit & ConfigurationManager

Erstellt am 17. Mai 2011 · Noch keine Antworten

Tags: Frage

katja ·

Hallo t3*,

ich habe versucht die ersten Tests zu schreiben und bin gleich auf einen bösen Fehler gestoßen:

Ich kann eine Instanz von CManager problemlos im Model erzeugen:

public function __construct( $vars ){
	$configurationManager = t3lib_div::makeInstance('Tx_Extbase_Configuration_ConfigurationManager');
	$this->config = $configurationManager->getConfiguration('Settings', 'myext', 'pi1');
	$this->setVars( $vars );
	$this->setURL();
}

Wenn ich aber dieses Objekt innerhalb von einem Test aufrufe

public function varsCanBeSet() {
	$vars = array( 'name'=>'katja' );
	$query = t3lib_div::makeInstance('TX_Myext_Domain_Model_QueryList', $vars);
	$this->assertEquals($vars, $query->getVars());	
}

bekomme ich "Fatal error: Call to a member function getConfiguration() on a non-object in ../typo3_src-4.5.2/typo3/sysext/extbase/Classes/Configuration/ConfigurationManager.php on line 107"

Kann mir jemand vielleicht helfen??😢

Nachtrag:
der Manager schaut so aus:

object(Tx_Extbase_Configuration_ConfigurationManager)#50 (2) {
  ["objectManager:protected"]=>
  NULL
  ["concreteConfigurationManager:protected"]=>
  NULL
}

und GetConfiguration schaut so aus

	public function getConfiguration($configurationType, $extensionName = NULL, $pluginName = NULL) {
		switch ($configurationType) {
			case self::CONFIGURATION_TYPE_SETTINGS :
				$configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
				return $configuration['settings'];
			case self::CONFIGURATION_TYPE_FRAMEWORK :
				return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
			case self::CONFIGURATION_TYPE_FULL_TYPOSCRIPT :
				return $this->concreteConfigurationManager->getTypoScriptSetup();
			default :
				throw new Tx_Extbase_Configuration_Exception_InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879);
		}
	}

$this->concreteConfigurationManager ist NULL 🙁 Warum?

Nachtrag2: Ich soll anscheinend eine 'FE'-Umgebung nachbauen

	protected function initializeConcreteConfigurationManager() {
		if (TYPO3_MODE === 'FE') {
			$this->concreteConfigurationManager = $this->objectManager->get('Tx_Extbase_Configuration_FrontendConfigurationManager');
		} else {
			$this->concreteConfigurationManager = $this->objectManager->get('Tx_Extbase_Configuration_BackendConfigurationManager');
		}
	}

Danke & Grüße
Katja