-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
196 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
plugin/videojs/tests/behat/videotimeplugin_videojs_settings.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@mod @mod_videotime @videotimeplugin_videojs | ||
Feature: Configure videojs settings | ||
In use a video assignment I need to control settings | ||
As an admin | ||
I need to adjust player options | ||
|
||
Background: | ||
Given the following "courses" exist: | ||
| shortname | fullname | | ||
| C1 | Course 1 | | ||
And the following "users" exist: | ||
| username | firstname | | ||
| teacher | Teacher | | ||
| student | Student | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| teacher | C1 | editingteacher | | ||
| student | C1 | student | | ||
And the following "activities" exist: | ||
| activity | name | course | vimeo_url | label_mode | section | controls | | ||
| videotime | Video Time with controls | C1 | https://www.youtube.com/watch?v=dQw4w9WgXcQ | 0 | 1 | 1 | | ||
| videotime | Video Time with no controls | C1 | https://www.youtube.com/watch?v=dQw4w9WgXcQ | 0 | 1 | 0 | | ||
|
||
@javascript | ||
Scenario: Force control setting on | ||
Given the following config values are set as admin: | ||
| forced | controls | videotimeplugin_videojs | | ||
| controls | 1 | videotimeplugin_videojs | | ||
When I am on the "Video Time with no controls" "mod_videotime > Embed options" page logged in as "teacher" | ||
Then I should see "Controls is globally forced to: Yes" | ||
|
||
@javascript | ||
Scenario: Force control setting off on embed settings page | ||
Given the following config values are set as admin: | ||
| forced | controls | videotimeplugin_videojs | | ||
| controls | 0 | videotimeplugin_videojs | | ||
When I am on the "Video Time with no controls" "mod_videotime > Embed options" page logged in as "teacher" | ||
Then I should see "Controls is globally forced to: No" | ||
|
||
@javascript | ||
Scenario: Force control setting off on activity page | ||
Given the following config values are set as admin: | ||
| forced | controls | videotimeplugin_videojs | | ||
| controls | 0 | videotimeplugin_videojs | | ||
When I am on the "Video Time with controls" "videotime activity" page logged in as "teacher" | ||
And I wait "3" seconds | ||
And I switch to "" class iframe | ||
Then "Play" "button" should not be visible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Video Time Vimeo force settings test | ||
* | ||
* @package videotimeplugin_videojs | ||
* @copyright 2023 bdecent gmbh <https://bdecent.de> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace videotimeplugin_videojs; | ||
|
||
use advanced_testcase; | ||
use mod_videotime\videotime_instance; | ||
|
||
/** | ||
* Class force_settings_test | ||
* | ||
* @group videotimeplugin_videojs | ||
* @covers \mod_videotime\videotime_instance | ||
*/ | ||
class force_settings_test extends advanced_testcase { | ||
|
||
/** | ||
* @var stdClass $course | ||
*/ | ||
private $course; | ||
/** | ||
* @var stdClass $instancerecord | ||
*/ | ||
private $instancerecord; | ||
|
||
/** | ||
* @var videotime_instance | ||
*/ | ||
private $videotimeinstance; | ||
|
||
/** | ||
* Set up | ||
*/ | ||
public function setUp() : void { | ||
$this->resetAfterTest(); | ||
|
||
$this->course = $this->getDataGenerator()->create_course(); | ||
$this->instancerecord = $this->getDataGenerator()->create_module('videotime', [ | ||
'course' => $this->course->id, | ||
'controls' => 0, | ||
'vimeo_url' => 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', | ||
]); | ||
$this->videotimeinstance = videotime_instance::instance_by_id($this->instancerecord->id); | ||
} | ||
|
||
/** | ||
* Tear down data | ||
*/ | ||
public function tearDown() : void { | ||
$this->course = null; | ||
$this->instancerecord = null; | ||
$this->videotimeinstance = null; | ||
} | ||
|
||
/** | ||
* Force setting test | ||
*/ | ||
public function test_disable_options() { | ||
$this->assertIsArray($this->videotimeinstance->get_force_settings()); | ||
$this->assertFalse(in_array(1, $this->videotimeinstance->get_force_settings())); | ||
|
||
set_config('enabled', 1, 'videotimeplugin_videojs'); | ||
foreach ($this->get_options() as $option) { | ||
set_config($option, 0, 'videotimeplugin_videojs'); | ||
set_config('forced', $option, 'videotimeplugin_videojs'); | ||
|
||
$this->videotimeinstance = videotime_instance::instance_by_id($this->instancerecord->id); | ||
|
||
$this->assertNotEmpty($this->videotimeinstance->to_record()); | ||
$this->assertEquals(0, $this->videotimeinstance->to_record()->$option); | ||
} | ||
} | ||
|
||
/** | ||
* Force setting test | ||
*/ | ||
public function test_enable_controls() { | ||
$this->assertIsArray($this->videotimeinstance->get_force_settings()); | ||
$this->assertFalse(in_array(1, $this->videotimeinstance->get_force_settings())); | ||
|
||
set_config('enabled', 1, 'videotimeplugin_videojs'); | ||
foreach ($this->get_options() as $option) { | ||
set_config($option, 1, 'videotimeplugin_videojs'); | ||
set_config('forced', $option, 'videotimeplugin_videojs'); | ||
|
||
$this->videotimeinstance = videotime_instance::instance_by_id($this->instancerecord->id); | ||
|
||
$this->assertNotEmpty($this->videotimeinstance->to_record()); | ||
$this->assertEquals(1, $this->videotimeinstance->to_record()->$option); | ||
} | ||
} | ||
|
||
/** | ||
* Get supported options | ||
* | ||
* @return array | ||
*/ | ||
public function get_options() { | ||
return [ | ||
'autoplay', | ||
'controls', | ||
'muted', | ||
'option_loop', | ||
'playsinline', | ||
'responsive', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters