1
0
mirror of synced 2024-12-14 15:16:04 +03:00
doctrine2/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php

142 lines
4.6 KiB
PHP
Raw Normal View History

<?php
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
2009-06-15 22:25:47 +04:00
class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListDatabases()
{
$this->_sm->dropAndCreateDatabase('test_oracle_create_database');
$databases = $this->_sm->listDatabases();
$this->assertEquals(true, in_array('TEST_ORACLE_CREATE_DATABASE', $databases));
}
public function testListFunctions()
{
$functions = $this->_sm->listFunctions();
$this->assertEquals(array(), $functions);
}
2009-06-15 22:25:47 +04:00
/**
* @expectedException \Exception
*/
public function testListTriggers()
{
2009-06-15 22:25:47 +04:00
$this->_sm->listTriggers();
}
public function testListSequences()
{
$this->createTestTable('list_sequences_test');
$sequences = $this->_sm->listSequences();
$this->assertEquals(true, in_array('LIST_SEQUENCES_TEST_SEQ', $sequences));
}
public function testListTableConstraints()
{
$this->createTestTable('test_constraints');
$tableConstraints = $this->_sm->listTableConstraints('test_constraints');
$this->assertEquals(2, count($tableConstraints));
}
public function testListTableColumns()
{
$this->createTestTable('list_tables_test');
$columns = $this->_sm->listTableColumns('list_tables_test');
$this->assertEquals('ID', $columns[1]['name']);
$this->assertEquals('Doctrine\DBAL\Types\IntegerType', get_class($columns[1]['type']));
$this->assertEquals(22, $columns[1]['length']);
$this->assertEquals(false, $columns[1]['unsigned']);
$this->assertEquals(false, $columns[1]['fixed']);
$this->assertEquals(true, $columns[1]['notnull']);
$this->assertEquals(null, $columns[1]['default']);
$this->assertEquals('TEST', $columns[2]['name']);
$this->assertEquals('Doctrine\DBAL\Types\StringType', get_class($columns[2]['type']));
$this->assertEquals(255, $columns[2]['length']);
$this->assertEquals(false, $columns[2]['unsigned']);
$this->assertEquals(false, $columns[2]['fixed']);
$this->assertEquals(false, $columns[2]['notnull']);
$this->assertEquals(null, $columns[2]['default']);
}
public function testListTableIndexes()
{
$data['options'] = array(
'indexes' => array(
'test_index_name' => array(
'fields' => array(
'test' => array()
),
'type' => 'unique'
)
)
);
$this->createTestTable('list_table_indexes_test', $data);
$tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_test');
$this->assertEquals(true, is_string($tableIndexes[0]['name']));
$this->assertEquals(true, $tableIndexes[0]['unique']);
}
public function testListTables()
{
$this->createTestTable('list_tables_test');
$tables = $this->_sm->listTables();
$this->assertEquals(true, in_array('LIST_TABLES_TEST', $tables));
}
public function testListUsers()
{
$users = $this->_sm->listUsers();
$this->assertEquals(true, is_array($users));
$params = $this->_conn->getParams();
$testUser = strtoupper($params['user']);
$found = false;
foreach ($users as $user) {
if ($user['user'] == $testUser) {
$found = true;
}
}
$this->assertEquals(true, $found);
}
public function testListViews()
{
$this->_sm->dropAndCreateView('test_create_view', 'SELECT * FROM sys.user_tables');
$views = $this->_sm->listViews();
$view = end($views);
$this->assertEquals('TEST_CREATE_VIEW', $view['name']);
}
public function testListTableForeignKeys()
{
return $this->assertUnsupportedMethod('listTableForeignKeys');
}
public function testRenameTable()
{
$this->_sm->tryDropTable('list_tables_test');
$this->_sm->tryDropTable('list_tables_test_new_name');
$this->createTestTable('list_tables_test');
$this->_sm->renameTable('list_tables_test', 'list_tables_test_new_name');
$tables = $this->_sm->listTables();
$this->assertEquals(true, in_array('LIST_TABLES_TEST_NEW_NAME', $tables));
}
public function testDropAndCreate()
{
$this->_sm->dropAndCreateView('testing_a_new_view', 'SELECT * FROM sys.user_tables');
$this->_sm->dropAndCreateView('testing_a_new_view', 'SELECT * FROM sys.user_tables');
}
}