This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Netdudes\DataSourceryBundle\Tests\UQL; |
||
3 | |||
4 | use Netdudes\DataSourceryBundle\DataSource\Configuration\Field; |
||
5 | use Netdudes\DataSourceryBundle\DataSource\DataSourceInterface; |
||
6 | use Netdudes\DataSourceryBundle\DataType\NumberDataType; |
||
7 | use Netdudes\DataSourceryBundle\DataType\StringDataType; |
||
8 | use Netdudes\DataSourceryBundle\Extension\ContextFactory; |
||
9 | use Netdudes\DataSourceryBundle\Extension\UqlExtensionContainer; |
||
10 | use Netdudes\DataSourceryBundle\Query\Filter; |
||
11 | use Netdudes\DataSourceryBundle\Query\FilterCondition; |
||
12 | use Netdudes\DataSourceryBundle\Query\FilterConditionFactory; |
||
13 | use Netdudes\DataSourceryBundle\UQL\AST\ASTAssertion; |
||
14 | use Netdudes\DataSourceryBundle\UQL\AST\ASTGroup; |
||
15 | use Netdudes\DataSourceryBundle\UQL\Exception\UQLInterpreterException; |
||
16 | use Netdudes\DataSourceryBundle\UQL\InterpreterFactory; |
||
17 | use PHPUnit\Framework\TestCase; |
||
18 | |||
19 | class InterpreterTest extends TestCase |
||
20 | { |
||
21 | /** |
||
22 | * @var ContextFactory |
||
23 | */ |
||
24 | private $contextFactoryProphecy; |
||
25 | |||
26 | /** |
||
27 | * @var UqlExtensionContainer |
||
28 | */ |
||
29 | private $extensionContainerProphecy; |
||
30 | |||
31 | public function testBuildFilter() |
||
32 | { |
||
33 | $astSubtree = new ASTGroup( |
||
34 | 'T_LOGIC_AND', |
||
35 | [ |
||
36 | new ASTGroup( |
||
37 | 'T_LOGIC_OR', |
||
38 | [ |
||
39 | new ASTAssertion( |
||
40 | 'test_dse_1', |
||
41 | 'T_OP_EQ', |
||
42 | 'value1' |
||
43 | ), |
||
44 | new ASTAssertion( |
||
45 | 'test_dse_2', |
||
46 | 'T_OP_LT', |
||
47 | 'value2' |
||
48 | ), |
||
49 | ] |
||
50 | ), |
||
51 | new ASTAssertion( |
||
52 | 'test_dse_3', |
||
53 | 'T_OP_NEQ', |
||
54 | 'value3' |
||
55 | ), |
||
56 | ] |
||
57 | ); |
||
58 | |||
59 | $filterDefinition1 = new Filter(); |
||
60 | $filterDefinition1->setConditionType('OR'); |
||
61 | $filter1 = new FilterCondition('test_dse_1', FilterCondition::METHOD_NUMERIC_EQ, 'value1', 'value1'); |
||
62 | $filter2 = new FilterCondition('test_dse_2', FilterCondition::METHOD_NUMERIC_LT, 'value2', 'value2'); |
||
63 | $filterDefinition1[] = $filter1; |
||
64 | $filterDefinition1[] = $filter2; |
||
65 | $filter3 = new FilterCondition('test_dse_3', FilterCondition::METHOD_NUMERIC_NEQ, 'value3', 'value3'); |
||
66 | $filterDefinition2 = new Filter(); |
||
67 | $filterDefinition2->setConditionType('AND'); |
||
68 | $filterDefinition2[] = $filterDefinition1; |
||
69 | $filterDefinition2[] = $filter3; |
||
70 | |||
71 | $expectedFilter = $filterDefinition2; |
||
72 | |||
73 | $dataSourceElements = [ |
||
74 | new Field('test_dse_1', '', '', new NumberDataType()), |
||
75 | new Field('test_dse_2', '', '', new NumberDataType()), |
||
76 | new Field('test_dse_3', '', '', new NumberDataType()), |
||
77 | ]; |
||
78 | |||
79 | $dataSourceProphecy = $this->prophesize(DataSourceInterface::class); |
||
80 | $dataSourceProphecy->getFields()->willReturn($dataSourceElements); |
||
81 | |||
82 | $interpreterFactory = new InterpreterFactory($this->extensionContainerProphecy->reveal(), new FilterConditionFactory(), $this->contextFactoryProphecy->reveal()); |
||
0 ignored issues
–
show
The method
reveal() does not seem to exist on object<Netdudes\DataSour...tension\ContextFactory> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
83 | $interpreter = $interpreterFactory->create($dataSourceProphecy->reveal()); |
||
84 | |||
85 | $actualFilter = $interpreter->buildFilter($astSubtree); |
||
86 | $this->assertEquals($expectedFilter, $actualFilter); |
||
87 | } |
||
88 | |||
89 | View Code Duplication | public function testTranslateOperator() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
90 | { |
||
91 | // Manually set the data source element, mimic what the data source would do |
||
92 | $dataSourceElement = new Field( |
||
93 | 'test_data_source_element_name', |
||
94 | '', |
||
95 | '', |
||
96 | new StringDataType() |
||
97 | ); |
||
98 | |||
99 | $dataSourceProphecy = $this->prophesize(DataSourceInterface::class); |
||
100 | $dataSourceProphecy->getFields()->willReturn([$dataSourceElement]); |
||
101 | |||
102 | $interpreterFactory = new InterpreterFactory($this->extensionContainerProphecy->reveal(), new FilterConditionFactory(), $this->contextFactoryProphecy->reveal()); |
||
0 ignored issues
–
show
The method
reveal() does not seem to exist on object<Netdudes\DataSour...\UqlExtensionContainer> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() The method
reveal() does not seem to exist on object<Netdudes\DataSour...tension\ContextFactory> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
103 | $interpreter = $interpreterFactory->create($dataSourceProphecy->reveal()); |
||
104 | |||
105 | // LIKE is valid for String type, should return LIKE |
||
106 | $this->assertEquals(FilterCondition::METHOD_STRING_LIKE, $interpreter->translateOperator('T_OP_LIKE', $dataSourceElement), 'Failed to translate T_OP_LIKE into STRING_LIKE for type String'); |
||
107 | |||
108 | // EQ is valid for String, and should choose STRING_EQ as it's the default for the type |
||
109 | $this->assertEquals(FilterCondition::METHOD_STRING_EQ, $interpreter->translateOperator('T_OP_EQ', $dataSourceElement), 'Failed to translate T_OP_EQ into STRING_EQ for type String'); |
||
110 | } |
||
111 | |||
112 | View Code Duplication | public function testInStatementsOnlyAcceptArraysAsValues() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
113 | { |
||
114 | $astSubtree = new ASTAssertion('field', 'T_OP_IN', '123'); |
||
115 | $field = new Field('field', '', '', new NumberDataType()); |
||
116 | |||
117 | $dataSourceProphecy = $this->prophesize(DataSourceInterface::class); |
||
118 | $dataSourceProphecy->getFields()->willReturn([$field]); |
||
119 | |||
120 | $interpreterFactory = new InterpreterFactory($this->extensionContainerProphecy->reveal(), new FilterConditionFactory(), $this->contextFactoryProphecy->reveal()); |
||
0 ignored issues
–
show
The method
reveal() does not seem to exist on object<Netdudes\DataSour...\UqlExtensionContainer> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() The method
reveal() does not seem to exist on object<Netdudes\DataSour...tension\ContextFactory> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
121 | $interpreter = $interpreterFactory->create($dataSourceProphecy->reveal()); |
||
122 | |||
123 | $this->expectException(UQLInterpreterException::class); |
||
124 | $this->expectExceptionMessage('Only arrays are valid arguments for IN / NOT IN statements'); |
||
125 | $interpreter->buildFilter($astSubtree); |
||
126 | } |
||
127 | |||
128 | View Code Duplication | public function testNullValueCanBeCheckedOnlyWithIsOperator() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
129 | { |
||
130 | $astSubtree = new ASTAssertion('field', 'T_OP_GT', null); |
||
131 | $field = new Field('field', '', '', new NumberDataType()); |
||
132 | |||
133 | $dataSourceProphecy = $this->prophesize(DataSourceInterface::class); |
||
134 | $dataSourceProphecy->getFields()->willReturn([$field]); |
||
135 | |||
136 | $interpreterFactory = new InterpreterFactory($this->extensionContainerProphecy->reveal(), new FilterConditionFactory(), $this->contextFactoryProphecy->reveal()); |
||
0 ignored issues
–
show
The method
reveal() does not seem to exist on object<Netdudes\DataSour...\UqlExtensionContainer> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() The method
reveal() does not seem to exist on object<Netdudes\DataSour...tension\ContextFactory> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
137 | $interpreter = $interpreterFactory->create($dataSourceProphecy->reveal()); |
||
138 | |||
139 | $this->expectException(UQLInterpreterException::class); |
||
140 | $this->expectExceptionMessage('Only IS / IS NOT operator can be used to compare against null value'); |
||
141 | $interpreter->buildFilter($astSubtree); |
||
142 | } |
||
143 | |||
144 | protected function setUp() |
||
145 | { |
||
146 | $this->extensionContainerProphecy = $this->prophesize(UqlExtensionContainer::class); |
||
0 ignored issues
–
show
It seems like
$this->prophesize(\Netdu...ensionContainer::class) of type object<Prophecy\Prophecy\ObjectProphecy> is incompatible with the declared type object<Netdudes\DataSour...\UqlExtensionContainer> of property $extensionContainerProphecy .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
147 | $this->contextFactoryProphecy = $this->prophesize(ContextFactory::class); |
||
0 ignored issues
–
show
It seems like
$this->prophesize(\Netdu...\ContextFactory::class) of type object<Prophecy\Prophecy\ObjectProphecy> is incompatible with the declared type object<Netdudes\DataSour...tension\ContextFactory> of property $contextFactoryProphecy .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
148 | } |
||
149 | } |
||
150 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.