/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->db = Enlight_Components_Db::factory('PDO_SQLITE', array('dbname' => Enlight_TestHelper::Instance()->TestPath('TempFiles') . 'cron.db')); $sql = ' DROP TABLE IF EXISTS `test_crontab`; CREATE TABLE IF NOT EXISTS `test_crontab` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255) NOT NULL, `action` varchar(255) NOT NULL, `data` text NOT NULL, `next` datetime DEFAULT NULL, `start` datetime DEFAULT NULL, `interval` int(11) NOT NULL, `active` int(1) NOT NULL, `end` datetime DEFAULT NULL, UNIQUE (`action`) ); '; $this->db->exec($sql); $options = array('idColumn' => 'id', 'nameColumn' => 'name', 'actionColumn' => 'action', 'dataColumn' => 'data', 'nextColumn' => 'next', 'startColumn' => 'start', 'intervalColumn' => 'interval', 'activeColumn' => 'active', 'endColumn' => 'end', 'name' => 'test_crontab', 'db' => $this->db); $this->jobData = array('name' => 'Lagerbestand Warnung', 'action' => 'article_stock', 'data' => '', 'next' => '2010-10-16 12:34:33', 'start' => '2010-10-16 12:34:31', 'interval' => '5', 'active' => '1', 'end' => '2010-10-16 12:34:32', 'crontab' => 's_crontab'); $this->jobData['next'] = new Zend_Date($this->jobData['next']); $this->jobData['start'] = new Zend_Date($this->jobData['start']); $this->jobData['end'] = new Zend_Date($this->jobData['end']); $this->jobData['data'] = array('key' => 'value'); $this->assertInstanceOf('Enlight_Components_Cron_Adapter', $this->_adapter = new Enlight_Components_Cron_Adapter_DbTable($options)); $this->assertInstanceOf('Enlight_Components_Cron_Manager', $this->manager = new Enlight_Components_Cron_Manager($this->_adapter)); $job = new Enlight_Components_Cron_Job($this->jobData); $this->assertInstanceOf('Enlight_Components_Cron_Manager', $this->manager->addJob($job)); }
/** * @return Zend_Db_Adapter_Pdo_Mysql */ public function initDb() { $configDb = array_merge(array('adapter' => 'PDO_MYSQL', 'params' => array('host' => '127.0.0.1', 'username' => 'root', 'password' => '', 'dbname' => 'enlight')), (array) $this->Application()->getOption('db')); $db = Enlight_Components_Db::factory(new Enlight_Config($configDb)); $db->getConnection(); return $db; }
/** * @param string $adapter * @param array $options * @return \Enlight_Components_Db_Adapter_Pdo_Mysql */ public function factory($adapter, $options) { /** @var \Enlight_Components_Db_Adapter_Pdo_Mysql $db */ $db = \Enlight_Components_Db::factory($adapter, $options); // Reset sql_mode "STRICT_TRANS_TABLES" that will be default in MySQL 5.6 $db->exec("SET @@session.sql_mode = ''"); return $db; }
/** * initialize and creates the db adapter * * @return Zend_Db_Adapter_Pdo_Mysql */ public function initDb() { //loads the db application option given in the application starter $config = $this->Application()->getOptions(); $db = Enlight_Components_Db::factory(new Zend_Config(array('adapter' => $config["adapter"], 'params' => $config["db"]))); $db->getConnection(); Zend_Db_Table_Abstract::setDefaultAdapter($db); return $db; }
/** * Class constructor to open the database connection * * @param $config */ public function __construct($config) { if (Shopware()->Plugins()->Backend()->SwagMigration()->Config()->debugMigration) { $this->db = new Shopware_Components_Migration_DbDecorator(Enlight_Components_Db::factory($this->db_adapter, $config)); } else { $this->db = Enlight_Components_Db::factory($this->db_adapter, $config); } $this->db->getConnection(); if (isset($config['prefix'])) { $this->db_prefix = $config['prefix']; } }
/** * Set up the test case */ public function setUp() { parent::setUp(); $dir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $this->db = Enlight_Components_Db::factory('PDO_SQLITE', array('dbname' => $dir . 'config.db')); $this->db->exec(' CREATE TABLE IF NOT EXISTS `config_test` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `section` varchar(255) DEFAULT NULL, `name` varchar(255) NOT NULL, `value` text NOT NULL, `created` datetime NOT NULL, `updated` datetime NOT NULL ); '); }
/** * Set up the test case */ public function setUp() { parent::setUp(); $dir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $this->db = Enlight_Components_Db::factory('PDO_SQLITE', array('dbname' => Enlight_TestHelper::Instance()->TestPath('TempFiles') . 'auth.db')); $this->lockeduntilColumn = 'lockeduntil'; $this->createDb($this->lockeduntilColumn); $this->createDefaultUser($this->lockeduntilColumn); // Needed to simulate web environment - otherwise we would get a nasty notice. $GLOBALS['_SESSION'] = array(); Zend_Session::$_unitTestEnabled = true; Zend_Session::start(); $this->auth = Enlight_Components_Auth::getInstance(); $this->authAdapter = new Enlight_Components_Auth_Adapter_DbTable($this->db, 'test_auth', 'username', 'password'); $this->authAdapter->setIdentityColumn('username')->setCredentialColumn('password')->setExpiryColumn('lastlogin')->setSessionIdColumn('sessionID')->setSessionId('s4inr04o6apmclk7u88qau4r57'); $storage = new Zend_Auth_Storage_Session('Enlight', 'Auth'); $this->auth->setAdapter($this->authAdapter); $this->assertInstanceOf('Enlight_Components_Auth_Adapter_DbTable', $this->auth->getAdapter()); $this->auth->setStorage($storage); }
/** * Set up the test case */ public function setUp() { parent::setUp(); $dir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $this->db = Enlight_Components_Db::factory('PDO_SQLITE', array('dbname' => $dir . 'menu.db')); $this->db->exec(' DROP TABLE IF EXISTS `menu_test`; CREATE TABLE IF NOT EXISTS `menu_test` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `parent` INTEGER NOT NULL, `active` INTEGER(1) NOT NULL, `label` varchar(255) NOT NULL ); DROP TABLE IF EXISTS `menu_test2`; CREATE TABLE IF NOT EXISTS `menu_test2` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `parent` INTEGER NOT NULL, `active` INTEGER(1) NOT NULL, `name` varchar(255) NOT NULL ); '); $this->adapter = new Enlight_Components_Menu_Adapter_DbTable(array('db' => $this->db, 'name' => 'menu_test')); }
/** * Init database method * * @return Zend_Db_Adapter_Pdo_Abstract */ protected function initDb() { $config = Shopware()->getOption('db'); $db = Enlight_Components_Db::factory( isset($config['adapter']) ? $config['adapter'] : 'PDO_MYSQL', $config ); $db->getConnection(); return $db; }