mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-10 01:35:13 +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:
79
_test/QueryBuilderSelectTest.php
Normal file
79
_test/QueryBuilderSelectTest.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\struct\test;
|
||||
|
||||
use dokuwiki\plugin\struct\meta\QueryBuilder;
|
||||
use dokuwiki\plugin\struct\meta\StructException;
|
||||
|
||||
/**
|
||||
* @group plugin_struct
|
||||
* @group plugins
|
||||
*/
|
||||
class QueryBuilderSelectTest extends StructTest
|
||||
{
|
||||
|
||||
/**
|
||||
* @noinspection SqlDialectInspection
|
||||
* @noinspection SqlNoDataSourceInspection
|
||||
*/
|
||||
public function test_simple_select()
|
||||
{
|
||||
$qb = new QueryBuilder();
|
||||
|
||||
$qb->addTable('first', 'T1');
|
||||
$qb->addSelectColumn('T1', 'colbar', 'asAlias');
|
||||
|
||||
|
||||
$expectedSQL = '
|
||||
SELECT T1.colbar AS asAlias FROM first AS T1 WHERE
|
||||
';
|
||||
|
||||
list($actual_sql, $actual_opts) = $qb->getSQL();
|
||||
$this->assertEquals($this->cleanWS($expectedSQL), $this->cleanWS($actual_sql));
|
||||
$this->assertEquals(array(), $actual_opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection SqlDialectInspection
|
||||
* @noinspection SqlNoDataSourceInspection
|
||||
*/
|
||||
public function test_overwrite_selects()
|
||||
{
|
||||
$qb = new QueryBuilder();
|
||||
|
||||
$qb->addTable('first', 'T1');
|
||||
$qb->addSelectColumn('T1', 'colbar_original', 'colAlias');
|
||||
$qb->addSelectColumn('T1', 'colfoo_overwritten', 'colAlias');
|
||||
|
||||
$expectedSQL = 'SELECT T1.colfoo_overwritten AS colAlias FROM first AS T1 WHERE';
|
||||
list($actual_sql, $actual_opts) = $qb->getSQL();
|
||||
$this->assertEquals($this->cleanWS($expectedSQL), $this->cleanWS($actual_sql));
|
||||
$this->assertEquals(array(), $actual_opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection SqlDialectInspection
|
||||
* @noinspection SqlNoDataSourceInspection
|
||||
*/
|
||||
public function test_arbitrary_selects()
|
||||
{
|
||||
$qb = new QueryBuilder();
|
||||
|
||||
$qb->addSelectStatement('a.b', 'C');
|
||||
|
||||
$expectedSQL = 'SELECT a.b AS C FROM WHERE';
|
||||
list($actual_sql, $actual_opts) = $qb->getSQL();
|
||||
$this->assertEquals($this->cleanWS($expectedSQL), $this->cleanWS($actual_sql));
|
||||
$this->assertEquals(array(), $actual_opts);
|
||||
}
|
||||
|
||||
public function test_missing_alias()
|
||||
{
|
||||
$this->expectException(StructException::class);
|
||||
$qb = new QueryBuilder();
|
||||
|
||||
$qb->addTable('first', 'T1');
|
||||
$qb->addSelectColumn('WrongAlias', 'colbar', 'colAlias');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user