[limb-svn] r6874 - in 3.x/trunk/limb: active_record/tests/cases dbal/src/toolkit dbal/tests/cases dbal/tests/cases/toolkit web_app/tests/cases

svn at limb-project.com svn at limb-project.com
Mon Mar 31 11:23:58 MSD 2008


Author: pachanga
Date: 2008-03-31 11:23:58 +0400 (Mon, 31 Mar 2008)
New Revision: 6874
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6874

Modified:
   3.x/trunk/limb/active_record/tests/cases/.setup.php
   3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php
   3.x/trunk/limb/dbal/tests/cases/.setup.php
   3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php
   3.x/trunk/limb/web_app/tests/cases/.setup.php
Log:
-- renaming isDefaultDbDsnAvailable() into isDefaultDbDSNAvailable() for consistency -- adding test for isDefaultDbDSNAvailable

Modified: 3.x/trunk/limb/active_record/tests/cases/.setup.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/.setup.php	2008-03-31 04:21:11 UTC (rev 6873)
+++ 3.x/trunk/limb/active_record/tests/cases/.setup.php	2008-03-31 07:23:58 UTC (rev 6874)
@@ -7,7 +7,7 @@
 }
 
 require_once(dirname(__FILE__) . '/../../common.inc.php');
-if(!lmbToolkit::instance()->isDefaultDbDsnAvailable())
+if(!lmbToolkit::instance()->isDefaultDbDSNAvailable())
 {
   $dsn = 'sqlite://localhost/' . LIMB_VAR_DIR . '/sqlite_tests.db';
   echo "Using default sqlite test database '$dsn'\n";

Modified: 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php	2008-03-31 04:21:11 UTC (rev 6873)
+++ 3.x/trunk/limb/dbal/src/toolkit/lmbDbTools.class.php	2008-03-31 07:23:58 UTC (rev 6874)
@@ -47,13 +47,15 @@
     return $this->getDbDSNByName('dsn');
   }
 
