Commit fb46481a authored by zYne's avatar zYne

added namespaces for event constants

parent efea8acc
...@@ -325,7 +325,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -325,7 +325,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return false; return false;
} }
$event = new Doctrine_Event($this, Doctrine_Event::CONNECT); $event = new Doctrine_Event($this, Doctrine_Event::CONN_CONNECT);
$this->getListener()->preConnect($event); $this->getListener()->preConnect($event);
...@@ -571,7 +571,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -571,7 +571,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/ */
public function fetchAll($statement, array $params = array()) public function fetchAll($statement, array $params = array())
{ {
return $this->execute($statement, $params)->fetchAll(PDO::FETCH_ASSOC); return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC);
} }
/** /**
* fetchOne * fetchOne
...@@ -594,7 +594,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -594,7 +594,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/ */
public function fetchRow($statement, array $params = array()) public function fetchRow($statement, array $params = array())
{ {
return $this->execute($statement, $params)->fetch(PDO::FETCH_ASSOC); return $this->execute($statement, $params)->fetch(Doctrine::FETCH_ASSOC);
} }
/** /**
* fetchArray * fetchArray
...@@ -605,7 +605,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -605,7 +605,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/ */
public function fetchArray($statement, array $params = array()) public function fetchArray($statement, array $params = array())
{ {
return $this->execute($statement, $params)->fetch(PDO::FETCH_NUM); return $this->execute($statement, $params)->fetch(Doctrine::FETCH_NUM);
} }
/** /**
* fetchColumn * fetchColumn
...@@ -617,7 +617,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -617,7 +617,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/ */
public function fetchColumn($statement, array $params = array(), $colnum = 0) public function fetchColumn($statement, array $params = array(), $colnum = 0)
{ {
return $this->execute($statement, $params)->fetchAll(PDO::FETCH_COLUMN, $colnum); return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_COLUMN, $colnum);
} }
/** /**
* fetchAssoc * fetchAssoc
...@@ -628,7 +628,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -628,7 +628,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/ */
public function fetchAssoc($statement, array $params = array()) public function fetchAssoc($statement, array $params = array())
{ {
return $this->execute($statement, $params)->fetchAll(PDO::FETCH_ASSOC); return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC);
} }
/** /**
* fetchBoth * fetchBoth
...@@ -639,7 +639,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -639,7 +639,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/ */
public function fetchBoth($statement, array $params = array()) public function fetchBoth($statement, array $params = array())
{ {
return $this->execute($statement, $params)->fetchAll(PDO::FETCH_BOTH); return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_BOTH);
} }
/** /**
* query * query
...@@ -672,7 +672,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -672,7 +672,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{ {
$this->connect(); $this->connect();
$event = new Doctrine_Event($this, Doctrine_Event::PREPARE, $statement); $event = new Doctrine_Event($this, Doctrine_Event::CONN_PREPARE, $statement);
$this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event); $this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event);
...@@ -760,7 +760,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -760,7 +760,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$stmt->execute($params); $stmt->execute($params);
return $stmt; return $stmt;
} else { } else {
$event = new Doctrine_Event($this, Doctrine_Event::QUERY, $query, $params); $event = new Doctrine_Event($this, Doctrine_Event::CONN_QUERY, $query, $params);
$this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event); $this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event);
...@@ -795,7 +795,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -795,7 +795,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $stmt->rowCount(); return $stmt->rowCount();
} else { } else {
$event = new Doctrine_Event($this, Doctrine_EVENT::EXEC, $query, $params); $event = new Doctrine_Event($this, Doctrine_Event::CONN_EXEC, $query, $params);
$this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event); $this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event);
......
...@@ -213,7 +213,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf ...@@ -213,7 +213,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
*/ */
public function execute($params = null) public function execute($params = null)
{ {
$event = new Doctrine_Event($this, Doctrine_Event::EXECUTE, $this->_stmt->queryString, $params); $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->_stmt->queryString, $params);
// print $this->_stmt->queryString . print_r($params, true) . "<br>"; // print $this->_stmt->queryString . print_r($params, true) . "<br>";
$this->_conn->getListener()->preExecute($event); $this->_conn->getListener()->preExecute($event);
...@@ -257,7 +257,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf ...@@ -257,7 +257,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
$cursorOrientation = Doctrine::FETCH_ORI_NEXT, $cursorOrientation = Doctrine::FETCH_ORI_NEXT,
$cursorOffset = null) $cursorOffset = null)
{ {
$event = new Doctrine_Db_Event($this, Doctrine_Event::FETCHALL, $this->_stmt->getQuery()); $event = new Doctrine_Db_Event($this, Doctrine_Event::STMT_FETCH, $this->_stmt->getQuery());
$event->fetchMode = $fetchMode; $event->fetchMode = $fetchMode;
$event->cursorOrientation = $cursorOrientation; $event->cursorOrientation = $cursorOrientation;
...@@ -289,7 +289,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf ...@@ -289,7 +289,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
public function fetchAll($fetchMode = Doctrine::FETCH_BOTH, public function fetchAll($fetchMode = Doctrine::FETCH_BOTH,
$columnIndex = null) $columnIndex = null)
{ {
$event = new Doctrine_Db_Event($this, Doctrine_Event::FETCHALL, $this->_stmt->getQuery()); $event = new Doctrine_Db_Event($this, Doctrine_Event::STMT_FETCHALL, $this->_stmt->getQuery());
$event->fetchMode = $fetchMode; $event->fetchMode = $fetchMode;
$event->columnIndex = $columnIndex; $event->columnIndex = $columnIndex;
......
...@@ -139,7 +139,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module ...@@ -139,7 +139,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
*/ */
public function save(Doctrine_Record $record) public function save(Doctrine_Record $record)
{ {
$event = new Doctrine_Event($this, Doctrine_Event::SAVE); $event = new Doctrine_Event($this, Doctrine_Event::RECORD_SAVE);
$record->preSave($event); $record->preSave($event);
...@@ -176,7 +176,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module ...@@ -176,7 +176,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
} }
$this->conn->beginTransaction(); $this->conn->beginTransaction();
$event = new Doctrine_Event($this, Doctrine_Event::DELETE); $event = new Doctrine_Event($this, Doctrine_Event::RECORD_DELETE);
$record->preDelete($event); $record->preDelete($event);
...@@ -326,7 +326,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module ...@@ -326,7 +326,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
*/ */
public function update(Doctrine_Record $record) public function update(Doctrine_Record $record)
{ {
$event = new Doctrine_Event($this, Doctrine_Event::UPDATE); $event = new Doctrine_Event($this, Doctrine_Event::RECORD_UPDATE);
$record->preUpdate($event); $record->preUpdate($event);
...@@ -381,7 +381,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module ...@@ -381,7 +381,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
public function insert(Doctrine_Record $record) public function insert(Doctrine_Record $record)
{ {
// listen the onPreInsert event // listen the onPreInsert event
$event = new Doctrine_Event($this, Doctrine_Event::INSERT); $event = new Doctrine_Event($this, Doctrine_Event::RECORD_INSERT);
$record->preInsert($event); $record->preInsert($event);
......
...@@ -32,23 +32,33 @@ ...@@ -32,23 +32,33 @@
class Doctrine_Event class Doctrine_Event
{ {
/** /**
* EVENT CODE CONSTANTS * CONNECTION EVENT CODES
*/ */
const QUERY = 1; const CONN_QUERY = 1;
const EXEC = 2; const CONN_EXEC = 2;
const EXECUTE = 3; const CONN_PREPARE = 3;
const PREPARE = 4; const CONN_CONNECT = 4;
const BEGIN = 5;
const COMMIT = 6; const STMT_EXECUTE = 10;
const ROLLBACK = 7; const STMT_FETCH = 11;
const CONNECT = 8; const STMT_FETCHALL = 12;
const FETCH = 9;
const FETCHALL = 10; const TX_BEGIN = 31;
const TX_COMMIT = 32;
const TX_ROLLBACK = 33;
const SAVEPOINT_CREATE = 34;
const SAVEPOINT_ROLLBACK = 35;
const SAVEPOINT_COMMIT = 36;
const DELETE = 11; /**
const SAVE = 12; * RECORD EVENT CODES
const UPDATE = 13; */
const INSERT = 14; const RECORD_DELETE = 21;
const RECORD_SAVE = 22;
const RECORD_UPDATE = 23;
const RECORD_INSERT = 24;
const RECORD_SERIALIZE = 25;
const RECORD_UNSERIALIZE = 26;
/** /**
* @var mixed $_invoker the handler which invoked this event * @var mixed $_invoker the handler which invoked this event
*/ */
......
...@@ -275,6 +275,30 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -275,6 +275,30 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
protected function validateOnInsert() protected function validateOnInsert()
{ } { }
/**
* Empty template method to provide concrete Record classes with the possibility
* to hook into the serializing procedure.
*/
public function preSerialize($event)
{ }
/**
* Empty template method to provide concrete Record classes with the possibility
* to hook into the serializing procedure.
*/
public function postSerialize($event)
{ }
/**
* Empty template method to provide concrete Record classes with the possibility
* to hook into the serializing procedure.
*/
public function preUnserialize($event)
{ }
/**
* Empty template method to provide concrete Record classes with the possibility
* to hook into the serializing procedure.
*/
public function postUnserialize($event)
{ }
/** /**
* Empty template method to provide concrete Record classes with the possibility * Empty template method to provide concrete Record classes with the possibility
* to hook into the saving procedure. * to hook into the saving procedure.
...@@ -447,7 +471,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -447,7 +471,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
public function serialize() public function serialize()
{ {
$this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onSleep($this); $event = new Doctrine_Event($this, Doctrine_Event::SERIALIZE_RECORD);
$this->preSerialize($event);
$vars = get_object_vars($this); $vars = get_object_vars($this);
...@@ -482,7 +508,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -482,7 +508,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
} }
return serialize($vars); $str = serialize($vars);
$this->postSerialize($event);
return $str;
} }
/** /**
* unseralize * unseralize
......
...@@ -222,7 +222,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -222,7 +222,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
$this->createSavePoint($savepoint); $this->createSavePoint($savepoint);
} else { } else {
if ($this->transactionLevel == 0) { if ($this->transactionLevel == 0) {
$event = new Doctrine_Event($this, Doctrine_Event::BEGIN); $event = new Doctrine_Event($this, Doctrine_Event::TX_BEGIN);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionBegin($event); $this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionBegin($event);
...@@ -267,7 +267,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -267,7 +267,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
$this->releaseSavePoint($savepoint); $this->releaseSavePoint($savepoint);
} else { } else {
if ($this->transactionLevel == 1) { if ($this->transactionLevel == 1) {
$event = new Doctrine_Event($this, Doctrine_Event::COMMIT); $event = new Doctrine_Event($this, Doctrine_Event::TX_COMMIT);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionCommit($event); $this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionCommit($event);
...@@ -333,9 +333,15 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -333,9 +333,15 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
if ( ! is_null($savepoint)) { if ( ! is_null($savepoint)) {
$this->transactionLevel = $this->removeSavePoints($savepoint); $this->transactionLevel = $this->removeSavePoints($savepoint);
$event = new Doctrine_Event($this, Doctrine_Event::ROLLBACK_SAVEPOINT);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preSavepointRollback($event);
$this->rollbackSavePoint($savepoint); $this->rollbackSavePoint($savepoint);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postSavepointRollback($event);
} else { } else {
$event = new Doctrine_Event($this, Doctrine_Event::ROLLBACK); $event = new Doctrine_Event($this, Doctrine_Event::TX_ROLLBACK);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionRollback($event); $this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionRollback($event);
......
...@@ -52,7 +52,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -52,7 +52,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'CREATE TABLE test (id INT)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'CREATE TABLE test (id INT)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXEC); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::CONN_EXEC);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$this->assertEqual($this->conn->count(), 1); $this->assertEqual($this->conn->count(), 1);
...@@ -66,14 +66,14 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -66,14 +66,14 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($event->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertEqual($event->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::PREPARE); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::CONN_PREPARE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$stmt->execute(array(1)); $stmt->execute(array(1));
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::STMT_EXECUTE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$this->assertEqual($this->conn->count(), 2); $this->assertEqual($this->conn->count(), 2);
...@@ -85,13 +85,13 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -85,13 +85,13 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$stmt = $this->conn->prepare('INSERT INTO test (id) VALUES (?)'); $stmt = $this->conn->prepare('INSERT INTO test (id) VALUES (?)');
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::PREPARE); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::CONN_PREPARE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$stmt2 = $this->conn->prepare('INSERT INTO test (id) VALUES (?)'); $stmt2 = $this->conn->prepare('INSERT INTO test (id) VALUES (?)');
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::PREPARE); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::CONN_PREPARE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
/** TODO: strange errors here /** TODO: strange errors here
$stmt->execute(array(1)); $stmt->execute(array(1));
...@@ -105,6 +105,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -105,6 +105,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->conn->count(), 4); $this->assertEqual($this->conn->count(), 4);
*/ */
} }
public function testExecuteStatementMultipleTimes() public function testExecuteStatementMultipleTimes()
{ {
try { try {
...@@ -118,14 +119,15 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -118,14 +119,15 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
} }
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::STMT_EXECUTE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::STMT_EXECUTE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
} }
public function testTransactionRollback() public function testTransactionRollback()
{ {
try { try {
...@@ -136,7 +138,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -136,7 +138,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
} }
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::BEGIN); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::TX_BEGIN);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
try { try {
...@@ -148,9 +150,10 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -148,9 +150,10 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::ROLLBACK); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::TX_ROLLBACK);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
} }
public function testTransactionCommit() public function testTransactionCommit()
{ {
try { try {
...@@ -161,7 +164,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -161,7 +164,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
} }
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::BEGIN); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::TX_BEGIN);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
try { try {
...@@ -174,7 +177,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase ...@@ -174,7 +177,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
$this->assertTrue($this->profiler->lastEvent()->hasEnded()); $this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::COMMIT); $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::TX_COMMIT);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
} }
} }
......
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