Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONTRIB-9449: Update tests #8

Closed
wants to merge 1 commit into from
Closed
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
47 changes: 45 additions & 2 deletions tests/bigbluebutton/action_url_addons_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use bbbext_flexurl\utils;
use mod_bigbluebuttonbn\extension;
use mod_bigbluebuttonbn\external\get_join_url;
use mod_bigbluebuttonbn\local\proxy\proxy_base;
use mod_bigbluebuttonbn\instance;

/**
Expand Down Expand Up @@ -65,33 +66,75 @@ public function setUp(): void {
$DB->insert_record('bbbext_flexurl',
['bigbluebuttonbnid' => $this->bbb->id, 'eventtype' => utils::ACTION_CODES['all'], 'paramname' => 'coursename',
'paramvalue' => 'courseinfo.fullname', ]);
// Pass extra parameters that are prefixed, meta or contain dashes on both create and join.
$DB->insert_record('bbbext_flexurl',
['bigbluebuttonbnid' => $this->bbb->id, 'eventtype' => utils::ACTION_CODES['all'], 'paramname' => 'one',
'paramvalue' => 'TEST', ]);
$DB->insert_record('bbbext_flexurl',
['bigbluebuttonbnid' => $this->bbb->id, 'eventtype' => utils::ACTION_CODES['all'], 'paramname' => 'suffix_two',
'paramvalue' => 'TEST', ]);
$DB->insert_record('bbbext_flexurl',
['bigbluebuttonbnid' => $this->bbb->id, 'eventtype' => utils::ACTION_CODES['all'], 'paramname' => 'meta_three',
'paramvalue' => 'TEST', ]);
$DB->insert_record('bbbext_flexurl',
['bigbluebuttonbnid' => $this->bbb->id, 'eventtype' => utils::ACTION_CODES['all'], 'paramname' => 'four-param',
'paramvalue' => 'TEST', ]);
}

/**
* Test join URL
*
* @dataProvider provider_value_for_parameters
*
* @param string $expectedstring
* @return void
*/
public function test_join_url_has_options() {
public function test_join_url_has_options($expectedstring) {
$this->setUser($this->user);
$instance = instance::get_from_instanceid($this->bbb->id);
$joinurl = get_join_url::execute($instance->get_cm_id());
$this->assertStringNotContainsString('firstname', $joinurl['join_url']);
$this->assertStringContainsString('lastname', $joinurl['join_url']);
$this->assertStringContainsString('coursename', $joinurl['join_url']);
$this->assertStringContainsString('BBB+LN', $joinurl['join_url']);
$this->assertStringContainsString($expectedstring, $joinurl['join_url']);
}

/**
* Test create URL
*
* @dataProvider provider_value_for_parameters
*
* @param string $expectedstring
* @return void
*/
public function test_create_url_has_options() {
public function test_create_url_has_options($expectedstring) {
$this->setUser($this->user);
instance::get_from_instanceid($this->bbb->id);
$addons = extension::action_url_addons('create', [], ['bbb-meta' => 'Test'], $this->bbb->id);
$this->assertContains('firstname', array_keys($addons['metadata']));
$this->assertContains('coursename', array_keys($addons['metadata']));
$this->assertNotContains('lastname', array_keys($addons['metadata']));

$rc = new \ReflectionClass(proxy_base::class);
$actionurl = $rc->getMethod('action_url');
$actionurl->setAccessible(true);
// Generate a create URL.
$createurl = $actionurl->invokeArgs(null, ['create', [], [], $this->bbb->id]);
$this->assertStringContainsString($expectedstring, $createurl);
}

/**
* Provider for Test create URL and join URL
*
* @return array[]
*/
public static function provider_value_for_parameters(): array {
return [
'pass a parameter on create and join' => ['one=TEST'],
'pass a prefixed parameter on create and join' => ['suffix_two=TEST'],
'pass a meta parameter on create and join' => ['meta_three=TEST'],
'pass a parameter with dashes on create and join' => ['four-param=TEST'],
];
}
}
Loading