コード例 #1
0
 /**
  * Filling the config object with individual testcase data.
  */
 protected function setUp()
 {
     $dbFactory = new Factory();
     if (!isset($this->db)) {
         Registry::remove('db');
         $config = $this->getConfig();
         $this->db = $dbFactory->getInstanceByConfig($config);
         Registry::set('db', $this->db);
     }
     if ($this->db === false) {
         $this->markTestIncomplete('Necessary DB configuration is not set.');
         parent::setUp();
         return;
     }
     /*
      * Deleting all tables from the db and setting up the db using the given schema.
      */
     $sql = 'SHOW TABLES';
     $tableList = $this->db->queryList($sql);
     foreach ($tableList as $table) {
         $sql = 'DROP TABLE ' . $table;
         $this->db->query($sql);
     }
     $this->db->queryMulti($this->getSchemaSQLQueries());
     parent::setUp();
 }
コード例 #2
0
ファイル: Login.php プロジェクト: prepare4battle/Ilch-2.0
 /**
  * Does the logout for a user.
  */
 public function logoutAction()
 {
     unset($_SESSION['user_id']);
     \Ilch\Registry::remove('user');
     if ($this->getRequest()->getParam('from_frontend')) {
         $this->redirect(array());
     } else {
         $this->redirect(array('module' => 'admin', 'controller' => 'login', 'action' => 'index'));
     }
 }
コード例 #3
0
 /**
  * Filling the config object with individual testcase data and injecting it into the registry.
  */
 public static function setConfigInRegistry($configData)
 {
     if (static::$config === null) {
         if (!Registry::has('config') && file_exists(CONFIG_PATH . '/config.php')) {
             static::$config = new Config();
             static::$config->loadConfigFromFile(CONFIG_PATH . '/config.php');
             foreach ($configData as $configKey => $configValue) {
                 static::$config->set($configKey, $configValue);
             }
         }
     }
     Registry::remove('config');
     Registry::set('config', self::$config);
 }
コード例 #4
0
ファイル: DateTest.php プロジェクト: prepare4battle/Ilch-2.0
 /**
  * Tests if the timezone with an empty Registry-Key 'timezone'.
  */
 public function testNewEmptyDateWithoutRegistry()
 {
     Registry::remove('timezone');
     $date = new \Ilch\Date();
     $this->assertEquals('UTC', $date->getTimeZone()->getName(), 'Timezone is not UTC as expected when creating Ilch_Date without a paramter.');
 }
コード例 #5
0
ファイル: UserTest.php プロジェクト: prepare4battle/Ilch-2.0
 /**
  * Tests if the access for a user can be returned.
  */
 public function testHasAccess()
 {
     $group = new Group();
     $group->setId(3);
     $group->setName('Testgroup');
     $user = new User();
     $user->setId(123);
     $user->addGroup($group);
     $dbMock = $this->getMock('Ilch_Database', array('queryCell'));
     $dbMock->expects($this->once())->method('queryCell')->with($this->logicalAnd($this->stringContains('FROM [prefix]_groups_access'), $this->stringContains('INNER JOIN `[prefix]_modules`'), $this->stringContains('user')))->will($this->returnValue('0'));
     Registry::remove('db');
     Registry::set('db', $dbMock);
     $this->assertEquals(0, $user->hasAccess('module_user'));
 }