Commit dcc3bd8c authored by zYne's avatar zYne

--no commit message

--no commit message
parent b0369879
...@@ -29,10 +29,48 @@ ...@@ -29,10 +29,48 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_AuditLog class Doctrine_AuditLog
{ {
public function audit(Doctrine_Table $table) public function audit()
{ {
}
public function deleteTriggerSql(Doctrine_Table $table)
{
$conn = $table->getConnection();
$columnNames = $table->getColumnNames();
$oldColumns = array_map(array($this, 'formatOld'), $columnNames);
$sql = 'CREATE TRIGGER '
. $conn->quoteIdentifier($table->getTableName()) . '_ddt' . ' DELETE ON '
. $conn->quoteIdentifier($table->getTableName())
. ' BEGIN'
. ' INSERT INTO ' . $table->getTableName() . '_dvt ('
. implode(', ', array_map(array($conn, 'quoteIdentifier'), $columnNames))
. ') VALUES ('
. implode(', ', array_map(array($conn, 'quoteIdentifier'), $oldColumns))
. ');'
. ' END;';
return $sql;
}
public function updateTriggerSql(Doctrine_Table $table)
{
$conn = $table->getConnection();
$columnNames = $table->getColumnNames();
$oldColumns = array_map(array($this, 'formatOld'), $columnNames);
$sql = 'CREATE TRIGGER '
. $conn->quoteIdentifier($table->getTableName()) . '_dut' . ' UPDATE ON '
. $conn->quoteIdentifier($table->getTableName())
. ' BEGIN'
. ' INSERT INTO ' . $table->getTableName() . '_dvt ('
. implode(', ', array_map(array($conn, 'quoteIdentifier'), $columnNames))
. ') VALUES ('
. implode(', ', array_map(array($conn, 'quoteIdentifier'), $oldColumns))
. ');'
. ' END;';
return $sql;
}
public function formatOld($column)
{
return 'old.' . $column;
} }
} }
<?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_AuditLog_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_AuditLog_TestCase extends Doctrine_UnitTestCase
{
public function prepareData()
{ }
public function prepareTables()
{ }
public function testUpdateTriggerSqlReturnsProperQuery()
{
$table = $this->conn->getTable('User');
$auditLog = new Doctrine_AuditLog();
$sql = $auditLog->updateTriggerSql($table);
$this->assertEqual($sql, 'CREATE TRIGGER entity_dut UPDATE ON entity BEGIN INSERT INTO entity_dvt (id, name, loginname, password, type, created, updated, email_id) VALUES (old.id, old.name, old.loginname, old.password, old.type, old.created, old.updated, old.email_id); END;');
}
public function testDeleteTriggerSqlReturnsProperQuery()
{
$table = $this->conn->getTable('User');
$auditLog = new Doctrine_AuditLog();
$sql = $auditLog->deleteTriggerSql($table);
$this->assertEqual($sql, 'CREATE TRIGGER entity_ddt DELETE ON entity BEGIN INSERT INTO entity_dvt (id, name, loginname, password, type, created, updated, email_id) VALUES (old.id, old.name, old.loginname, old.password, old.type, old.created, old.updated, old.email_id); END;');
}
}
...@@ -56,9 +56,9 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase ...@@ -56,9 +56,9 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q->select('c.alias1, c.alias2')->from('ColumnAliasTest c'); $q->select('c.alias1, c.alias2')->from('ColumnAliasTest c');
$coll = $q->execute(); $coll = $q->execute();
$this->assertEqual($coll[0]->alias1, 'someone'); $this->assertEqual($coll[0]->alias1, 'someone');
$this->assertEqual($coll[0]->alias2, 187); $this->assertEqual($coll[0]->alias2, 187);
} }
...@@ -71,10 +71,10 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase ...@@ -71,10 +71,10 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
->where('c.alias1 = ?'); ->where('c.alias1 = ?');
$coll = $q->execute(array('someone')); $coll = $q->execute(array('someone'));
$this->assertEqual($coll[0]->alias1, 'someone'); $this->assertEqual($coll[0]->alias1, 'someone');
$this->assertEqual($coll[0]->alias2, 187); $this->assertEqual($coll[0]->alias2, 187);
} }
public function testAliasesAreSupportedForDqlAggregateFunctions() public function testAliasesAreSupportedForDqlAggregateFunctions()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -83,7 +83,7 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase ...@@ -83,7 +83,7 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
->from('ColumnAliasTest c'); ->from('ColumnAliasTest c');
$coll = $q->execute(); $coll = $q->execute();
$this->assertEqual($coll[0]->max, 'someone'); $this->assertEqual($coll[0]->max, 'someone');
} }
public function testAliasesAreSupportedForDqlHavingPart() public function testAliasesAreSupportedForDqlHavingPart()
......
...@@ -99,7 +99,7 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase { ...@@ -99,7 +99,7 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase {
public function testQueryWithOrdering2() { public function testQueryWithOrdering2() {
$q = new Doctrine_Query($this->connection); $q = new Doctrine_Query($this->connection);
print '<pre>';
$categories = $q->select('c.*, b.*') $categories = $q->select('c.*, b.*')
->from('CategoryWithPosition c') ->from('CategoryWithPosition c')
->leftJoin('c.Boards b') ->leftJoin('c.Boards b')
...@@ -160,12 +160,12 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase { ...@@ -160,12 +160,12 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase {
case 'First': case 'First':
// The first category should have 3 boards, right? // The first category should have 3 boards, right?
// It has only 1! The other two slipped to the 2nd category! // It has only 1! The other two slipped to the 2nd category!
print $category->Boards->count();
$this->assertEqual(3, $category->Boards->count()); $this->assertEqual(3, $category->Boards->count());
break; break;
case 'Second': case 'Second':
// The second category should have 1 board, but it got 3 now // The second category should have 1 board, but it got 3 now
print $category->Boards->count();
$this->assertEqual(1, $category->Boards->count()); $this->assertEqual(1, $category->Boards->count());
break; break;
case 'Third': case 'Third':
......
...@@ -102,12 +102,9 @@ class Doctrine_Query_MultiJoin2_TestCase extends Doctrine_UnitTestCase ...@@ -102,12 +102,9 @@ class Doctrine_Query_MultiJoin2_TestCase extends Doctrine_UnitTestCase
->where('c.parentCategoryId = 0') ->where('c.parentCategoryId = 0')
->orderBy('c.position ASC, subCats.position ASC, b.position ASC') ->orderBy('c.position ASC, subCats.position ASC, b.position ASC')
->execute(array(), Doctrine::FETCH_ARRAY); ->execute(array(), Doctrine::FETCH_ARRAY);
//echo "<pre>";
//var_dump($categories);
//echo "</pre>";
$this->pass(); $this->pass();
} catch (Doctrine_Exception $e) { } catch (Doctrine_Exception $e) {
$this->fail(); $this->fail();
} }
} }
} }
...@@ -655,8 +655,8 @@ class QueryTest_Category extends Doctrine_Record ...@@ -655,8 +655,8 @@ class QueryTest_Category extends Doctrine_Record
*/ */
public function setUp() public function setUp()
{ {
$this->ownsMany('QueryTest_Category as subCategories','subCategories.parentCategoryId'); $this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId');
$this->hasOne('QueryTest_Category as rootCategory','QueryTest_Category.rootCategoryId'); $this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId');
$this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId'); $this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId');
} }
} }
......
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