$this->assertTrue($o = $this->m->get('eptBook', $oid)); // events (onPreLoad) should have fired, but no onLoad $this->assertTrue(eptBook::$counts['onPreLoad'] == $i * 2 + 2); $this->assertTrue(eptBook::$counts['onLoad'] == $i + 1); // update object $o->title = md5($o->title); $this->assertTrue($o->commit()); // events (onPreUpdate, onUpdate) should have fired $this->assertTrue(eptBook::$counts['onPreUpdate'] == $i + 1); $this->assertTrue(eptBook::$counts['onUpdate'] == $i + 1); // delete object $this->assertTrue($o->delete()); // events (onPreDelete, onDelete) should have fired $this->assertTrue(eptBook::$counts['onPreDelete'] == $i + 1); $this->assertTrue(eptBook::$counts['onDelete'] == $i + 1); } // unregister a listner class (returns 1 instances unregistered) $this->assertTrue($this->m->unregister('eptBook') == 1); } } if (!defined('EP_GROUP_TEST')) { $tm = microtime(true); $t = new epTestListeners(); if (epIsWebRun()) { $t->run(new HtmlReporter()); } else { $t->run(new TextReporter()); } $elapsed = microtime(true) - $tm; echo epNewLine() . 'Time elapsed: ' . $elapsed . ' seconds' . "\n"; }
/** * Run all tests * @param string $dbal (adodb, peardb) * @param string $dbtype (mysql, sqlite) */ function _allTests($dbal, $dbtype) { echo "tests for {$dbal}/{$dbtype} started.. " . epNewLine(); echo " setup.."; $this->_setUp($dbal, $dbtype); echo "done " . epNewLine(); echo " single object.."; $this->_testSingleObject(); echo "done " . epNewLine(); echo " multiple objects.."; $this->_testMultiObjects(); echo "done " . epNewLine(); echo " array sort by.."; $this->_testArraySortBy(); echo "done " . epNewLine(); echo " array to object.."; $this->_testCreateFromArray(); echo "done " . epNewLine(); echo " data typess.."; $this->_testDataTypes(); echo "done " . epNewLine(); echo " find objects.."; $this->_testObjectFind(); echo "done " . epNewLine(); echo " find objects by child.."; $this->_testObjectFindByChild(); echo "done " . epNewLine(); echo " object query primitive.."; $this->_testObjectQueryPrimitive(); echo "done " . epNewLine(); echo " object query relationship.."; $this->_testObjectQueryRelationship(); echo "done " . epNewLine(); echo " object relationship.."; $this->_testObjectRelation(); echo "done " . epNewLine(); echo " composed delete.."; $this->_testComposedOfDelete(); echo "done " . epNewLine(); echo " object transaction.."; $this->_testTransactionObject(); echo "done " . epNewLine(); echo " transaction: commit.."; $this->_testTransactionStartCommit(); echo "done " . epNewLine(); echo " transaction: rollback.."; $this->_testTransactionStartRollback(); echo "done " . epNewLine(); echo " complete!" . epNewLine(); }
/** * Run all tests * @param string $dbal (adodb, peardb) * @param string $dbtype (mysql, sqlite) */ function _runTests($dbal, $dbtype) { echo "EZOQL tests for {$dbal}/{$dbtype} started.. " . epNewLine(); echo " setting up.."; $this->_start($dbal, $dbtype); echo "done " . epNewLine(); if ($methods = get_class_methods(__CLASS__)) { // go through each _testXXX methods foreach ($methods as $method) { // skip non test methods if (0 !== strpos($method, '_test')) { continue; } // run the test echo " {$method}.."; $this->assertTrue($this->{$method}()); echo "done " . epNewLine(); } } echo " tearing down.. "; $this->_end(); echo "done " . epNewLine(); echo " complete!" . epNewLine(); }
/** * Debug: Print out all class maps in the factory */ function _cmfToString(epClassMapFactory $cmf) { $s = ''; $cms = $cmf->allMade(); ksort($cms); foreach ($cms as $cm) { $s .= 'class: ' . $cm->getName() . epNewLine(); $fms = $cm->getAllFields(); ksort($fms); foreach ($fms as $fm) { $s .= ' field: ' . $fm->getName() . epNewLine(); } } return $s; }