2009-05-28 06:04:51 +04:00
|
|
|
<?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 MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
|
2009-05-28 06:04:51 +04:00
|
|
|
{
|
|
|
|
public function testListSequences()
|
|
|
|
{
|
2009-05-30 06:27:50 +04:00
|
|
|
$this->createTestTable('list_sequences_test');
|
2009-05-28 06:04:51 +04:00
|
|
|
$sequences = $this->_sm->listSequences();
|
2009-05-29 01:34:35 +04:00
|
|
|
$this->assertEquals(true, in_array('list_sequences_test', $sequences));
|
2009-05-28 06:04:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testListTableConstraints()
|
|
|
|
{
|
2009-05-30 06:27:50 +04:00
|
|
|
$this->createTestTable('list_table_constraints_test');
|
2009-05-28 06:04:51 +04:00
|
|
|
$tableConstraints = $this->_sm->listTableConstraints('list_table_constraints_test');
|
2009-05-29 01:34:35 +04:00
|
|
|
$this->assertEquals(array('PRIMARY'), $tableConstraints);
|
2009-05-28 06:04:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testListUsers()
|
|
|
|
{
|
|
|
|
$users = $this->_sm->listUsers();
|
2009-05-29 01:34:35 +04:00
|
|
|
$this->assertEquals(true, is_array($users));
|
2009-05-28 06:04:51 +04:00
|
|
|
$params = $this->_conn->getParams();
|
|
|
|
$testUser = $params['user'];
|
|
|
|
$found = false;
|
|
|
|
foreach ($users as $user) {
|
|
|
|
if ($user['user'] == $testUser) {
|
|
|
|
$found = true;
|
|
|
|
}
|
|
|
|
}
|
2009-05-29 01:34:35 +04:00
|
|
|
$this->assertEquals(true, $found);
|
2009-05-28 06:04:51 +04:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:56:05 +03:00
|
|
|
protected function getCreateExampleViewSql()
|
2009-05-28 06:04:51 +04:00
|
|
|
{
|
2009-11-03 19:56:05 +03:00
|
|
|
return 'SELECT * from mysql.user';
|
2009-05-28 06:04:51 +04:00
|
|
|
}
|
2009-11-03 19:56:05 +03:00
|
|
|
|
2009-05-29 01:34:35 +04:00
|
|
|
public function testListTableForeignKeys()
|
|
|
|
{
|
2009-05-30 06:27:50 +04:00
|
|
|
$data['options'] = array('type' => 'innodb');
|
|
|
|
$this->createTestTable('list_table_foreign_keys_test1', $data);
|
|
|
|
$this->createTestTable('list_table_foreign_keys_test2', $data);
|
2009-05-30 14:16:54 +04:00
|
|
|
|
2009-05-29 01:34:35 +04:00
|
|
|
$definition = array(
|
|
|
|
'name' => 'testing',
|
2009-05-30 06:27:50 +04:00
|
|
|
'local' => 'foreign_key_test',
|
2009-05-29 01:34:35 +04:00
|
|
|
'foreign' => 'id',
|
2009-05-30 06:27:50 +04:00
|
|
|
'foreignTable' => 'list_table_foreign_keys_test2'
|
2009-05-29 01:34:35 +04:00
|
|
|
);
|
2009-05-30 06:27:50 +04:00
|
|
|
$this->_sm->createForeignKey('list_table_foreign_keys_test1', $definition);
|
2009-05-30 14:16:54 +04:00
|
|
|
|
2009-05-30 06:27:50 +04:00
|
|
|
$tableForeignKeys = $this->_sm->listTableForeignKeys('list_table_foreign_keys_test1');
|
2009-05-29 01:34:35 +04:00
|
|
|
$this->assertEquals(1, count($tableForeignKeys));
|
2009-05-30 06:27:50 +04:00
|
|
|
$this->assertEquals('list_table_foreign_keys_test2', $tableForeignKeys[0]['table']);
|
|
|
|
$this->assertEquals('foreign_key_test', $tableForeignKeys[0]['local']);
|
2009-05-29 01:34:35 +04:00
|
|
|
$this->assertEquals('id', $tableForeignKeys[0]['foreign']);
|
|
|
|
}
|
2009-05-28 06:04:51 +04:00
|
|
|
}
|