ParserResultTest.php 1.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php

namespace Doctrine\Tests\ORM\Query;

use Doctrine\ORM\Query\ParserResult;

class ParserResultTest extends \PHPUnit_Framework_TestCase
{
    public $result;

    public function setUp()
    {
        $this->result = new ParserResult();
    }

    public function testGetRsm()
    {
        $this->assertType(
            'Doctrine\ORM\Query\ResultSetMapping',
            $this->result->getResultSetMapping()
        );
    }

    public function testSetGetSqlExecutor()
    {
        $this->assertNull($this->result->getSqlExecutor());

        $executor = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute'));
        $this->result->setSqlExecutor($executor);
        $this->assertSame($executor, $this->result->getSqlExecutor());
    }

    public function testGetSqlParameterPosition()
    {
        $this->result->addParameterMapping(1, 1);
        $this->result->addParameterMapping(1, 2);
        $this->assertEquals(array(1, 2), $this->result->getSqlParameterPositions(1));
    }

    public function testGetParameterMappings()
    {
        $this->assertType('array', $this->result->getParameterMappings());

        $this->result->addParameterMapping(1, 1);
        $this->result->addParameterMapping(1, 2);
        $this->assertEquals(array(1 => array(1, 2)), $this->result->getParameterMappings());
    }
}