1
|
|
|
<?php |
2
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
3
|
|
|
use HexMakina\Crudites\Grammar\Clause\Where; |
4
|
|
|
use HexMakina\Crudites\Grammar\Predicate; |
5
|
|
|
|
6
|
|
|
class WhereTest extends TestCase |
7
|
|
|
{ |
8
|
|
|
public function testConstructor() |
9
|
|
|
{ |
10
|
|
|
$where = new Where('default_table'); |
11
|
|
|
$this->assertInstanceOf(Where::class, $where); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function testBindings() |
15
|
|
|
{ |
16
|
|
|
$where = new Where('default_table'); |
17
|
|
|
$this->assertIsArray($where->bindings()); |
18
|
|
|
$this->assertEmpty($where->bindings()); |
19
|
|
|
|
20
|
|
|
$where->andPredicate((new Predicate(['table', 'field'], '='))->withValue(3)); |
21
|
|
|
$this->assertNotEmpty($where->bindings()); |
22
|
|
|
$this->assertArrayHasKey('table_field', $where->bindings()); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testToString() |
26
|
|
|
{ |
27
|
|
|
$where = new Where('default_table'); |
28
|
|
|
$this->assertEquals('', $where->__toString()); |
29
|
|
|
|
30
|
|
|
$predicate = new Predicate('1', '=', '1'); |
31
|
|
|
$where->andPredicate($predicate); |
32
|
|
|
$this->assertEquals('WHERE 1 = 1', $where->__toString()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testAndRaw() |
36
|
|
|
{ |
37
|
|
|
$where = new Where('default_table'); |
38
|
|
|
$where->andRaw('1=1'); |
39
|
|
|
$this->assertEquals('WHERE 1=1', $where->__toString()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testAndPredicate() |
43
|
|
|
{ |
44
|
|
|
$where = new Where('default_table'); |
45
|
|
|
$where->andPredicate(new Predicate('1', '=', '1')); |
46
|
|
|
|
47
|
|
|
$this->assertEquals('WHERE 1 = 1', (string)$where); |
48
|
|
|
$this->assertEquals([], $where->bindings()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testAndIsNull() |
52
|
|
|
{ |
53
|
|
|
$where = new Where('default_table'); |
54
|
|
|
$where->andIsNull('field'); |
55
|
|
|
$this->assertStringContainsString('IS NULL', $where->__toString()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testAndFields() |
59
|
|
|
{ |
60
|
|
|
$where = new Where('default_table'); |
61
|
|
|
$where->andFields(['field' => 'value']); |
62
|
|
|
$this->assertStringContainsString('=', $where->__toString()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testAndIn() |
66
|
|
|
{ |
67
|
|
|
$where = new Where('default_table'); |
68
|
|
|
$where->andIn('field', ['value1', 'value2']); |
69
|
|
|
$this->assertStringContainsString('IN', $where->__toString()); |
70
|
|
|
} |
71
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths