public function setUp($connectionName = null) { ActiveRecord\Table::clearCache(); $config = ActiveRecord\Config::instance(); $this->originalDefaultConnection = $config->getDefaultConnection(); if ($connectionName) { $config->setDefaultConnection($connectionName); } if ($connectionName == 'sqlite' || $config->getDefaultConnection() == 'sqlite') { // need to create the db. the adapter specifically does not create it for us. $this->db = substr(ActiveRecord\Config::instance()->getConnection('sqlite'), 9); new SQLite3($this->db); } $this->connectionName = $connectionName; $this->conn = ActiveRecord\ConnectionManager::getConnection($connectionName); $GLOBALS['ACTIVERECORD_LOG'] = false; $loader = new DatabaseLoader($this->conn); $loader->resetTableData(); if (self::$log) { $GLOBALS['ACTIVERECORD_LOG'] = true; } }
public function testClearCacheForSpecificClass() { $bookTable1 = ActiveRecord\Table::load('Book'); $bookTable2 = ActiveRecord\Table::load('Book'); ActiveRecord\Table::clearCache('Book'); $bookTable3 = ActiveRecord\Table::load('Book'); $this->assertTrue($bookTable1 === $bookTable2); $this->assertTrue($bookTable1 !== $bookTable3); }
public function testBeforeValidationReturnedFalseHaltsExecution() { VenueCB::$beforeValidation = array('beforeValidationHaltExecution'); ActiveRecord\Table::clearCache('VenueCB'); $table = ActiveRecord\Table::load('VenueCB'); $v = VenueCB::find(1); $v->name .= 'test'; $ret = $v->save(); $this->assertFalse($ret); $this->assertTrue(strpos(ActiveRecord\Table::load('VenueCB')->lastSql, 'UPDATE') === false); }