1
|
|
|
<?php |
2
|
|
|
namespace Netdudes\DataSourceryBundle\Tests\Extension; |
3
|
|
|
|
4
|
|
|
use Netdudes\DataSourceryBundle\Extension\BuiltInFunctionsExtension; |
5
|
|
|
use Netdudes\DataSourceryBundle\Extension\Context; |
6
|
|
|
use Netdudes\DataSourceryBundle\Extension\ContextAwareUqlFunction; |
7
|
|
|
use Netdudes\DataSourceryBundle\Extension\Exception\FunctionNotFoundException; |
8
|
|
|
use Netdudes\DataSourceryBundle\Extension\UqlExtensionContainer; |
9
|
|
|
use Netdudes\DataSourceryBundle\Extension\UqlFunction; |
10
|
|
|
use Netdudes\DataSourceryBundle\Extension\UqlFunctionCaller; |
11
|
|
|
use Netdudes\DataSourceryBundle\Util\CurrentDateTimeProvider; |
12
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
13
|
|
|
|
14
|
|
|
class UqlFunctionCallerTest extends \PHPUnit_Framework_TestCase |
15
|
|
|
{ |
16
|
|
|
public function testItThrowsAnExceptionIsFunctionIsNotFound() |
17
|
|
|
{ |
18
|
|
|
$uqlFunction = $this->prophesize(UqlFunction::class)->reveal(); |
19
|
|
|
|
20
|
|
|
$uqlExtensionContainerProphecy = $this->prophesize(UqlExtensionContainer::class); |
21
|
|
|
$uqlExtensionContainerProphecy->getFunctions()->willReturn(['UqlFunction' => $uqlFunction]); |
22
|
|
|
$context = $this->prophesize(Context::class)->reveal(); |
23
|
|
|
|
24
|
|
|
$uqlFunctionCaller = new UqlFunctionCaller($uqlExtensionContainerProphecy->reveal()); |
25
|
|
|
$this->setExpectedException(FunctionNotFoundException::class, 'Could not find UQL function OtherUqlFunction'); |
|
|
|
|
26
|
|
|
$uqlFunctionCaller->callFunction('OtherUqlFunction', [], $context); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testItCallsFunctionWithContextParameter() |
30
|
|
|
{ |
31
|
|
|
$context = $this->prophesize(Context::class)->reveal(); |
32
|
|
|
|
33
|
|
|
$uqlFunctionProphecy = $this->prophesize(UqlFunction::class); |
34
|
|
|
$uqlFunctionProphecy->call([], $context)->shouldBeCalled(); |
35
|
|
|
|
36
|
|
|
$uqlExtensionContainerProphecy = $this->prophesize(UqlExtensionContainer::class); |
37
|
|
|
$uqlExtensionContainerProphecy->getFunctions()->willReturn(['UqlFunction' => $uqlFunctionProphecy->reveal()]); |
38
|
|
|
|
39
|
|
|
$uqlFunctionCaller = new UqlFunctionCaller($uqlExtensionContainerProphecy->reveal()); |
40
|
|
|
$uqlFunctionCaller->callFunction('UqlFunction', [], $context); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.