From a9114630ac09cdc9d01da96fd62c3c013d059677 Mon Sep 17 00:00:00 2001 From: qadan Date: Mon, 3 Feb 2014 20:44:06 -0400 Subject: [PATCH] toggle switch for automatic deletion --- tests/islandora_web_test_case.inc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index d417ff37..cd575607 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -14,6 +14,11 @@ class IslandoraWebTestCase extends DrupalWebTestCase { */ protected $users = array(); + /** + * By default, deleteUserCreatedObjects() runs on each tearDown() step. + */ + protected $delete_objects_on_teardown = TRUE; + /** * Sets up the Drupal filter to access this test Drupal instances database. * @@ -160,11 +165,17 @@ class IslandoraWebTestCase extends DrupalWebTestCase { /** * Restores the original Drupal filter, frees any allocated resources. * + * To safeguard against leaving test objects in the repository, tearDown() + * calls deleteUserCreatedObjects() every time by default. This feature can be + * toggled by setting $this->delete_objects_on_teardown to TRUE or FALSE. + * * @see DrupalWebTestCase::tearDown() */ public function tearDown() { - foreach ($this->users as $user) { - $this->deleteUserCreatedObjects($user); + if ($this->delete_objects_on_teardown) { + foreach ($this->users as $user) { + $this->deleteUserCreatedObjects($user); + } } if ($this->configuration['use_drupal_filter']) { $this->restoreDrupalFilter(); @@ -397,6 +408,10 @@ class IslandoraWebTestCase extends DrupalWebTestCase { /** * Deletes all objects created by the given user. * + * To safeguard against leaving test objects in the repository, this is called + * each time DrupalTestCase::run() calls tearDown(). This feature can be + * toggled by setting $this->delete_objects_on_teardown to TRUE or FALSE. + * * @param object $username * The user whose objects we'd like to remove. *