|
From: <gem...@li...> - 2012-01-02 12:35:29
|
Revision: 392
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=392&view=rev
Author: mennodekker
Date: 2012-01-02 12:35:23 +0000 (Mon, 02 Jan 2012)
Log Message:
-----------
Fixed unit tests
Modified Paths:
--------------
trunk/library/classes/Gems/User/Organization.php
trunk/library/classes/Gems/Util/AccessLogActions.php
trunk/library/classes/Gems/Util/DbLookup.php
trunk/test/classes/IndexControllerTest.php
Modified: trunk/library/classes/Gems/User/Organization.php
===================================================================
--- trunk/library/classes/Gems/User/Organization.php 2012-01-02 10:17:42 UTC (rev 391)
+++ trunk/library/classes/Gems/User/Organization.php 2012-01-02 12:35:23 UTC (rev 392)
@@ -201,8 +201,12 @@
*/
protected function loadData($id)
{
- $sql = "SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1";
- $data = $this->db->fetchRow($sql, $id);
+ try {
+ $sql = "SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1";
+ $data = $this->db->fetchRow($sql, $id);
+ } catch (Exception $e) {
+ $data = false;
+ }
if ($data) {
try {
Modified: trunk/library/classes/Gems/Util/AccessLogActions.php
===================================================================
--- trunk/library/classes/Gems/Util/AccessLogActions.php 2012-01-02 10:17:42 UTC (rev 391)
+++ trunk/library/classes/Gems/Util/AccessLogActions.php 2012-01-02 12:35:23 UTC (rev 392)
@@ -75,6 +75,12 @@
*/
protected function loadData($id)
{
- return $this->db->fetchAssoc('SELECT glac_name, glac_id_action AS id, glac_log AS log FROM gems__log_actions ORDER BY glac_name');
+ try {
+ $data = $this->db->fetchAssoc('SELECT glac_name, glac_id_action AS id, glac_log AS log FROM gems__log_actions ORDER BY glac_name');
+ } catch (Exception $exc) {
+ $data = array();
+ }
+
+ return $data;
}
}
Modified: trunk/library/classes/Gems/Util/DbLookup.php
===================================================================
--- trunk/library/classes/Gems/Util/DbLookup.php 2012-01-02 10:17:42 UTC (rev 391)
+++ trunk/library/classes/Gems/Util/DbLookup.php 2012-01-02 12:35:23 UTC (rev 392)
@@ -249,7 +249,11 @@
try {
$organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 ORDER BY gor_name');
} catch (Exception $e) {
- $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 ORDER BY gor_name');
+ try {
+ $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 ORDER BY gor_name');
+ } catch (Exception $e) {
+ $organizations = array();
+ }
}
natsort($organizations);
}
Modified: trunk/test/classes/IndexControllerTest.php
===================================================================
--- trunk/test/classes/IndexControllerTest.php 2012-01-02 10:17:42 UTC (rev 391)
+++ trunk/test/classes/IndexControllerTest.php 2012-01-02 12:35:23 UTC (rev 392)
@@ -17,16 +17,40 @@
parent::setUp();
}
+
+ /**
+ * Here we fix the intentional errors that are in de default setup
+ *
+ * At the moment we only set a salt in the project resource
+ */
+ public function _fixSetup() {
+ $this->bootstrap->bootstrap();
+ $project = $this->bootstrap->getBootstrap()->getResource('project');
+ $project->salt = 'TESTCASE';
+ }
+
+ public function testSaltRequired()
+ {
+ $this->dispatch('/');
+ $reponse = $this->getFrontController()->getResponse();
+ $exception = $reponse->getExceptionByMessage("Missing required project setting: 'salt'.");
+ $this->assertTrue(count($exception) == 1);
+ }
public function testHomeRedirectsToLogin()
{
+ $this->_fixSetup();
$this->dispatch('/');
$this->assertRedirectTo('/index/login');
}
public function testLoginPage()
{
+ $this->_fixSetup();
$this->dispatch('/index/login');
+ $reponse = $this->getFrontController()->getResponse();
+ var_dump($reponse->getBody());
+
$this->assertController('index');
$this->assertAction('login');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|