|
|
@@ -1646,6 +1646,39 @@ abstract class Zend_Db_Table_TestCommon extends Zend_Db_Table_TestSetup
|
|
|
$this->assertType('Zend_Db_Table_Row', $tblRecursive->find(6)->current());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group ZF-11810
|
|
|
+ */
|
|
|
+ public function testTableCascadeRecurseDeleteUsingTableDeleteMethod()
|
|
|
+ {
|
|
|
+ $tblRecursive = $this->_getTable('My_ZendDbTable_TableCascadeRecursive');
|
|
|
+
|
|
|
+ // Enforce initial table structure
|
|
|
+ $parentRow = $tblRecursive->find(1)->current();
|
|
|
+ $this->assertType('Zend_Db_Table_Row', $parentRow);
|
|
|
+ $childRows = $parentRow->findDependentRowset('My_ZendDbTable_TableCascadeRecursive', 'Children');
|
|
|
+ $this->assertType('Zend_Db_Table_Rowset', $childRows);
|
|
|
+ $this->assertEquals(2, count($childRows));
|
|
|
+ foreach ( $childRows as $childRow ) {
|
|
|
+ $this->assertType('Zend_Db_Table_Row', $childRow);
|
|
|
+ $subChildRows = $childRow->findDependentRowset('My_ZendDbTable_TableCascadeRecursive', 'Children');
|
|
|
+ $this->assertType('Zend_Db_Table_Rowset', $subChildRows);
|
|
|
+ $this->assertEquals( $childRow['item_id'] == 3 ? 2 : 0 , count($subChildRows));
|
|
|
+ }
|
|
|
+
|
|
|
+ // Perform the delete
|
|
|
+ $tblRecursive->delete($tblRecursive->getAdapter()->quoteInto('item_id = ?', 1));
|
|
|
+
|
|
|
+ // Assert that all children of #1 (2,3,4,5) are removed recursively
|
|
|
+ $this->assertNull($tblRecursive->find(1)->current());
|
|
|
+ $this->assertNull($tblRecursive->find(2)->current());
|
|
|
+ $this->assertNull($tblRecursive->find(3)->current());
|
|
|
+ $this->assertNull($tblRecursive->find(4)->current());
|
|
|
+ $this->assertNull($tblRecursive->find(5)->current());
|
|
|
+ //... but #6 remains
|
|
|
+ $this->assertType('Zend_Db_Table_Row', $tblRecursive->find(6)->current());
|
|
|
+ }
|
|
|
+
|
|
|
public function testSerialiseTable()
|
|
|
{
|
|
|
$table = $this->_table['products'];
|