mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-06 10:24:17 +00:00
clean up for the tests
This mostly corrects file and class names for PSR-2. Function names have not been adjusted yet
This commit is contained in:
70
_test/QueryBuilderWhereTest.php
Normal file
70
_test/QueryBuilderWhereTest.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\struct\test;
|
||||
|
||||
use dokuwiki\plugin\struct\meta\QueryBuilder;
|
||||
use dokuwiki\plugin\struct\meta\QueryBuilderWhere;
|
||||
|
||||
/**
|
||||
* @group plugin_struct
|
||||
* @group plugins
|
||||
*/
|
||||
class QueryBuilderWhereTest extends StructTest
|
||||
{
|
||||
|
||||
public function test_sql()
|
||||
{
|
||||
$QB = new QueryBuilder();
|
||||
$where = new QueryBuilderWhere($QB);
|
||||
|
||||
$where->whereAnd('foo = foo');
|
||||
$this->assertEquals(
|
||||
$this->cleanWS('(foo = foo)'),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
|
||||
$where->whereAnd('bar = bar');
|
||||
$this->assertEquals(
|
||||
$this->cleanWS('(foo = foo AND bar = bar)'),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
|
||||
$sub = $where->whereSubAnd();
|
||||
$this->assertEquals(
|
||||
$this->cleanWS('(foo = foo AND bar = bar)'),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
|
||||
$sub->whereAnd('zab = zab');
|
||||
$this->assertEquals(
|
||||
$this->cleanWS('(foo = foo AND bar = bar AND (zab = zab))'),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
|
||||
$sub->whereOr('fab = fab');
|
||||
$this->assertEquals(
|
||||
$this->cleanWS('(foo = foo AND bar = bar AND (zab = zab OR fab = fab))'),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
}
|
||||
|
||||
public function test_orsql()
|
||||
{
|
||||
$QB = new QueryBuilder();
|
||||
$where = new QueryBuilderWhere($QB);
|
||||
|
||||
$where->whereAnd("foo = ''");
|
||||
$this->assertEquals(
|
||||
$this->cleanWS("(foo = '')"),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
|
||||
$sub = $where->whereSubOr();
|
||||
$sub->whereAnd('bar = bar');
|
||||
$sub->whereAnd('baz = baz');
|
||||
$this->assertEquals(
|
||||
$this->cleanWS("(foo = '' OR (bar = bar AND baz = baz))"),
|
||||
$this->cleanWS($where->toSQL())
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user