Skip to content

Commit 1a14786

Browse files
committed
Fix last visit tests
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 36b55ae commit 1a14786

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

tests/functional/lastvisit_test.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ public function test_autogroups_memberships()
2525
$test_data = array(
2626
'type' => 'lastvisit',
2727
'group_name' => 'test-lastvisit',
28-
'min' => 0,
29-
'max' => 10,
28+
'min' => 10,
29+
'max' => 1000,
3030
);
3131

32+
$test_user_id = $this->create_user('Bertie');
33+
3234
// Create a new test group
3335
$group_id = $this->create_group($test_data['group_name']);
3436
self::assertNotNull($group_id, 'Failed to create a test group.');
@@ -37,17 +39,17 @@ public function test_autogroups_memberships()
3739
$autogroup_id = $this->create_autogroup_rule($test_data['type'], $group_id, $test_data['min'], $test_data['max']);
3840
self::assertNotNull($autogroup_id, 'Failed to create an auto group rule set.');
3941

40-
// Run the cron job for a user with 2 days of membership, should add the user to the group
41-
$this->update_user_lastvisit(2, 2)->reset_cron();
42+
// Run the cron job for a user with 20 days since last visit, should add the user to the group
43+
$this->update_user_lastvisit($test_user_id, 20)->reset_cron();
4244
self::request('GET', "cron.php?cron_type=cron.task.autogroups_check&sid={$this->sid}", array(), false);
4345
$this->purge_cache();
44-
$this->assertInGroup(2, $test_data['group_name']);
46+
$this->assertInGroup($test_user_id, $test_data['group_name']);
4547

46-
// Run the cron job for a user with 20 days of membership, should remove the user from the group
47-
$this->update_user_lastvisit(2, 20)->reset_cron();
48+
// Run the cron job for a user with 2 days since last visit, should remove the user from the group
49+
$this->update_user_lastvisit($test_user_id, 2)->reset_cron();
4850
self::request('GET', "cron.php?cron_type=cron.task.autogroups_check&sid={$this->sid}", array(), false);
4951
$this->purge_cache();
50-
$this->assertNotInGroup(2, $test_data['group_name']);
52+
$this->assertNotInGroup($test_user_id, $test_data['group_name']);
5153
}
5254

5355
/**

0 commit comments

Comments
 (0)