Selaa lähdekoodia

[ZF-8902]: add proxy to __unset in Zend_Db_Table_Row_Abstract::offsetUnset($offset)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20570 44c647ce-9c0f-0410-b52a-842ac1e357ba
mikaelkael 16 vuotta sitten
vanhempi
commit
9ee6293a98
2 muutettua tiedostoa jossa 26 lisäystä ja 1 poistoa
  1. 2 1
      library/Zend/Db/Table/Row/Abstract.php
  2. 24 0
      tests/Zend/Db/Table/Row/TestCommon.php

+ 2 - 1
library/Zend/Db/Table/Row/Abstract.php

@@ -293,13 +293,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
      }
 
      /**
-      * Does nothing
+      * Proxy to __unset
       * Required by the ArrayAccess implementation
       *
       * @param string $offset
       */
      public function offsetUnset($offset)
      {
+         return $this->__unset($offset);
      }
 
     /**

+ 24 - 0
tests/Zend/Db/Table/Row/TestCommon.php

@@ -319,6 +319,30 @@ abstract class Zend_Db_Table_Row_TestCommon extends Zend_Db_Table_TestSetup
         }
     }
 
+    /**
+     * @group ZF-8902
+     */
+    public function testTableRowOffsetUnset()
+    {
+        $table = $this->_table['bugs'];
+        $bug_description = $this->_db->foldCase('bug_description');
+
+        $rowset = $table->find(1);
+        $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset,
+            'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset));
+        $row1 = $rowset->current();
+        $this->assertType('Zend_Db_Table_Row_Abstract', $row1,
+            'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1));
+
+        try {
+            $this->assertTrue($row1->offsetExists($bug_description));
+            $row1->offsetUnset($bug_description);
+            $this->assertFalse($row1->offsetExists($bug_description));
+        } catch (Zend_Exception $e) {
+            $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected.  Exception message: \"".$e->getMessage()."\"\n");
+        }
+    }
+
     public function testTableRowSetFromArray()
     {
         $table = $this->_table['bugs'];