21
21
use core \context \course ;
22
22
use core \context \module ;
23
23
use local_smartmedia \conversion ;
24
+ use filter_smartmedia \text_filter ;
24
25
25
26
defined ('MOODLE_INTERNAL ' ) || die ();
26
27
27
28
global $ CFG ;
28
- require_once ($ CFG ->dirroot . '/filter/smartmedia/filter.php ' ); // Include the code to test.
29
29
30
30
/**
31
- * Unit test for the filter_smartmedia
31
+ * Unit test for the text_filter
32
32
*
33
33
* @package filter_smartmedia
34
34
* @copyright 2019 Matt Porritt <mattp@catalyst-au.net>
@@ -63,10 +63,10 @@ public function setUp(): void {
63
63
public function test_videojs_enabled_true (): void {
64
64
$ this ->resetAfterTest (true );
65
65
66
- $ filterplugin = new filter_smartmedia (null , []);
66
+ $ filterplugin = new text_filter (null , []);
67
67
68
68
// We're testing a private method, so we need to setup reflector magic.
69
- $ method = new ReflectionMethod ('filter_smartmedia ' , 'videojs_enabled ' );
69
+ $ method = new ReflectionMethod ('\ filter_smartmedia\text_filter ' , 'videojs_enabled ' );
70
70
$ method ->setAccessible (true ); // Allow accessing of private method.
71
71
$ proxy = $ method ->invoke ($ filterplugin ); // Get result of invoked method.
72
72
@@ -82,10 +82,10 @@ public function test_videojs_enabled_false(): void {
82
82
// Only enable the HTML5 video player not video.js.
83
83
media::set_enabled_plugins ('html5video ' );
84
84
85
- $ filterplugin = new filter_smartmedia (null , []);
85
+ $ filterplugin = new text_filter (null , []);
86
86
87
87
// We're testing a private method, so we need to setup reflector magic.
88
- $ method = new ReflectionMethod ('filter_smartmedia ' , 'videojs_enabled ' );
88
+ $ method = new ReflectionMethod ('\ filter_smartmedia\text_filter ' , 'videojs_enabled ' );
89
89
$ method ->setAccessible (true ); // Allow accessing of private method.
90
90
$ proxy = $ method ->invoke ($ filterplugin ); // Get result of invoked method.
91
91
@@ -98,12 +98,12 @@ public function test_videojs_enabled_false(): void {
98
98
*/
99
99
public function test_get_smart_elements_no_smart (): void {
100
100
$ this ->resetAfterTest (true );
101
- $ filterplugin = new filter_smartmedia (null , []);
101
+ $ filterplugin = new text_filter (null , []);
102
102
103
103
$ linkhref = 'http://moodle.local/pluginfile.php/1461/mod_label/intro/SampleVideo1mb.mp4 ' ;
104
104
105
105
// We're testing a private method, so we need to setup reflector magic.
106
- $ method = new ReflectionMethod ('filter_smartmedia ' , 'get_smart_elements ' );
106
+ $ method = new ReflectionMethod ('\ filter_smartmedia\text_filter ' , 'get_smart_elements ' );
107
107
$ method ->setAccessible (true ); // Allow accessing of private method.
108
108
list ($ context , $ proxy ) = $ method ->invoke ($ filterplugin , $ linkhref ); // Get result of invoked method.
109
109
@@ -113,7 +113,7 @@ public function test_get_smart_elements_no_smart(): void {
113
113
114
114
public function test_get_embed_markup_simple (): void {
115
115
$ this ->resetAfterTest (true );
116
- $ filterplugin = new filter_smartmedia (null , []);
116
+ $ filterplugin = new text_filter (null , []);
117
117
118
118
$ linkhref = 'http://moodle.local/pluginfile.php/1461/mod_label/intro/OriginalVideo.mp4 ' ;
119
119
$ urls = [new url ('http://moodle.local/pluginfile.php/1461/mod_label/intro/SampleVideo1mb.m3u8 ' )];
@@ -128,7 +128,7 @@ public function test_get_embed_markup_simple(): void {
128
128
];
129
129
130
130
// We're testing a private method, so we need to setup reflector magic.
131
- $ method = new ReflectionMethod ('filter_smartmedia ' , 'get_embed_markup ' );
131
+ $ method = new ReflectionMethod ('\ filter_smartmedia\text_filter ' , 'get_embed_markup ' );
132
132
$ method ->setAccessible (true ); // Allow accessing of private method.
133
133
$ proxy = $ method ->invoke ($ filterplugin , $ linkhref , $ urls , $ options , $ download , false ); // Get result of invoked method.
134
134
@@ -142,9 +142,9 @@ public function test_get_embed_markup_simple(): void {
142
142
* There is no valid tags to replace.
143
143
* Output next should be the same as input text.
144
144
*/
145
- public function test_filter_smartmedia_filter_no_replace (): void {
145
+ public function test_text_filter_filter_no_replace (): void {
146
146
$ this ->resetAfterTest (true );
147
- $ filterplugin = new filter_smartmedia (null , []);
147
+ $ filterplugin = new text_filter (null , []);
148
148
149
149
$ inputtext = '<div class="no-overflow"> '
150
150
.'<a href="#">Some test data</a> '
@@ -162,7 +162,7 @@ public function test_get_placeholder_markkup(): void {
162
162
$ this ->resetAfterTest (true );
163
163
164
164
global $ DB ;
165
- $ filterplugin = new filter_smartmedia (null , []);
165
+ $ filterplugin = new text_filter (null , []);
166
166
167
167
$ linkhref = 'http://moodle.local/pluginfile.php/1461/mod_label/intro/SampleVideo1mb.avi ' ;
168
168
$ fulltext = '<div class="no-overflow"> '
@@ -239,7 +239,7 @@ public function test_get_placeholder_markkup(): void {
239
239
$ initialfilerecord2 ['itemid ' ], $ initialfilerecord2 ['filepath ' ], $ initialfilerecord2 ['filename ' ]);
240
240
241
241
// We're testing a private method, so we need to setup reflector magic.
242
- $ method = new ReflectionMethod ('filter_smartmedia ' , 'get_placeholder_markup ' );
242
+ $ method = new ReflectionMethod ('\ filter_smartmedia\text_filter ' , 'get_placeholder_markup ' );
243
243
$ method ->setAccessible (true ); // Allow accessing of private method.
244
244
245
245
$ proxy = $ method ->invoke ($ filterplugin , $ linkhref , $ fulltext ); // Get result of invoked method.
@@ -514,7 +514,7 @@ public function test_filter_replace($text, $regex, $matchcount, $mediaplugincoun
514
514
]);
515
515
$ PAGE ->set_url (new url ($ pageurl ));
516
516
517
- $ filterplugin = new filter_smartmedia (null , [], $ conversion );
517
+ $ filterplugin = new text_filter (null , [], $ conversion );
518
518
$ result = $ filterplugin ->filter ($ text );
519
519
$ this ->assertEquals ($ matchcount , preg_match_all ($ regex , $ result ));
520
520
@@ -545,7 +545,7 @@ public function test_view_source(): void {
545
545
]);
546
546
$ PAGE ->set_url (new url ("/my/ " ));
547
547
548
- $ filterplugin = new filter_smartmedia (null , [], $ conversion );
548
+ $ filterplugin = new text_filter (null , [], $ conversion );
549
549
$ text = '<div><div><video><source src="url.com/pluginfile.php/fake.mp4"/></video></div></div> ' ;
550
550
$ result = $ filterplugin ->filter ($ text );
551
551
$ this ->assertMatchesRegularExpression ('/<button.*View source media.*<\/button>/ ' , $ result );
@@ -570,7 +570,7 @@ public function test_view_optimised(): void {
570
570
$ text = '<div><div><video><source src="url.com/pluginfile.php/fake.mp4"/></video></div></div> ' ;
571
571
$ SESSION ->local_smartmedia_viewsource = [sha1 ('url.com/pluginfile.php/fake.mp4 ' ) => true ];
572
572
573
- $ filterplugin = new filter_smartmedia (null , [], $ conversion );
573
+ $ filterplugin = new text_filter (null , [], $ conversion );
574
574
$ result = $ filterplugin ->filter ($ text );
575
575
$ this ->assertMatchesRegularExpression ('/<button.*View optimised media.*<\/button>/ ' , $ result );
576
576
}
0 commit comments