1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace QB\Generic\Clause; |
6
|
|
|
|
7
|
|
|
use InvalidArgumentException; |
8
|
|
|
use PDO; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use QB\Generic\Expr\Expr; |
11
|
|
|
use QB\Generic\IQueryPart; |
12
|
|
|
use QB\Generic\Statement\Select; |
13
|
|
|
|
14
|
|
|
class JoinTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
public function toStringGetParamsProvider(): array |
17
|
|
|
{ |
18
|
|
|
return [ |
19
|
|
|
[ |
20
|
|
|
IJoin::TYPE_INNER_JOIN, |
21
|
|
|
new Table('foo', 'f'), |
22
|
|
|
new Expr('f.id = bar.foo_id AND ?', [1]), |
23
|
|
|
'INNER JOIN foo AS f ON f.id = bar.foo_id AND ?', |
24
|
|
|
[[1, PDO::PARAM_INT]], |
25
|
|
|
], |
26
|
|
|
[ |
27
|
|
|
IJoin::TYPE_FULL_JOIN, |
28
|
|
|
new QueryAsTable(new Select(new Column(new Expr('?', [123]))), 'f'), |
29
|
|
|
null, |
30
|
|
|
'FULL JOIN (SELECT ?) AS f', |
31
|
|
|
[[123, PDO::PARAM_INT]], |
32
|
|
|
], |
33
|
|
|
[ |
34
|
|
|
IJoin::TYPE_LEFT_JOIN, |
35
|
|
|
'foo', |
36
|
|
|
'foo.id = bar.foo_id', |
37
|
|
|
'LEFT JOIN foo ON foo.id = bar.foo_id', |
38
|
|
|
[], |
39
|
|
|
], |
40
|
|
|
]; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @dataProvider toStringGetParamsProvider |
45
|
|
|
* |
46
|
|
|
* @param string $type |
47
|
|
|
* @param ITable|string $table |
48
|
|
|
* @param IQueryPart|string|null $on |
49
|
|
|
* @param string $expectedSql |
50
|
|
|
* @param array $expectedParams |
51
|
|
|
*/ |
52
|
|
|
public function testToStringGetParamsProvider( |
53
|
|
|
string $type, |
54
|
|
|
ITable|string $table, |
55
|
|
|
IQueryPart|string|null $on, |
|
|
|
|
56
|
|
|
string $expectedSql, |
57
|
|
|
array $expectedParams |
58
|
|
|
) { |
59
|
|
|
$sut = new Join($type, $table, $on); |
60
|
|
|
|
61
|
|
|
$actualSql = (string)$sut; |
62
|
|
|
$actualParams = $sut->getParams(); |
63
|
|
|
|
64
|
|
|
$this->assertSame($expectedSql, $actualSql); |
65
|
|
|
$this->assertSame($expectedParams, $actualParams); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @suppress PhanNoopNew |
70
|
|
|
*/ |
71
|
|
|
public function testInvalidType() |
72
|
|
|
{ |
73
|
|
|
$this->expectException(InvalidArgumentException::class); |
74
|
|
|
|
75
|
|
|
new Join('foo', new Table('bar', 'b'), 'bar.id = foo.bar_id'); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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