From 95f38c22ca4b2e69ad7d9bac434432cc852870a0 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 6 Apr 2017 08:50:11 +0800 Subject: [PATCH] MDL-55611 calendar: Fix unit test filter The event test factory uses a closure to return only every other record. This was previously working based on ID but MSSQL starts from an even number rather than an odd number. This change changes that to use a static variable which keeps a count of the records instead and only returns every other record in this fashion, removing the dependance upon ID. --- calendar/tests/event_vault_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/calendar/tests/event_vault_test.php b/calendar/tests/event_vault_test.php index 1d57d1db9d2..0d522497629 100644 --- a/calendar/tests/event_vault_test.php +++ b/calendar/tests/event_vault_test.php @@ -208,7 +208,9 @@ class core_calendar_event_vault_testcase extends advanced_testcase { $user = $this->getDataGenerator()->create_user(); // The factory will skip events with even ids. $factory = new action_event_test_factory(function($actionevent) { - return ($actionevent->get_id() % 2) ? false : true; + static $count = 0; + $count++; + return ($count % 2) ? true : false; }); $strategy = new raw_event_retrieval_strategy(); $vault = new event_vault($factory, $strategy);