Commit bd46df21 authored by zYne's avatar zYne

--no commit message

--no commit message
parent af0d91fe
......@@ -57,7 +57,11 @@ class AdapterMock implements Doctrine_Adapter_Interface {
return 0;
}
public function lastInsertId(){ }
public function lastInsertId()
{
$this->queries[] = 'LAST_INSERT_ID()';
return 1;
}
public function beginTransaction(){
$this->queries[] = 'BEGIN TRANSACTION';
}
......@@ -85,6 +89,9 @@ class AdapterStatementMock {
public function execute() {
return true;
}
public function fetchColumn($colnum) {
return 0;
}
}
class Doctrine_Driver_UnitTestCase extends UnitTestCase {
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Sequence_Db2_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Db2_TestCase extends Doctrine_UnitTestCase
{
}
......@@ -30,7 +30,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Firebird_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Firebird_TestCase extends Doctrine_UnitTestCase {
}
......@@ -30,7 +30,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Informix_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Informix_TestCase extends Doctrine_UnitTestCase {
}
......@@ -30,7 +30,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Mssql_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Mssql_TestCase extends Doctrine_UnitTestCase {
}
......@@ -30,7 +30,26 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Mysql_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Mysql_TestCase extends Doctrine_UnitTestCase {
public function testCurrIdExecutesSql() {
$this->sequence->currId('user');
$this->assertEqual($this->adapter->pop(), 'SELECT MAX(id) FROM user_seq');
}
public function testNextIdExecutesSql() {
$id = $this->sequence->nextId('user');
$this->assertEqual($id, 1);
$this->assertEqual($this->adapter->pop(), 'DELETE FROM user_seq WHERE id < 1');
$this->assertEqual($this->adapter->pop(), 'LAST_INSERT_ID()');
$this->assertEqual($this->adapter->pop(), 'INSERT INTO user_seq (id) VALUES (NULL)');
}
public function testLastInsertIdCallsPdoLevelEquivalent() {
$id = $this->sequence->lastInsertId('user');
$this->assertEqual($id, 1);
$this->assertEqual($this->adapter->pop(), 'LAST_INSERT_ID()');
}
}
......@@ -30,7 +30,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Oracle_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Oracle_TestCase extends Doctrine_UnitTestCase {
}
......@@ -30,7 +30,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase {
}
......@@ -30,7 +30,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence_Sqlite_TestCase extends Doctrine_UnitTestCase
{
class Doctrine_Sequence_Sqlite_TestCase extends Doctrine_UnitTestCase {
}
......@@ -114,6 +114,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this->transaction = $this->connection->transaction;
$this->dataDict = $this->connection->dataDict;
$this->expr = $this->connection->expression;
$this->sequence = $this->connection->sequence;
}
$this->unitOfWork = $this->connection->unitOfWork;
$this->connection->setListener(new Doctrine_EventListener());
......
......@@ -54,10 +54,10 @@ print '<pre>';
$test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Sequence_Mysql_TestCase());
// DATABASE ABSTRACTION tests
/**
// Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
......@@ -87,6 +87,16 @@ $test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
$test->addTestCase(new Doctrine_DataDict_Oracle_TestCase());
$test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
// Sequence module (not yet fully tested)
$test->addTestCase(new Doctrine_Sequence_TestCase());
$test->addTestCase(new Doctrine_Sequence_Firebird_TestCase());
$test->addTestCase(new Doctrine_Sequence_Informix_TestCase());
$test->addTestCase(new Doctrine_Sequence_Mssql_TestCase());
$test->addTestCase(new Doctrine_Sequence_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Sequence_Oracle_TestCase());
$test->addTestCase(new Doctrine_Sequence_Sqlite_TestCase());
// Export module (not yet fully tested)
$test->addTestCase(new Doctrine_Export_TestCase());
$test->addTestCase(new Doctrine_Export_Reporter_TestCase());
......@@ -136,6 +146,9 @@ $test->addTestCase(new Doctrine_Collection_TestCase());
$test->addTestCase(new Doctrine_Relation_TestCase());
$test->addTestCase(new Doctrine_Relation_Access_TestCase());
$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
$test->addTestCase(new Doctrine_Relation_OneToOne_TestCase());
$test->addTestCase(new Doctrine_TreeStructure_TestCase());
// Datatypes
......@@ -193,9 +206,7 @@ $test->addTestCase(new Doctrine_Query_Expression_TestCase());
$test->addTestCase(new Doctrine_Query_Having_TestCase());
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
$test->addTestCase(new Doctrine_TreeStructure_TestCase());
*/
// Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment