Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tests/observer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace tool_dynamic_cohorts;

use advanced_testcase;
use tool_dynamic_cohorts\local\tool_dynamic_cohorts\condition\user_profile;

/**
* Unit tests for observer class.
Expand Down Expand Up @@ -50,6 +49,8 @@ public function setUp(): void {
public function test_user_creation_triggers_rule_processing(): void {
global $DB;

set_config('realtime', 1, 'tool_dynamic_cohorts');

$rule = new rule(0, (object)['name' => 'Test rule 1', 'enabled' => 1, 'cohortid' => $this->cohort->id, 'realtime' => 1]);
$rule->save();

Expand All @@ -60,7 +61,7 @@ public function test_user_creation_triggers_rule_processing(): void {
// Condition username starts with user to catch both users.
$condition->set_config_data([
'profilefield' => 'username',
'username_operator' => user_profile::TEXT_STARTS_WITH,
'username_operator' => condition_base::TEXT_STARTS_WITH,
'username_value' => 'user',
]);

Expand All @@ -83,6 +84,8 @@ public function test_user_creation_triggers_rule_processing(): void {
public function test_user_updating_triggers_rule_processing(): void {
global $DB;

set_config('realtime', 1, 'tool_dynamic_cohorts');

$user1 = $this->getDataGenerator()->create_user(['username' => 'user1']);
$user2 = $this->getDataGenerator()->create_user(['username' => 'user2']);

Expand All @@ -96,7 +99,7 @@ public function test_user_updating_triggers_rule_processing(): void {
// Condition username starts with user to catch both users.
$condition->set_config_data([
'profilefield' => 'username',
'username_operator' => user_profile::TEXT_STARTS_WITH,
'username_operator' => condition_base::TEXT_STARTS_WITH,
'username_value' => 'user',
]);

Expand Down Expand Up @@ -132,7 +135,7 @@ public function test_realtime_rule_processing_when_disabled_globally(): void {
// Condition username starts with user to catch both users.
$condition->set_config_data([
'profilefield' => 'username',
'username_operator' => user_profile::TEXT_STARTS_WITH,
'username_operator' => condition_base::TEXT_STARTS_WITH,
'username_value' => 'user',
]);

Expand Down Expand Up @@ -167,7 +170,7 @@ public function test_realtime_rule_processing_when_disabled_for_a_rule(): void {
// Condition username starts with user to catch both users.
$condition->set_config_data([
'profilefield' => 'username',
'username_operator' => user_profile::TEXT_STARTS_WITH,
'username_operator' => condition_base::TEXT_STARTS_WITH,
'username_value' => 'user',
]);

Expand Down
Loading