]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #5952 - Added test
authorPaweł Sroka <srokap@gmail.com>
Sun, 27 Oct 2013 11:17:05 +0000 (12:17 +0100)
committerPaweł Sroka <srokap@gmail.com>
Sun, 27 Oct 2013 12:07:38 +0000 (13:07 +0100)
engine/tests/regression/trac_bugs.php

index f823825abddf9748aa75976fe3a32abd58ba9d73..ef1348cf60813f6adc4238c63bfaae28ab88263b 100644 (file)
@@ -332,4 +332,45 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest {
                
                $group->delete();
        }
+
+       /**
+        * Ensure that ElggBatch doesn't go into infinite loop when disabling annotations recursively when show hidden is enabled.
+        *
+        * https://github.com/Elgg/Elgg/issues/5952
+        */
+       public function test_disabling_annotations_infinite_loop() {
+
+               //let's have some entity
+               $group = new ElggGroup();
+               $group->name = 'test_group';
+               $group->access_id = ACCESS_PUBLIC;
+               $this->assertTrue($group->save() !== false);
+
+               $total = 51;
+               //add some annotations
+               for ($cnt = 0; $cnt < $total; $cnt++) {
+                       $group->annotate('test_annotation', 'value_' . $total);
+               }
+
+               //disable them
+               $show_hidden = access_get_show_hidden_status();
+               access_show_hidden_entities(true);
+               $options = array(
+                       'guid' => $group->guid,
+                       'limit' => $total, //using strict limit to avoid real infinite loop and just see ElggBatch limiting on it before finishing the work
+               );
+               elgg_disable_annotations($options);
+               access_show_hidden_entities($show_hidden);
+
+               //confirm all being disabled
+               $annotations = $group->getAnnotations(array(
+                       'limit' => $total,
+               ));
+               foreach ($annotations as $annotation) {
+                       $this->assertTrue($annotation->enabled == 'no');
+               }
+
+               //delete group and annotations
+               $group->delete();
+       }
 }