public function testExecuteOperation() { $operationManager = new tx_caretakerinstance_OperationManager(); $operation = $this->getMock('tx_caretakerinstance_IOperation', array('execute')); $operation->expects($this->once())->method('execute')->with($this->equalTo(array('foo' => 'bar')))->will($this->returnValue(new tx_caretakerinstance_OperationResult(true, 'bar'))); $operationManager->registerOperation('mock', $operation); $result = $operationManager->executeOperation('mock', array('foo' => 'bar')); $this->assertTrue($result->isSuccessful()); $this->assertEquals('bar', $result->getValue()); }
/** * @return tx_caretakerinstance_OperationManager */ public function getOperationManager() { if ($this->operationManager == null) { $this->operationManager = new tx_caretakerinstance_OperationManager(); if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['caretaker_instance']['operations'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['caretaker_instance']['operations'] as $key => $operationRef) { if (is_string($operationRef)) { $operation = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($operationRef); } elseif ($operationRef instanceof tx_caretakerinstance_IOperation) { $operation = $operationRef; } else { // TODO log error if some strange value is registered } $this->operationManager->registerOperation($key, $operation); } } } return $this->operationManager; }