1
0
mirror of synced 2025-01-17 22:11:41 +03:00

updated query limit test case, added new tests for mysql export driver

This commit is contained in:
zYne 2006-11-22 00:18:33 +00:00
parent c134ad16cb
commit d97c78dad8
2 changed files with 63 additions and 4 deletions

View File

@ -1,7 +1,60 @@
<?php
class Doctrine_Export_Mysql_TestCase {
public function testCreateDatabase() {
class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() {
parent::__construct('mysql');
}
public function testCreateDatabaseExecutesSql() {
$this->export->createDatabase('db');
$this->assertEqual($this->adapter->pop(), 'CREATE DATABASE db');
}
public function testDropDatabaseExecutesSql() {
$this->export->dropDatabase('db');
$this->assertEqual($this->adapter->pop(), 'DROP DATABASE db');
}
public function testAlterTableThrowsExceptionWithoutValidTableName() {
try {
$this->export->alterTable(0,0,array());
$this->fail();
} catch(Doctrine_Export_Exception $e) {
$this->pass();
}
}
public function testCreateTableThrowsExceptionWithoutValidTableName() {
try {
$this->export->createTable(0,array(),array());
$this->fail();
} catch(Doctrine_Export_Exception $e) {
$this->pass();
}
}
public function testCreateTableThrowsExceptionWithEmptyFieldsArray() {
try {
$this->export->createTable('sometable',array(),array());
$this->fail();
} catch(Doctrine_Export_Exception $e) {
$this->pass();
}
}
public function testCreateIndexExecutesSql() {
$this->export->createIndex('sometable', 'relevancy', array('fields' => array('title' => array(), 'content' => array())));
$this->assertEqual($this->adapter->pop(), 'CREATE INDEX relevancy ON sometable (title, content)');
}
public function testDropIndexExecutesSql() {
$this->export->dropIndex('sometable', 'relevancy');
$this->assertEqual($this->adapter->pop(), 'DROP INDEX relevancy ON sometable');
}
public function testDropTableExecutesSql() {
$this->export->dropTable('sometable');
$this->assertEqual($this->adapter->pop(), 'DROP TABLE sometable');
}
}
?>

View File

@ -217,6 +217,11 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this->manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_RECORDS);
}
public function testLimitWithManyToManyAndColumnAggregationInheritance() {
$q = new Doctrine_Query();
$q->from('User u, u.Group g')->where('g.id > 1')->orderby('u.name DESC')->limit(10);
}
public function testLimitWithNormalManyToMany() {
$coll = new Doctrine_Collection($this->connection->getTable("Photo"));
$tag = new Tag();
@ -237,7 +242,8 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$photos = $q->execute(array(1));
$this->assertEqual($photos->count(), 3);
$this->assertEqual($q->getQuery(),
"SELECT p.id AS p__id, p.name AS p__name FROM photo p LEFT JOIN phototag ON p.id = phototag.photo_id LEFT JOIN tag t ON t.id = phototag.tag_id WHERE p.id IN (SELECT DISTINCT p2.id FROM photo p2 LEFT JOIN phototag ON p2.id = phototag.photo_id LEFT JOIN tag t2 ON t2.id = phototag.tag_id WHERE t2.id = ? ORDER BY p2.id DESC LIMIT 100) AND t2.id = ? ORDER BY p.id DESC");
"SELECT p.id AS p__id, p.name AS p__name FROM photo p LEFT JOIN phototag ON p.id = phototag.photo_id LEFT JOIN tag t ON t.id = phototag.tag_id WHERE p.id IN (SELECT DISTINCT p2.id FROM photo p2 LEFT JOIN phototag ON p2.id = phototag.photo_id LEFT JOIN tag t2 ON t2.id = phototag.tag_id WHERE t2.id = ? ORDER BY p2.id DESC LIMIT 100) AND t.id = ? ORDER BY p.id DESC");
}
}