Пример #1
0
 public function test_constructor_shouldNotEstablishADatabaseConnection()
 {
     Db::destroyDatabaseObject();
     $this->assertNotDbConnectionCreated();
     $this->createSettingsInstance();
     $this->assertNotDbConnectionCreated();
 }
Пример #2
0
 /**
  * @dataProvider getDbAdapter
  */
 public function test_SqlMode_IsSet_PDO($adapter, $expectedClass)
 {
     Db::destroyDatabaseObject();
     Config::getInstance()->database['adapter'] = $adapter;
     $db = Db::get();
     // make sure test is useful and setting adapter works
     $this->assertInstanceOf($expectedClass, $db);
     $result = $db->fetchOne('SELECT @@SESSION.sql_mode');
     $expected = 'NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER';
     $this->assertSame($expected, $result);
 }
Пример #3
0
 public function test_constructor_shouldEstablishADatabaseConnection_AsSoonAsWeSetAValue()
 {
     $this->setSuperUser();
     Db::destroyDatabaseObject();
     $setting = $this->buildUserSetting('testSetting', 'Test Setting');
     $settings = $this->createSettingsInstance();
     $settings->addSetting($setting);
     $this->assertNotDbConnectionCreated();
     $setting->setValue('5');
     $this->assertDbConnectionCreated();
 }
Пример #4
0
 public function test_getDbLock_shouldGetLock()
 {
     $db = Db::get();
     $this->assertTrue(Db::getDbLock('MyLock'));
     // same session still has lock
     $this->assertTrue(Db::getDbLock('MyLock'));
     Db::setDatabaseObject(null);
     // different session, should not be able to acquire lock
     $this->assertFalse(Db::getDbLock('MyLock', 1));
     // different session cannot release lock
     $this->assertFalse(Db::releaseDbLock('MyLock'));
     Db::destroyDatabaseObject();
     // release lock again by using previous session
     Db::setDatabaseObject($db);
     $this->assertTrue(Db::releaseDbLock('MyLock'));
     Db::destroyDatabaseObject();
 }
 public function test_process_ShouldNotCreateADatabaseConnectionAtAnyTime()
 {
     $this->setDummyRequests(false);
     Queue\Factory::getSettings()->queueEnabled->getValue();
     // this will cause a db query but will be cached afterwards
     Db::destroyDatabaseObject();
     $this->handler->init($this->tracker, $this->requestSet);
     $this->assertNotDbConnectionCreated();
     $this->handler->onStartTrackRequests($this->tracker, $this->requestSet);
     $this->assertNotDbConnectionCreated();
     $this->handler->process($this->tracker, $this->requestSet);
     $this->assertNotDbConnectionCreated();
     $this->handler->onAllRequestsTracked($this->tracker, $this->requestSet);
     $this->assertNotDbConnectionCreated();
     $this->handler->finish($this->tracker, $this->requestSet);
     $this->assertNotDbConnectionCreated();
 }
Пример #6
0
 private function resetDatabase()
 {
     Option::clearCache();
     Db::destroyDatabaseObject();
 }
 public function setUp()
 {
     parent::setUp();
     Db::destroyDatabaseObject();
     $this->settings = $this->createSettingsInstance();
 }