civicrm/civicrm-core — pull request #3983 by totten (2014-08-28 06:47:01+00:00)
Title: api_v3_SyntaxConformanceTest - Work-around problem with MembershipBlock

It appears that -- during the course of executing testCreateSingleValueAlter('MembershipBlock') -- calls createTestOject to create two MembershipBlocks linked to two ContributionPages. tearDown() tries to delete these four test-objects by calling deleteTestObject. However, the order of the deletes is invalid because the FK's have been rearranged by testCreateSingleValueAlter, so we get:

```
DELETE FROM civicrm_contribution_page WHERE ( civicrm_contribution_page.id = 1 ) [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`d45test_ihhvp`.`civicrm_membership_block`, CONSTRAINT `FK_civicrm_membership_block_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_contribution_page` (`id`))]
```

This patch is the simplest thing (ie it tells testCreateSingleValueAlter not to mess-around with the entity_id FK). However, it might also work to set ON DELETE (CASCADE | SET NULL) for the MembershipBlock<=>ContributionPage FK. (In that case, the order wouldn't matter.) However, I'm not familiar enough with this FK to know the right ON DELETE behavior, so... I've just done the simplest thing.