Example #1
0
 public function testTableExceptionNoAdapter()
 {
     Zend_Loader::loadClass('Zend_Db_Table_ZfTestTable');
     try {
         $dbTable = new Zend_Db_Table_ZfTestTable(array('db' => 327));
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception, got ' . get_class($e));
         $this->assertEquals("No object of type Zend_Db_Adapter_Abstract has been specified", $e->getMessage());
     }
     Zend_Registry::set('registered_db', 327);
     try {
         $dbTable = new Zend_Db_Table_ZfTestTable(array('db' => 'registered_db'));
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception, got ' . get_class($e));
         $this->assertEquals("No object of type Zend_Db_Adapter_Abstract has been specified", $e->getMessage());
     }
     try {
         Zend_Db_Table_ZfTestTable::setDefaultAdapter(327);
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('PHPUnit_Framework_Error'), 'Expecting object of type Zend_Db_Table_Exception, got ' . get_class($e));
         $mesg = substr("Argument 1 passed to Zend_Db_Table_Abstract::setDefaultAdapter() must be an instance of Zend_Db_Adapter_Abstract, integer given", 0, 100);
         $this->assertEquals($mesg, substr($e->getMessage(), 0, 100));
     }
 }
Example #2
0
 public function testTableExceptionNoAdapter()
 {
     Zend::loadClass('Zend_Db_Table_ZfTestTable');
     try {
         $dbTable = new Zend_Db_Table_ZfTestTable(array('db' => 327));
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception');
         $this->assertEquals($e->getMessage(), 'db object does not extend Zend_Db_Adapter_Abstract');
     }
     Zend::register('registered_db', 327);
     try {
         $dbTable = new Zend_Db_Table_ZfTestTable(array('db' => 'registered_db'));
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception');
         $this->assertEquals($e->getMessage(), 'db object does not extend Zend_Db_Adapter_Abstract');
     }
     try {
         Zend_Db_Table_ZfTestTable::setDefaultAdapter(327);
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception');
         $this->assertEquals($e->getMessage(), 'db object does not extend Zend_Db_Adapter_Abstract');
     }
 }