-  function isDefaultDbDsnAvailable()
+  function isDefaultDbDSNAvailable()
   {
     try
     {
       $dsn = $this->getDefaultDbDSN();
       if($dsn)
         return true;
+      else
+        return false;
     }
     catch(lmbException $e)
     {

Modified: 3.x/trunk/limb/dbal/tests/cases/.setup.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/.setup.php	2008-03-31 04:21:11 UTC (rev 6873)
+++ 3.x/trunk/limb/dbal/tests/cases/.setup.php	2008-03-31 07:23:58 UTC (rev 6874)
@@ -7,7 +7,7 @@
 }
 
 require_once(dirname(__FILE__) . '/../../common.inc.php');
-if(!lmbToolkit::instance()->isDefaultDbDsnAvailable())
+if(!lmbToolkit::instance()->isDefaultDbDSNAvailable())
 {
   $dsn = 'sqlite://localhost/' . LIMB_VAR_DIR . '/sqlite_tests.db';
   echo "Using default sqlite test database '$dsn'\n";

Modified: 3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php	2008-03-31 04:21:11 UTC (rev 6873)
+++ 3.x/trunk/limb/dbal/tests/cases/toolkit/lmbDbToolsTest.class.php	2008-03-31 07:23:58 UTC (rev 6874)
@@ -3,66 +3,90 @@
 lmb_require('limb/toolkit/src/lmbToolkit.class.php');
 lmb_require('limb/dbal/src/toolkit/lmbDbTools.class.php');
 
+class ExceptionalDbConfStub extends lmbConf
+{
+  function __construct(){}
+
+  function get($name, $default = LIMB_UNDEFINED)
+  {
+    throw new lmbException("Ooops!");
+  }
+}
+
 class lmbDbToolsTest extends UnitTestCase
 {
-  public $toolkit;
-  public $config;
-  protected $conn;
+  var $tools;
+  var $config;
+  var $conn;
 
   function setUp()
   {
     parent::setUp();
-    $this->toolkit = new lmbDbTools();
-    $this->conn = $this->toolkit->getDefaultDbConnection();
+
+    $this->tools = new lmbDbTools();
+    $this->conn = $this->tools->getDefaultDbConnection();
     $this->config = array(
       'dsn' => 'mysql://root:test@localhost/hello_from_foo?charset=cp1251',
       'another_dsn' => 'sqlite://kraynopp:pasha@ksu/kadrs?charset=utf8'
     );
     lmbToolkit::instance()->setConf('db', new lmbSet($this->config));
-    $this->toolkit->setDefaultDbConnection($this->toolkit->createDbConnection(new lmbDbDSN($this->config['dsn'])));
+    $this->tools->setDefaultDbConnection($this->tools->createDbConnection(new lmbDbDSN($this->config['dsn'])));
   }
   
   function tearDown()
   {
-    $this->toolkit->setDefaultDbConnection($this->conn);    
+    $this->tools->setDefaultDbConnection($this->conn);    
   }
 
   function testGetDbDSNByName()
   {
-    $this->assertEqual($this->toolkit->getDbDSNByName('another_dsn'), new lmbDbDSN($this->config['another_dsn']));
+    $this->assertEqual($this->tools->getDbDSNByName('another_dsn'), new lmbDbDSN($this->config['another_dsn']));
   }
 
   function testGetDefaultDbDSN()
   {
     $this->assertEqual(
-      $this->toolkit->getDefaultDbDSN(),
-      $this->toolkit->getDbDSNByName('dsn')
+      $this->tools->getDefaultDbDSN(),
+      $this->tools->getDbDSNByName('dsn')
     );
   }
 
+  function testIsDefaultDbDSNAvailable()
+  {
+    $tools = new lmbDbTools();
+    $tools->setDefaultDbDSN("mysql://localhost/test");
+    $this->assertTrue($tools->isDefaultDbDSNAvailable());
+
+    $toolkit = lmbToolkit :: save();
+    $tools = new lmbDbTools();
+    $toolkit->setConf('db', new ExceptionalDbConfStub());
+    $this->assertFalse($tools->isDefaultDbDSNAvailable());
+    lmbToolkit :: restore();
+  }
+
   function testSetDbDSNByName()
   {
-    $this->assertEqual($this->toolkit->getDbDSNByName('another_dsn'), new lmbDbDSN($this->config['another_dsn']));
+    $this->assertEqual($this->tools->getDbDSNByName('another_dsn'), new lmbDbDSN($this->config['another_dsn']));
     $dsn = new lmbDbDSN($this->config['dsn']);
-    $this->toolkit->setDbDSNByName('another_dsn', $dsn);
-    $this->assertEqual($this->toolkit->getDbDSNByName('another_dsn'), new lmbDbDSN($this->config['dsn']));
+    $this->tools->setDbDSNByName('another_dsn', $dsn);
+    $this->assertEqual($this->tools->getDbDSNByName('another_dsn'), new lmbDbDSN($this->config['dsn']));
   }
 
   function testGetDbConnectionByName()
   {
-    $connection = $this->toolkit->createDbConnection(new lmbDbDSN($this->config['another_dsn']));
-    $this->assertIdentical($connection, $this->toolkit->getDbConnectionByName('another_dsn'));
+    $connection = $this->tools->createDbConnection(new lmbDbDSN($this->config['another_dsn']));
+    $this->assertIdentical($connection, $this->tools->getDbConnectionByName('another_dsn'));
   }
 
   function testSetDbConnectionByName()
   {
-    $connection = $this->toolkit->createDbConnection(new lmbDbDSN($this->config['dsn']));
-    $another_connection = $this->toolkit->createDbConnection(new lmbDbDSN($this->config['another_dsn']));
+    $connection = $this->tools->createDbConnection(new lmbDbDSN($this->config['dsn']));
+    $another_connection = $this->tools->createDbConnection(new lmbDbDSN($this->config['another_dsn']));
 
-    $this->assertEqual($connection, $this->toolkit->getDefaultDbConnection());
+    $this->assertEqual($connection, $this->tools->getDefaultDbConnection());
 
-    $this->toolkit->setDbConnectionByName('dsn', $another_connection);
+    $this->tools->setDbConnectionByName('dsn', $another_connection);
 
-    $this->assertIdentical($another_connection, $this->toolkit->getDefaultDbConnection());
+    $this->assertIdentical($another_connection, $this->tools->getDefaultDbConnection());
   }
-}
\ No newline at end of file
+}

Modified: 3.x/trunk/limb/web_app/tests/cases/.setup.php
===================================================================
--- 3.x/trunk/limb/web_app/tests/cases/.setup.php	2008-03-31 04:21:11 UTC (rev 6873)
+++ 3.x/trunk/limb/web_app/tests/cases/.setup.php	2008-03-31 07:23:58 UTC (rev 6874)
@@ -7,7 +7,7 @@
 }
 
 require_once(dirname(__FILE__) . '/../../common.inc.php');
-if(!lmbToolkit::instance()->isDefaultDbDsnAvailable())
+if(!lmbToolkit::instance()->isDefaultDbDSNAvailable())
 {
   $dsn = 'sqlite://localhost/' . LIMB_VAR_DIR . '/sqlite_tests.db';
   echo "Using default sqlite test database '$dsn'\n";



More information about the limb-svn mailing list