/** * 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)); }
/** * Returns the singleton instance of the tests helper. * * @return Enlight_TestHelper */ public static function Instance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
/** * Test case */ public function testConfigFileWrite() { $adapter = new Enlight_Config_Adapter_File(array('configDir' => Enlight_TestHelper::Instance()->TestPath('TempFiles'), 'exclusiveLock' => true, 'skipExtends' => false, 'configType' => 'ini')); $config = new Enlight_Config('test'); $config->setData(array('test' => true)); $config->setSection('test'); $adapter->write($config); }
/** * Sets up */ public function setUp() { $tempDir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $this->engine = new Enlight_Template_Manager(); $this->engine->setCompileDir($tempDir); $this->engine->setCompileId('view'); $this->engine->clearCompiledTemplate(null, 'view'); Smarty::$global_tpl_vars = array(); }
/** * Set up the test case */ public function setUp() { parent::setUp(); $tempDir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $dataDir = Enlight_TestHelper::Instance()->TestPath('DataSets'); $this->manager = new Enlight_Template_Manager(); $this->manager->setCompileDir($tempDir); $this->manager->setCompileId('resource'); $this->manager->setTemplateDir(array($dataDir . 'Template/parent1/', $dataDir . 'Template/parent2/')); }
/** * Set up the test case */ public function setUp() { parent::setUp(); $tempDir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $adapter = new Enlight_Config_Adapter_File(array('configType' => 'ini', 'configDir' => $tempDir, 'namePrefix' => 'snippet_')); $this->manager = new Enlight_Components_Snippet_Manager($adapter); $this->engine = new Enlight_Template_Manager(); $this->engine->setCompileDir($tempDir); $this->engine->setCompileId('snippet'); $this->engine->clearCompiledTemplate(null, 'snippet'); }
/** * 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')); }
/** * Set up the test case */ public function setUp() { parent::setUp(); $dir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $this->adapter = new Enlight_Config_Adapter_File(array('configType' => 'ini', 'configDir' => $dir)); }
/** * Test case */ public function testConfigNamePrefix() { $dir = Enlight_TestHelper::Instance()->TestPath('TempFiles'); $adapter = new Enlight_Config_Adapter_File(array('configDir' => $dir, 'namePrefix' => 's_', 'skipExtends' => false, 'configType' => 'ini')); $config = new Enlight_Config('test', array('adapter' => $adapter)); $config->setData(array('test' => true)); $config->write(); $this->assertFileExists($dir . 's_test' . '.ini'); }
/** * Small helper method to write an form config * * @return void */ private function writeConfig() { $cfg = ' [testing] ; general form metainformation user.login.action = "/user/login" user.login.method = "post" ; username element user.login.elements.username.type = "text" user.login.elements.username.options.validators.alnum.validator = "alnum" user.login.elements.username.options.validators.regex.validator = "regex" user.login.elements.username.options.validators.regex.options.pattern = "/^[a-z]/i" user.login.elements.username.options.validators.strlen.validator = "StringLength" user.login.elements.username.options.validators.strlen.options.min = "6" user.login.elements.username.options.validators.strlen.options.max = "20" user.login.elements.username.options.required = true user.login.elements.username.options.filters.lower.filter = "StringToLower" ; password element user.login.elements.password.type = "password" user.login.elements.password.options.validators.strlen.validator = "StringLength" user.login.elements.password.options.validators.strlen.options.min = "6" user.login.elements.password.options.required = true ; submit element user.login.elements.submit.type = "submit" user.login.disableLoadDefaultDecorators = true user.login.decorators.formElements.decorator = "FormElements" user.login.decorators.description.decorator = "Description" user.login.decorators.form.decorator = "Form" '; $target = Enlight_TestHelper::Instance()->TestPath('TempFiles') . 'testForm.ini'; if (file_exists($target)) { $this->removeOldForm($target); } file_put_contents(Enlight_TestHelper::Instance()->TestPath('TempFiles') . 'testForm.ini', $cfg); }