2009-11-06 17:03:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Query;
|
|
|
|
|
2016-06-18 13:01:59 +02:00
|
|
|
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
|
2009-11-06 17:03:59 +00:00
|
|
|
use Doctrine\ORM\Query\ParserResult;
|
2016-12-08 18:01:04 +01:00
|
|
|
use Doctrine\ORM\Query\ResultSetMapping;
|
2017-03-31 17:20:10 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2009-11-06 17:03:59 +00:00
|
|
|
|
2017-03-31 17:20:10 +01:00
|
|
|
class ParserResultTest extends TestCase
|
2009-11-06 17:03:59 +00:00
|
|
|
{
|
2011-01-13 21:16:08 +01:00
|
|
|
public $parserResult;
|
2009-11-06 17:03:59 +00:00
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
2011-01-13 21:16:08 +01:00
|
|
|
$this->parserResult = new ParserResult();
|
2009-11-06 17:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetRsm()
|
|
|
|
{
|
2016-12-08 18:01:04 +01:00
|
|
|
$this->assertInstanceOf(ResultSetMapping::class, $this->parserResult->getResultSetMapping());
|
2009-11-06 17:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetGetSqlExecutor()
|
|
|
|
{
|
2011-01-13 21:16:08 +01:00
|
|
|
$this->assertNull($this->parserResult->getSqlExecutor());
|
2009-11-06 17:03:59 +00:00
|
|
|
|
2016-12-07 23:33:41 +01:00
|
|
|
$executor = $this->getMockBuilder(AbstractSqlExecutor::class)->setMethods(['execute'])->getMock();
|
2011-01-13 21:16:08 +01:00
|
|
|
$this->parserResult->setSqlExecutor($executor);
|
|
|
|
$this->assertSame($executor, $this->parserResult->getSqlExecutor());
|
2009-11-06 17:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetSqlParameterPosition()
|
|
|
|
{
|
2011-01-13 21:16:08 +01:00
|
|
|
$this->parserResult->addParameterMapping(1, 1);
|
|
|
|
$this->parserResult->addParameterMapping(1, 2);
|
2016-12-07 23:33:41 +01:00
|
|
|
$this->assertEquals([1, 2], $this->parserResult->getSqlParameterPositions(1));
|
2009-11-06 17:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetParameterMappings()
|
|
|
|
{
|
2011-02-19 19:50:58 -02:00
|
|
|
$this->assertInternalType('array', $this->parserResult->getParameterMappings());
|
2009-11-06 17:03:59 +00:00
|
|
|
|
2011-01-13 21:16:08 +01:00
|
|
|
$this->parserResult->addParameterMapping(1, 1);
|
|
|
|
$this->parserResult->addParameterMapping(1, 2);
|
2016-12-07 23:33:41 +01:00
|
|
|
$this->assertEquals([1 => [1, 2]], $this->parserResult->getParameterMappings());
|
2009-11-06 17:03:59 +00:00
|
|
|
}
|
2016-12-07 23:33:41 +01:00
|
|
|
}
|