Browse Source

[ZF-3837] insert() don't return last_insert_id when empty key exists in inserted data
Added test to Zend_Db_Table_TestCommon to prove issue has been resolved


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23878 44c647ce-9c0f-0410-b52a-842ac1e357ba

adamlundrigan 14 years ago
parent
commit
1658633432
1 changed files with 22 additions and 0 deletions
  1. 22 0
      tests/Zend/Db/Table/TestCommon.php

+ 22 - 0
tests/Zend/Db/Table/TestCommon.php

@@ -671,6 +671,28 @@ abstract class Zend_Db_Table_TestCommon extends Zend_Db_Table_TestSetup
         $this->assertEquals($insertResult, $lastInsertId);
         $this->assertEquals(5, $lastInsertId);
     }
+    
+    /**
+     * @group ZF-3837
+     */
+    public function testTableInsertWhenAutoIncrementFieldIsAnEmptyStringShouldProduceNewAutoIncrementValue()
+    {
+        $table = $this->_table['bugs'];
+        $row = array (
+            'bug_id'          => '',
+            'bug_description' => 'New bug',
+            'bug_status'      => 'NEW',
+            'created_on'      => '2007-04-02',
+            'updated_on'      => '2007-04-02',
+            'reported_by'     => 'micky',
+            'assigned_to'     => 'goofy',
+            'verified_by'     => 'dduck'
+        );
+        $insertResult = $table->insert($row);
+        $lastInsertId = $this->_db->lastInsertId();
+        $this->assertEquals($insertResult, $lastInsertId);
+        $this->assertEquals(5, $lastInsertId);
+    }
 
     public function testTableInsertWithSchema()
     {