Last active
August 29, 2015 14:15
-
-
Save pumatertion/e71ed2f44cb53265621b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\Package\Tests\Functional; | |
use TYPO3\Flow\Annotations as Flow; | |
use TYPO3\Flow\Configuration\ConfigurationManager; | |
use TYPO3\Flow\Tests\FunctionalTestCase; | |
use TYPO3\Eel\Utility as EelUtility; | |
/** | |
* Designed as a functional test, should offer every information you need to get started. | |
*/ | |
class EelStandaloneDemonstrationTest extends FunctionalTestCase { | |
/** | |
* @var \TYPO3\Eel\EelEvaluatorInterface | |
*/ | |
protected $eelEvaluator; | |
/** | |
* @var array | |
*/ | |
protected $defaultContextVariables = array(); | |
/** | |
*/ | |
public function setUp() { | |
parent::setUp(); | |
$this->eelEvaluator = $this->objectManager->get('TYPO3\Eel\EelEvaluatorInterface'); | |
/** @var ConfigurationManager $configurationManager */ | |
$configurationManager = $this->objectManager->get('TYPO3\Flow\Configuration\ConfigurationManager'); | |
$this->defaultContextVariables = $configurationManager->getConfiguration( | |
'Settings', | |
'Acme.Package.defaultEelContextVariables'); | |
} | |
/** | |
* Data provider | |
* Signature: Eel expression, expected evaluation result, context variables | |
*/ | |
public function eelEvaluationDataProvider() { | |
return array( | |
array('${18 + 4 / 2}', 20), | |
array('${foo * foo + 2}', 11, array('foo' => 3)), | |
array('${Math.pow(bar, 3)}', 64, array('bar' => 4)) | |
); | |
} | |
/** | |
* @param string $expression | |
* @param mixed $expectedEvaluation | |
* @param array $contextVariables | |
* @dataProvider eelEvaluationDataProvider | |
* @test | |
*/ | |
public function eelExpressionsAreCorrectlyEvaluated($expression, $expectedEvaluation, $contextVariables = array()) { | |
$actualEvaluation = EelUtility::evaluateEelExpression( | |
$expression, | |
$this->eelEvaluator, | |
$contextVariables, | |
$this->defaultContextVariables); | |
$this->assertEquals($expectedEvaluation, $actualEvaluation); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acme: | |
Package: | |
defaultEelContextVariables: | |
String: 'TYPO3\Eel\Helper\StringHelper' | |
Array: 'TYPO3\Eel\Helper\ArrayHelper' | |
Date: 'TYPO3\Eel\Helper\DateHelper' | |
Configuration: 'TYPO3\Eel\Helper\ConfigurationHelper' | |
Math: 'TYPO3\Eel\Helper\MathHelper' | |
Json: 'TYPO3\Eel\Helper\JsonHelper' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment