/**
  * clean up the related bean and the relationship table
  * @access public
  */
 public static function removeCreatedContactAndRelationships()
 {
     if (self::$_createdContact === null) {
         return;
     }
     $GLOBALS['db']->query("DELETE FROM contacts WHERE id = '" . self::$_createdContact->id . "'");
     $GLOBALS['db']->query('DELETE FROM email_addr_bean_rel WHERE bean_module=\'Contacts\' AND bean_id =\'' . self::$_createdContact->id . '\'');
     self::$_createdContact = null;
 }
 public function testEmailSimulatedInvalidFlagWorkflow()
 {
     $workflow_email = '*****@*****.**';
     $new_email = '*****@*****.**';
     // simulate a before workflow: invalid is set to true
     $email_old_invalid = SugarTestSugarEmailAddressUtilities::createEmailAddress($workflow_email, '', array('invalid' => true));
     $old_uuid = SugarTestSugarEmailAddressUtilities::fetchEmailIdByAddress($workflow_email);
     $contact = SugarTestSugarEmailAddressUtilities::getContact();
     $email_old_invalid->stash($contact->id, $contact->module_dir);
     $email_old_invalid->AddUpdateEmailAddress($workflow_email, 0);
     // 'workflow'
     $uuid = $email_old_invalid->AddUpdateEmailAddress($new_email, 1, 0, $old_uuid);
     // workflow is processed
     $this->assertNotNull($old_uuid, 'where is the old email address?');
     $this->assertNotNull($uuid, 'where is our new email address?');
     $this->assertNotEquals($old_uuid, $uuid, 'we used the same Email Address Bean for different Email Addresses!');
     // need a way to see our new work
     $fresh_sea = $this->readSugarEmailAddress($uuid);
     $this->assertNotNull($fresh_sea, 'Email Address not found in DB!');
     $this->assertEquals($new_email, $fresh_sea->email_address, 'Email Address in DB is not the same as expected.');
     $this->assertNotEquals(1, intval($fresh_sea->invalid_email), 'Workflow changes to Email not protected');
 }