|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
namespace Aimeos\Base\Criteria\Expression\Sort; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class SQLTest extends \PHPUnit\Framework\TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
private $conn = null; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
protected function setUp() : void |
|
19
|
|
|
{ |
|
20
|
|
|
if( \TestHelperMw::getConfig()->get( 'resource/db/adapter', false ) === false ) { |
|
|
|
|
|
|
21
|
|
|
$this->markTestSkipped( 'No database configured' ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
$dbm = \TestHelperMw::getDBManager(); |
|
26
|
|
|
$this->conn = $dbm->acquire(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
protected function tearDown() : void |
|
31
|
|
|
{ |
|
32
|
|
|
$dbm = \TestHelperMw::getDBManager(); |
|
33
|
|
|
$dbm->release( $this->conn ); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
public function testGetOperators() |
|
38
|
|
|
{ |
|
39
|
|
|
$expected = array( '+', '-' ); |
|
40
|
|
|
$actual = \Aimeos\Base\Criteria\Expression\Sort\SQL::getOperators(); |
|
41
|
|
|
$this->assertEquals( $expected, $actual ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
public function testGetOperator() |
|
46
|
|
|
{ |
|
47
|
|
|
$expr = new \Aimeos\Base\Criteria\Expression\Sort\SQL( $this->conn, '+', 'test' ); |
|
48
|
|
|
$this->assertEquals( '+', $expr->getOperator() ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testGetName() |
|
53
|
|
|
{ |
|
54
|
|
|
$expr = new \Aimeos\Base\Criteria\Expression\Sort\SQL( $this->conn, '-', 'test' ); |
|
55
|
|
|
$this->assertEquals( 'test', $expr->getName() ); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
public function testToString() |
|
60
|
|
|
{ |
|
61
|
|
|
$types = array( |
|
62
|
|
|
'test' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
|
63
|
|
|
'test()' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
$translations = array( |
|
67
|
|
|
'test()' => 'testfunc($1,$2)', |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
|
|
$object = new \Aimeos\Base\Criteria\Expression\Sort\SQL( $this->conn, '-', 'test' ); |
|
71
|
|
|
$this->assertEquals( 'test DESC', $object->toSource( $types ) ); |
|
72
|
|
|
|
|
73
|
|
|
$object = new \Aimeos\Base\Criteria\Expression\Sort\SQL( $this->conn, '+', 'test(1,2.1)' ); |
|
74
|
|
|
$this->assertEquals( 'testfunc(1,2.1) ASC', $object->toSource( $types, $translations ) ); |
|
75
|
|
|
|
|
76
|
|
|
$object = new \Aimeos\Base\Criteria\Expression\Sort\SQL( $this->conn, '-', 'test("a",2)' ); |
|
77
|
|
|
$this->assertEquals( 'testfunc(\'a\',2) DESC', $object->toSource( $types, $translations ) ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
public function testToArray() |
|
82
|
|
|
{ |
|
83
|
|
|
$dbm = \TestHelperMw::getDBManager(); |
|
84
|
|
|
$conn = $dbm->acquire(); |
|
85
|
|
|
$dbm->release( $conn ); |
|
86
|
|
|
|
|
87
|
|
|
$object = new \Aimeos\Base\Criteria\Expression\Sort\SQL( $conn, '+', 'stringvar' ); |
|
88
|
|
|
|
|
89
|
|
|
$this->assertEquals( ['stringvar' => '+'], $object->__toArray() ); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
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