2013-03-18 11:10:14 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Query;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Query\SqlWalker;
|
|
|
|
use Doctrine\ORM\Query;
|
|
|
|
use Doctrine\Tests\OrmTestCase;
|
|
|
|
use Doctrine\ORM\Query\ParserResult;
|
|
|
|
|
2014-10-19 17:10:39 +02:00
|
|
|
/**
|
|
|
|
* Tests for {@see \Doctrine\ORM\Query\SqlWalker}
|
|
|
|
*
|
|
|
|
* @covers \Doctrine\ORM\Query\SqlWalker
|
|
|
|
*/
|
2013-03-18 11:10:14 +01:00
|
|
|
class SqlWalkerTest extends OrmTestCase
|
|
|
|
{
|
2014-10-19 17:21:13 +02:00
|
|
|
/**
|
|
|
|
* @var SqlWalker
|
|
|
|
*/
|
|
|
|
private $sqlWalker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
$this->sqlWalker = new SqlWalker(new Query($this->_getTestEntityManager()), new ParserResult(), array());
|
|
|
|
}
|
|
|
|
|
2014-10-19 17:16:07 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider getColumnNamesAndSqlAliases
|
|
|
|
*/
|
|
|
|
public function testGetSQLTableAlias($tableName, $expectedAlias)
|
2013-03-18 11:10:14 +01:00
|
|
|
{
|
2014-10-19 17:21:13 +02:00
|
|
|
$this->assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName));
|
2014-10-19 17:16:07 +02:00
|
|
|
}
|
|
|
|
|
2014-10-19 17:18:30 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider getColumnNamesAndSqlAliases
|
|
|
|
*/
|
|
|
|
public function testGetSQLTableAliasIsSameForMultipleCalls($tableName)
|
|
|
|
{
|
2014-10-19 17:21:13 +02:00
|
|
|
$this->assertSame(
|
|
|
|
$this->sqlWalker->getSQLTableAlias($tableName),
|
|
|
|
$this->sqlWalker->getSQLTableAlias($tableName)
|
|
|
|
);
|
2014-10-19 17:18:30 +02:00
|
|
|
}
|
|
|
|
|
2014-10-19 17:16:07 +02:00
|
|
|
/**
|
|
|
|
* @private data provider
|
|
|
|
*
|
|
|
|
* @return string[][]
|
|
|
|
*/
|
|
|
|
public function getColumnNamesAndSqlAliases()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('aaaaa', 'a0_'),
|
|
|
|
array('table', 't0_'),
|
|
|
|
array('çtable', 't0_'),
|
|
|
|
);
|
2013-03-18 11:10:14 +01:00
|
|
|
}
|
2014-10-19 17:09:41 +02:00
|
|
|
}
|