Completed
Pull Request — master (#15)
by
unknown
02:47
created

testItThrowsAnExceptionIsFunctionIsNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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.

Loading history...
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