OCI8ConnectionTest.php 1.41 KB
Newer Older
1 2 3 4 5
<?php

namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;

use Doctrine\DBAL\Driver\OCI8\Driver;
6
use Doctrine\DBAL\Schema\Table;
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
use Doctrine\Tests\DbalFunctionalTestCase;

class OCI8ConnectionTest extends DbalFunctionalTestCase
{
    /**
     * @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection
     */
    protected $driverConnection;

    protected function setUp()
    {
        if (! extension_loaded('oci8')) {
            $this->markTestSkipped('oci8 is not installed.');
        }

        parent::setUp();

        if (! $this->_conn->getDriver() instanceof Driver) {
            $this->markTestSkipped('oci8 only test.');
        }

        $this->driverConnection = $this->_conn->getWrappedConnection();
    }

    /**
     * @group DBAL-2595
     */
    public function testLastInsertIdAcceptsFqn()
    {
36 37 38 39 40 41 42 43 44
        $platform = $this->_conn->getDatabasePlatform();
        $schemaManager = $this->_conn->getSchemaManager();

        $table = new Table('DBAL2595');
        $table->addColumn('id', 'integer', array('autoincrement' => true));
        $table->addColumn('foo', 'integer');

        $schemaManager->dropAndCreateTable($table);

45 46 47
        $this->_conn->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');

        $schema = $this->_conn->getDatabase();
48
        $sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id');
49

50
        self::assertSame(1, $this->driverConnection->lastInsertId($sequence));
51 52
    }
}