weekly release 3.0dev
[moodle.git] / lib / tests / useragent_test.php
CommitLineData
c3d2fbf9
SH
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Tests the user agent class.
19 *
20 * @package core
21 * @copyright 2013 Sam Hemelryk
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * User agent test suite.
27 *
28 * @package core
29 * @copyright 2013 Sam Hemelryk
30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31 */
32class core_useragent_testcase extends basic_testcase {
33
7c10ad33 34 public function user_agents_providers() {
96a54631
AN
35 // Note: When adding new entries to this list, please ensure that any new browser versions are added to the corresponding list.
36 // This ensures that regression tests are applied to all known user agents.
7c10ad33
AN
37 return array(
38 // Windows 98; Internet Explorer 5.0.
39 array(
40 'Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)',
41 array(
42 // MSIE 5.0 is not considered a browser at all: known false results.
43 'is_ie' => false,
44 'check_ie_version' => array(
45 '0' => true,
46 '5.0' => true,
47 ),
48 'versionclasses' => array(
49 // IE 5.0 is not considered a browser.
50 ),
51
52 // IE 5.0 is a legacy browser.
96a54631 53 'devicetype' => 'legacy',
7c10ad33
AN
54
55 'supports_svg' => false,
83af1329 56 'supports_json_contenttype' => false,
7c10ad33 57 ),
c3d2fbf9 58 ),
7c10ad33
AN
59
60 // Windows 2000; Internet Explorer 5.5.
61 array(
62 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)',
63 array(
64 'is_ie' => true,
65 'check_ie_version' => array(
66 '0' => true,
67 '5.0' => true,
68 '5.5' => true,
69 ),
70 'versionclasses' => array(
71 'ie',
72 ),
73
74 // IE 6.0 is a legacy browser.
96a54631 75 'devicetype' => 'legacy',
7c10ad33
AN
76
77 'supports_svg' => false,
83af1329 78 'supports_json_contenttype' => false,
7c10ad33 79 ),
c3d2fbf9 80 ),
7c10ad33
AN
81
82 // Windows XP SP2; Internet Explorer 6.0.
83 array(
84 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
85 array(
86 'is_ie' => true,
87 'check_ie_version' => array(
88 '0' => true,
89 '5.0' => true,
90 '5.5' => true,
91 '6.0' => true,
92 ),
93 'versionclasses' => array(
94 'ie',
95 'ie6',
96 ),
97
98 // IE 7.0 is a legacy browser.
99 'devicetype' => 'legacy',
100
101 'supports_svg' => false,
83af1329 102 'supports_json_contenttype' => false,
7c10ad33 103 ),
c3d2fbf9 104 ),
7c10ad33
AN
105
106 // Windows XP SP2; Internet Explorer 7.0.
107 array(
108 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
109 array(
110 'is_ie' => true,
111 'check_ie_version' => array(
112 '0' => true,
113 '5.0' => true,
114 '5.5' => true,
115 '6.0' => true,
116 '7.0' => true,
117 ),
118 'versionclasses' => array(
119 'ie',
120 'ie7',
121 ),
122
123 'supports_svg' => false,
83af1329 124 'supports_json_contenttype' => false,
7c10ad33 125 ),
c3d2fbf9 126 ),
7c10ad33
AN
127
128 // Windows XP SP2; Internet Explorer 7.0; Meridio extension.
129 array(
130 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Meridio for Excel 5.0.251; Meridio for PowerPoint 5.0.251; Meridio for Word 5.0.251; Meridio Protocol; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)',
131 array(
132 'is_ie' => true,
133 'check_ie_version' => array(
134 '0' => true,
135 '5.0' => true,
136 '5.5' => true,
137 '6.0' => true,
138 '7.0' => true,
139 ),
140 'versionclasses' => array(
141 'ie',
142 'ie7',
143 ),
144
145 'supports_svg' => false,
83af1329 146 'supports_json_contenttype' => false,
7c10ad33 147 ),
d2fdad7c 148 ),
7c10ad33
AN
149
150 // Windows Vista; Internet Explorer 8.0.
151 array(
152 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)',
153 array(
154 'is_ie' => true,
155 'check_ie_version' => array(
156 '0' => true,
157 '5.0' => true,
158 '5.5' => true,
159 '6.0' => true,
160 '7.0' => true,
161 '8.0' => true,
162 ),
7c10ad33
AN
163 'versionclasses' => array(
164 'ie',
165 'ie8',
166 ),
167
168 'supports_svg' => false,
169 ),
c3d2fbf9 170 ),
7c10ad33
AN
171
172 // Windows 7; Internet Explorer 9.0.
173 array(
174 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
175 array(
176 'is_ie' => true,
177 'check_ie_version' => array(
178 '0' => true,
179 '5.0' => true,
180 '5.5' => true,
181 '6.0' => true,
182 '7.0' => true,
183 '8.0' => true,
184 '9.0' => true,
185 ),
186 'versionclasses' => array(
187 'ie',
188 'ie9',
189 ),
190 ),
c3d2fbf9 191 ),
7c10ad33
AN
192
193 // Windows 7; Internet Explorer 9.0i.
194 array(
195 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)',
196 array(
197 'is_ie' => true,
198 'check_ie_version' => array(
199 '0' => true,
200 '5.0' => true,
201 '5.5' => true,
202 '6.0' => true,
203 '7.0' => true,
204 '8.0' => true,
205 '9.0' => true,
206 ),
207 'versionclasses' => array(
208 'ie',
209 'ie9',
210 ),
211 'iecompatibility' => true,
212
213 // IE 9 in Compatiblity mode does not support SVG.
214 'supports_svg' => false,
83af1329
AN
215
216 // IE in Compatiblity mode does not support JSON ContentType.
217 'supports_json_contenttype' => false,
7c10ad33 218 ),
c3d2fbf9 219 ),
7c10ad33
AN
220
221 // Windows 8; Internet Explorer 10.0.
222 array(
223 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)',
224 array(
225 'is_ie' => true,
226 'check_ie_version' => array(
227 '0' => true,
228 '5.0' => true,
229 '5.5' => true,
230 '6.0' => true,
231 '7.0' => true,
232 '8.0' => true,
233 '9.0' => true,
234 '10' => true,
235 ),
236 'versionclasses' => array(
237 'ie',
238 'ie10',
239 ),
240 ),
c3d2fbf9 241 ),
c3d2fbf9 242
7c10ad33
AN
243 // Windows 8; Internet Explorer 10.0i.
244 array(
245 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)',
246 array(
247 'is_ie' => true,
248 'check_ie_version' => array(
249 '0' => true,
250 '5.0' => true,
251 '5.5' => true,
252 '6.0' => true,
253 '7.0' => true,
254 '8.0' => true,
255 '9.0' => true,
256 '10' => true,
257 ),
258 'iecompatibility' => true,
259 'versionclasses' => array(
260 'ie',
261 'ie10',
262 ),
83af1329
AN
263
264 // IE in Compatiblity mode does not support JSON ContentType.
265 'supports_json_contenttype' => false,
7c10ad33
AN
266 ),
267 ),
c3d2fbf9 268
7c10ad33
AN
269 // Windows 8.1; Internet Explorer 11.0.
270 array(
271 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0)',
272 array(
273 'is_ie' => true,
274 'check_ie_version' => array(
275 '0' => true,
276 '5.0' => true,
277 '5.5' => true,
278 '6.0' => true,
279 '7.0' => true,
280 '8.0' => true,
281 '9.0' => true,
282 '10' => true,
283 '11' => true,
284 ),
285 'versionclasses' => array(
286 'ie',
287 'ie11',
288 ),
289 ),
290 ),
c3d2fbf9 291
7c10ad33
AN
292 // Windows 8.1; Internet Explorer 11.0i.
293 array(
294 ' Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)',
295 array(
296 'is_ie' => true,
297 'check_ie_version' => array(
298 '0' => true,
299 '5.0' => true,
300 '5.5' => true,
301 '6.0' => true,
302 '7.0' => true,
303 '8.0' => true,
304 '9.0' => true,
305 '10' => true,
306 '11' => true,
307 ),
308 'iecompatibility' => true,
309 'versionclasses' => array(
310 'ie',
311 'ie11',
312 ),
83af1329
AN
313
314 // IE in Compatiblity mode does not support JSON ContentType.
315 'supports_json_contenttype' => false,
7c10ad33
AN
316 ),
317 ),
318
319 // Windows XP; Firefox 1.0.6.
320 array(
321 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6',
322 array(
323 'is_firefox' => true,
324
325 'is_gecko' => true,
326 'check_gecko_version' => array(
327 '1' => true,
328 ),
329
330 'versionclasses' => array(
331 'gecko',
332 'gecko17',
333 ),
334 ),
335 ),
336
337 // Windows XP; Firefox 1.0.6.
338 array(
339 'Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8) Gecko/20051107 Firefox/1.5',
340 array(
341 'is_firefox' => true,
342 'check_firefox_version' => array(
343 '1.5' => true,
344 ),
345
346 'is_gecko' => true,
347 'check_gecko_version' => array(
348 '1' => true,
349 '20030516' => true,
350 '20051116' => true,
351 ),
352
353 'versionclasses' => array(
354 'gecko',
355 'gecko18',
356 ),
357 ),
358 ),
359
360 // Windows XP; Firefox 1.5.0.1.
361 array(
362 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1',
363 array(
364 'is_firefox' => true,
365 'check_firefox_version' => array(
366 '1.5' => true,
367 ),
368
369 'is_gecko' => true,
370 'check_gecko_version' => array(
371 '1' => true,
372 '20030516' => true,
373 '20051116' => true,
374 ),
375
376 'versionclasses' => array(
377 'gecko',
378 'gecko18',
379 ),
380 ),
381 ),
382
383 // Windows XP; Firefox 2.0.
384 array(
385 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1',
386 array(
387 'is_firefox' => true,
388 'check_firefox_version' => array(
389 '1.5' => true,
390 ),
391
392 'is_gecko' => true,
393 'check_gecko_version' => array(
394 '1' => true,
395 '2' => true,
396 '20030516' => true,
397 '20051116' => true,
398 '2006010100' => true,
399 ),
400
401 'versionclasses' => array(
402 'gecko',
403 'gecko18',
404 ),
405 ),
406 ),
407
408 // Ubuntu Linux amd64; Firefox 2.0.
409 array(
410 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)',
411 array(
412 'is_firefox' => true,
413 'check_firefox_version' => array(
414 '1.5' => true,
415 ),
416
417 'is_gecko' => true,
418 'check_gecko_version' => array(
419 '1' => true,
420 '2' => true,
421 '20030516' => true,
422 '20051116' => true,
423 '2006010100' => true,
424 ),
425
426 'versionclasses' => array(
427 'gecko',
428 'gecko18',
429 ),
430 ),
431 ),
432
433 // SUSE; Firefox 3.0.6.
434 array(
435 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-1.4 Firefox/3.0.6',
436 array(
437 'is_firefox' => true,
438 'check_firefox_version' => array(
439 '1.5' => true,
440 '3.0' => true,
441 ),
442
443 'is_gecko' => true,
444 'check_gecko_version' => array(
445 '1' => true,
446 '2' => true,
447 '20030516' => true,
448 '20051116' => true,
449 '2006010100' => true,
450 ),
451
452 'versionclasses' => array(
453 'gecko',
454 'gecko19',
455 ),
456 ),
457 ),
458
459 // Linux i686; Firefox 3.6.
460 array(
461 'Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/3.6',
462 array(
463 'is_firefox' => true,
464 'check_firefox_version' => array(
465 '1.5' => true,
466 '3.0' => true,
467 ),
468
469 'is_gecko' => true,
470 'check_gecko_version' => array(
471 '1' => true,
472 '2' => true,
473 '20030516' => true,
474 '20051116' => true,
475 '2006010100' => true,
476 '3.6' => true,
5ee4f581 477 '20100101' => true,
7c10ad33
AN
478 ),
479
480 'versionclasses' => array(
481 'gecko',
482 'gecko20',
483 ),
484 ),
485 ),
486
487 // Windows; Firefox 11.0.
488 array(
489 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko Firefox/11.0',
490 array(
491 'is_firefox' => true,
492 'check_firefox_version' => array(
493 '1.5' => true,
494 '3.0' => true,
495 '4' => true,
496 '10' => true,
497 ),
498
499 'is_gecko' => true,
500 'check_gecko_version' => array(
501 '1' => true,
502 '2' => true,
503 '20030516' => true,
504 '20051116' => true,
505 '2006010100' => true,
5ee4f581 506 '20100101' => true,
7c10ad33
AN
507 '3.6' => true,
508 '4.0' => true,
509 ),
510
511 'versionclasses' => array(
512 'gecko',
513 ),
514 ),
515 ),
516
517 // Windows; Firefox 15.0a2.
518 array(
519 'Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0a2',
520 array(
521 'is_firefox' => true,
522 'check_firefox_version' => array(
523 '1.5' => true,
524 '3.0' => true,
525 '4' => true,
526 '10' => true,
527 '15' => true,
528 ),
529
530 'is_gecko' => true,
531 'check_gecko_version' => array(
532 '1' => true,
533 '2' => true,
534 '20030516' => true,
535 '20051116' => true,
536 '2006010100' => true,
5ee4f581 537 '20100101' => true,
7c10ad33
AN
538 '3.6' => true,
539 '4.0' => true,
540 '15.0' => true,
541 ),
542
543 'versionclasses' => array(
544 'gecko',
545 ),
546 ),
547 ),
548
549 // Firefox 18; Mac OS X 10.
550 array(
551 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:18.0) Gecko/18.0 Firefox/18.0',
552 array(
553 'is_firefox' => true,
554 'check_firefox_version' => array(
555 '1.5' => true,
556 '3.0' => true,
557 '4' => true,
558 '10' => true,
559 '15' => true,
560 '18' => true,
561 ),
562
563 'is_gecko' => true,
564 'check_gecko_version' => array(
565 '1' => true,
566 '2' => true,
567 '20030516' => true,
568 '20051116' => true,
569 '2006010100' => true,
570 '3.6' => true,
571 '4.0' => true,
572 '15.0' => true,
573 '18.0' => true,
5ee4f581
AN
574 '20100101' => true,
575 ),
576
577 'versionclasses' => array(
578 'gecko',
579 ),
580 ),
581 ),
582
583 // Firefox 33; Mac OS X 10.10.
584 array(
585 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:33.0) Gecko/20100101 Firefox/33.0',
586 array(
587 'is_firefox' => true,
588 'check_firefox_version' => array(
589 '1.5' => true,
590 '3.0' => true,
591 '4' => true,
592 '10' => true,
593 '15' => true,
594 '18' => true,
595 '19' => true,
596 '33' => true,
597 ),
598
599 'is_gecko' => true,
600 'check_gecko_version' => array(
601 '1' => true,
602 '2' => true,
603 '20030516' => true,
604 '20051116' => true,
605 '2006010100' => true,
606 '3.6' => true,
607 '4.0' => true,
608 '15.0' => true,
609 '18.0' => true,
610 '19.0' => true,
611 '20100101' => true,
7c10ad33
AN
612 ),
613
614 'versionclasses' => array(
615 'gecko',
616 ),
617 ),
618 ),
619
620 // SeaMonkey 2.0; Windows.
621 array(
622 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1b3pre) Gecko/20081208 SeaMonkey/2.0',
623 array(
624 'is_gecko' => true,
625 'check_gecko_version' => array(
626 '1' => true,
627 '2' => true,
628 '20030516' => true,
629 '20051106' => true,
630 '20051116' => true,
631 '2006010100' => true,
632 ),
633
634 'versionclasses' => array(
635 'gecko',
636 'gecko19',
637 ),
638 ),
639 ),
640
641 // SeaMonkey 2.1; Linux.
642 array(
643 'Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20110609 Firefox/4.0.1 SeaMonkey/2.1',
644 array(
645 'is_gecko' => true,
646 'check_gecko_version' => array(
647 '1' => true,
648 '2' => true,
649 '20030516' => true,
650 '20051116' => true,
651 '2006010100' => true,
5ee4f581 652 '20100101' => true,
7c10ad33
AN
653 '3.6' => true,
654 '4.0' => true,
655 ),
656
657 'is_firefox' => true,
658 'check_firefox_version' => array(
659 '1.5' => true,
660 '3.0' => true,
661 '4' => true,
662 ),
663
664 'versionclasses' => array(
665 'gecko',
666 'gecko20',
667 ),
668 ),
669 ),
670
671 // SeaMonkey 2.3; FreeBSD.
672 array(
673 'Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0) Gecko/20110818 Firefox/6.0 SeaMonkey/2.3',
674 array(
675 'is_gecko' => true,
676 'check_gecko_version' => array(
677 '1' => true,
678 '2' => true,
679 '20030516' => true,
680 '20051116' => true,
681 '2006010100' => true,
5ee4f581 682 '20100101' => true,
7c10ad33
AN
683 '3.6' => true,
684 '4.0' => true,
685 ),
686
687 'is_firefox' => true,
688 'check_firefox_version' => array(
689 '1.5' => true,
690 '3.0' => true,
691 '4' => true,
692 ),
693
694 'versionclasses' => array(
695 'gecko',
696 ),
697 ),
698 ),
699
700 // Windows 7; MS Word 2010.
701 array(
702 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; ms-office)',
703 array(
704 'is_ie' => true,
705 'check_ie_version' => array(
706 '0' => true,
707 '5.0' => true,
708 '5.5' => true,
709 '6.0' => true,
710 '7.0' => true,
711 '8.0' => true,
712 ),
713 'iecompatibility' => true,
714 'versionclasses' => array(
715 'ie',
716 'ie8',
717 ),
718
719 'is_msword' => true,
720
721 'supports_svg' => false,
83af1329 722 'supports_json_contenttype' => false,
7c10ad33
AN
723 ),
724 ),
725
726 // Windows 7; MS Outlook 2010.
727 array(
728 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Microsoft Outlook 14.0.7113; ms-office; MSOffice 14)',
729 array(
730 'is_ie' => true,
731 'check_ie_version' => array(
732 '0' => true,
733 '5.0' => true,
734 '5.5' => true,
735 '6.0' => true,
736 '7.0' => true,
737 '8.0' => true,
738 ),
739 'iecompatibility' => true,
740 'versionclasses' => array(
741 'ie',
742 'ie8',
743 ),
744
745 // Note: Outlook is deliberately not considered to be MS Word.
746 'is_msword' => false,
747
748 'supports_svg' => false,
83af1329 749 'supports_json_contenttype' => false,
7c10ad33
AN
750 ),
751 ),
752
753 // Mac OS X; MS Word 14.
754 array(
755 'Mozilla/5.0 (Macintosh; Intel Mac OS X) Word/14.38.0',
756 array(
757 'versionclasses' => array(
758 ),
759
760 'is_msword' => true,
761 ),
762 ),
763
764 // Safari 312; Max OS X.
765 array(
766 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312',
767 array(
768 'is_safari' => true,
769 'check_safari_version' => array(
770 '1' => true,
771 '312' => true,
772 ),
773
774 'is_webkit' => true,
775
776 'versionclasses' => array(
777 'safari',
778 ),
779 ),
780 ),
781
782 // Safari 412; Max OS X.
783 array(
784 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412',
785 array(
786 'is_safari' => true,
787 'check_safari_version' => array(
788 '1' => true,
789 '312' => true,
790 ),
791
792 'is_webkit' => true,
793
794 'versionclasses' => array(
795 'safari',
796 ),
797 ),
798 ),
657a94fc 799
7c10ad33
AN
800 // Safari 2.0; Max OS X.
801 array(
802 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412',
803 array(
804 'is_safari' => true,
805 'check_safari_version' => array(
806 '1' => true,
807 '312' => true,
808 ),
809
810 'is_webkit' => true,
811
812 'versionclasses' => array(
813 'safari',
814 ),
815 ),
816 ),
657a94fc 817
7c10ad33
AN
818 // iOS Safari 528; iPhone.
819 array(
820 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; cs-cz) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16',
821 array(
822 // Note: We do *not* identify mobile Safari as Safari.
823 'is_safari_ios' => true,
824 'check_safari_ios_version' => array(
825 '527' => true,
826 ),
827
828 'is_webkit' => true,
829
830 'versionclasses' => array(
831 'safari',
832 'ios',
833 ),
834
835 'devicetype' => 'mobile',
836 ),
837 ),
657a94fc 838
5ee4f581
AN
839 // Safari; iPhone 6 Plus; iOS 8.1; Build 12B411.
840 array(
841 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_10 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4',
842 array(
843 // Note: We do *not* identify mobile Safari as Safari.
844 'is_safari_ios' => true,
845 'check_safari_ios_version' => array(
846 '527' => true,
847 '590' => true,
848 '600' => true,
849 ),
850
851 'is_webkit' => true,
852
853 'versionclasses' => array(
854 'safari',
855 'ios',
856 ),
857
858 'devicetype' => 'mobile',
859 ),
860 ),
861
7c10ad33
AN
862 // iOS Safari 533; iPad.
863 array(
864 'Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5',
865 array(
866 // Note: We do *not* identify mobile Safari as Safari.
867 'is_safari_ios' => true,
868 'check_safari_ios_version' => array(
869 '527' => true,
870 ),
871
872 'is_webkit' => true,
873
874 'versionclasses' => array(
875 'safari',
876 'ios',
877 ),
878
879 'devicetype' => 'tablet',
880 ),
881 ),
657a94fc 882
7c10ad33
AN
883 // Android WebKit 525; G1 Phone.
884 array(
885 'Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2 – G1 Phone',
886 array(
887 'is_webkit_android' => true,
888 'check_webkit_android_version' => array(
889 '525' => true,
890 ),
657a94fc 891
7c10ad33 892 'is_webkit' => true,
657a94fc 893
7c10ad33
AN
894 'versionclasses' => array(
895 'android',
896 'safari',
897 ),
657a94fc 898
7c10ad33 899 'devicetype' => 'mobile',
657a94fc 900
7c10ad33
AN
901 'supports_svg' => false,
902 ),
903 ),
657a94fc 904
7c10ad33
AN
905 // Android WebKit 530; Nexus.
906 array(
907 'Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 –Nexus',
908 array(
909 'is_webkit_android' => true,
910 'check_webkit_android_version' => array(
911 '525' => true,
912 '527' => true,
913 ),
657a94fc 914
7c10ad33 915 'is_webkit' => true,
657a94fc 916
7c10ad33
AN
917 'versionclasses' => array(
918 'android',
919 'safari',
920 ),
657a94fc 921
7c10ad33 922 'devicetype' => 'mobile',
657a94fc 923
7c10ad33
AN
924 'supports_svg' => false,
925 ),
926 ),
657a94fc 927
7c10ad33
AN
928 // Android WebKit 537; Samsung GT-9505.
929 array(
930 'Mozilla/5.0 (Linux; Android 4.3; it-it; SAMSUNG GT-I9505/I9505XXUEMJ7 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36',
931 array(
932 'is_webkit_android' => true,
933 'check_webkit_android_version' => array(
934 '525' => true,
935 '527' => true,
936 ),
937
938 'is_webkit' => true,
939
940 'is_chrome' => true,
941 'check_chrome_version' => array(
942 '7' => true,
943 '8' => true,
944 '10' => true,
945 ),
946
947 'versionclasses' => array(
948 'safari',
949 'android',
950 ),
951
952 'devicetype' => 'mobile',
953 ),
954 ),
955
956 // Android WebKit 537; Nexus 5.
957 array(
958 'Mozilla/5.0 (Linux; Android 5.0; Nexus 5 Build/LPX13D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.102 Mobile Safari/537.36',
959 array(
960 'is_webkit_android' => true,
961 'check_webkit_android_version' => array(
962 '525' => true,
963 '527' => true,
964 ),
965
966 'is_webkit' => true,
967
968 'is_chrome' => true,
969 'check_chrome_version' => array(
970 '7' => true,
971 '8' => true,
972 '10' => true,
973 ),
974
975 'versionclasses' => array(
976 'safari',
977 'android',
978 ),
979
980 'devicetype' => 'mobile',
981 ),
982 ),
983
984 // Chrome 8; Mac OS X.
985 array(
986 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.215 Safari/534.10',
987 array(
988 'is_chrome' => true,
989 'check_chrome_version' => array(
990 '7' => true,
991 '8' => true,
992 ),
993
994 'is_webkit' => true,
995
996 'versionclasses' => array(
997 'safari',
998 ),
999 ),
1000 ),
1001
5ee4f581
AN
1002 // Chrome 39; Mac OS X.
1003 array(
1004 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36',
1005 array(
1006 'is_chrome' => true,
1007 'check_chrome_version' => array(
1008 '7' => true,
1009 '8' => true,
1010 '10' => true,
1011 '39' => true,
1012 ),
1013
1014 'is_webkit' => true,
1015
1016 'versionclasses' => array(
1017 'safari',
1018 ),
1019 ),
1020 ),
1021
7c10ad33
AN
1022 // Opera 8.51; Windows XP.
1023 array(
1024 'Opera/8.51 (Windows NT 5.1; U; en)',
1025 array(
1026 'is_opera' => true,
1027 'check_opera_version' => array(
1028 '8.0' => true,
1029 ),
1030
1031 'versionclasses' => array(
1032 'opera',
1033 ),
1034
1035 'supports_svg' => false,
1036 ),
1037 ),
657a94fc 1038
7c10ad33
AN
1039 // Opera 9.0; Windows XP.
1040 array(
1041 'Opera/9.0 (Windows NT 5.1; U; en)',
1042 array(
1043 'is_opera' => true,
1044 'check_opera_version' => array(
1045 '8.0' => true,
5ee4f581
AN
1046 '9.0' => true,
1047 ),
1048
1049 'versionclasses' => array(
1050 'opera',
1051 ),
1052
1053 'supports_svg' => false,
1054 ),
1055 ),
1056
1057 // Opera 12.15 (Build 1748); Mac OS X.
1058 array(
1059 'Opera/9.80 (Macintosh; Intel Mac OS X 10.10.0; Edition MAS) Presto/2.12.388 Version/12.15',
1060 array(
1061 'is_opera' => true,
1062 'check_opera_version' => array(
1063 '8.0' => true,
1064 '9.0' => true,
1065 '10.0' => true,
1066 '12.15' => true,
7c10ad33
AN
1067 ),
1068
1069 'versionclasses' => array(
1070 'opera',
1071 ),
1072
1073 'supports_svg' => false,
1074 ),
1075 ),
657a94fc 1076
7c10ad33
AN
1077 // Opera 9.0; Debian Linux.
1078 array(
1079 'Opera/9.01 (X11; Linux i686; U; en)',
1080 array(
1081 'is_opera' => true,
1082 'check_opera_version' => array(
1083 '8.0' => true,
5ee4f581 1084 '9.0' => true,
7c10ad33
AN
1085 ),
1086
1087 'versionclasses' => array(
1088 'opera',
1089 ),
1090
1091 'supports_svg' => false,
1092 ),
1093 ),
1094 );
657a94fc
MS
1095 }
1096
c3d2fbf9 1097 /**
7c10ad33 1098 * Test instance generation.
c3d2fbf9 1099 */
7c10ad33
AN
1100 public function test_instance() {
1101 $this->assertInstanceOf('core_useragent', core_useragent::instance());
1102 $this->assertInstanceOf('core_useragent', core_useragent::instance(true));
1103 }
c3d2fbf9 1104
7c10ad33
AN
1105 /**
1106 * @dataProvider user_agents_providers
1107 */
1108 public function test_useragent_ie($useragent, $tests) {
1109 // Setup the core_useragent instance.
1110 core_useragent::instance(true, $useragent);
1111
1112 // IE Tests.
1113 if (isset($tests['is_ie']) && $tests['is_ie']) {
1114 $this->assertTrue(core_useragent::is_ie());
1115 } else {
1116 $this->assertFalse(core_useragent::is_ie());
1117 }
1118
1119 $versions = array(
1120 // New versions of should be added here.
1121 '0' => false,
1122 '5.0' => false,
1123 '5.5' => false,
1124 '6.0' => false,
1125 '7.0' => false,
1126 '8.0' => false,
1127 '9.0' => false,
1128 '10' => false,
1129 '11' => false,
1130 '12' => false,
1131 '13' => false,
1132 '14' => false,
1133 );
1134
1135 if (isset($tests['check_ie_version'])) {
1136 // The test provider has overwritten some of the above checks.
1137 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1138 $versions = $tests['check_ie_version'] + $versions;
1139 }
1140
1141 foreach ($versions as $version => $result) {
1142 $this->assertEquals($result, core_useragent::check_ie_version($version),
1143 "Version incorrectly determined for IE version '{$version}'");
1144 }
1145
1146 // IE Compatibility mode.
1147 if (isset($tests['iecompatibility']) && $tests['iecompatibility']) {
1148 $this->assertTrue(core_useragent::check_ie_compatibility_view(), "IE Compability false negative");
1149 } else {
1150 $this->assertFalse(core_useragent::check_ie_compatibility_view(), "IE Compability false positive");
1151 }
c3d2fbf9 1152
7c10ad33 1153 }
c3d2fbf9 1154
7c10ad33
AN
1155 /**
1156 * @dataProvider user_agents_providers
1157 */
1158 public function test_useragent_msword($useragent, $tests) {
1159 // Setup the core_useragent instance.
1160 core_useragent::instance(true, $useragent);
1161
1162 // MSWord Tests.
1163 if (isset($tests['is_msword']) && $tests['is_msword']) {
1164 $this->assertTrue(core_useragent::is_msword());
1165 } else {
1166 $this->assertFalse(core_useragent::is_msword());
1167 }
1168 }
c3d2fbf9 1169
c3d2fbf9 1170
7c10ad33
AN
1171 /**
1172 * @dataProvider user_agents_providers
1173 */
1174 public function test_useragent_supports($useragent, $tests) {
1175 // Setup the core_useragent instance.
1176 core_useragent::instance(true, $useragent);
1177
1178 // Supports SVG.
1179 if (!isset($tests['supports_svg']) || $tests['supports_svg']) {
1180 $this->assertTrue(core_useragent::supports_svg(),
1181 "SVG Support was not reported (and should have been)");
1182 } else {
1183 $this->assertFalse(core_useragent::supports_svg(),
1184 "SVG Support was reported (and should not have been)");
1185 }
83af1329
AN
1186
1187 // Supports JSON ContentType.
1188 if (!isset($tests['supports_json_contenttype']) || $tests['supports_json_contenttype']) {
1189 $this->assertTrue(core_useragent::supports_json_contenttype(),
1190 "JSON ContentType Support was not reported (and should have been)");
1191 } else {
1192 $this->assertFalse(core_useragent::supports_json_contenttype(),
1193 "JSON ContentType Support was reported (and should not have been)");
1194 }
7c10ad33 1195 }
c3d2fbf9 1196
7c10ad33
AN
1197 /**
1198 * @dataProvider user_agents_providers
1199 */
1200 public function test_useragent_webkit($useragent, $tests) {
1201 // Setup the core_useragent instance.
1202 core_useragent::instance(true, $useragent);
1203
1204 if (isset($tests['is_webkit']) && $tests['is_webkit']) {
1205 $this->assertTrue(core_useragent::is_webkit(),
1206 "Browser was not identified as a webkit browser");
1207 $this->assertTrue(core_useragent::check_webkit_version());
1208 } else {
1209 $this->assertFalse(core_useragent::is_webkit(),
1210 "Browser was incorrectly identified as a webkit browser");
1211 $this->assertFalse(core_useragent::check_webkit_version());
1212 }
1213
1214 $versions = array(
1215 // New versions should be added here.
1216 );
1217
1218 if (isset($tests['check_webkit_version'])) {
1219 // The test provider has overwritten some of the above checks.
1220 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1221 $versions = $tests['check_webkit_version'] + $versions;
1222 }
1223
1224 foreach ($versions as $version => $result) {
1225 $this->assertEquals($result, core_useragent::check_webkit_version($version),
1226 "Version incorrectly determined for Webkit version '{$version}'");
1227 }
1228 }
c3d2fbf9 1229
7c10ad33
AN
1230 /**
1231 * @dataProvider user_agents_providers
1232 */
1233 public function test_useragent_webkit_android($useragent, $tests) {
1234 // Setup the core_useragent instance.
1235 core_useragent::instance(true, $useragent);
1236
1237 if (isset($tests['is_webkit_android']) && $tests['is_webkit_android']) {
1238 $this->assertTrue(core_useragent::is_webkit_android(),
1239 "Browser was not identified as an Android webkit browser");
1240 $this->assertTrue(core_useragent::check_webkit_android_version());
1241 } else {
1242 $this->assertFalse(core_useragent::is_webkit_android(),
1243 "Browser was incorrectly identified as an Android webkit browser");
1244 $this->assertFalse(core_useragent::check_webkit_android_version());
1245 }
1246
1247 $versions = array(
1248 // New versions should be added here.
1249 '525' => false,
1250 '527' => false,
1251 '590' => false,
1252 );
1253
1254 if (isset($tests['check_webkit_android_version'])) {
1255 // The test provider has overwritten some of the above checks.
1256 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1257 $versions = $tests['check_webkit_android_version'] + $versions;
1258 }
1259
1260 foreach ($versions as $version => $result) {
1261 $this->assertEquals($result, core_useragent::check_webkit_android_version($version),
1262 "Version incorrectly determined for Android webkit version '{$version}'");
1263 }
1264 }
c3d2fbf9 1265
7c10ad33
AN
1266 /**
1267 * @dataProvider user_agents_providers
1268 */
1269 public function test_useragent_chrome($useragent, $tests) {
1270 // Setup the core_useragent instance.
1271 core_useragent::instance(true, $useragent);
1272
1273 if (isset($tests['is_chrome']) && $tests['is_chrome']) {
1274 $this->assertTrue(core_useragent::is_chrome(),
1275 "Browser was not identified as a chrome browser");
1276 $this->assertTrue(core_useragent::check_chrome_version());
1277 } else {
1278 $this->assertFalse(core_useragent::is_chrome(),
1279 "Browser was incorrectly identified as a chrome browser");
1280 $this->assertFalse(core_useragent::check_chrome_version());
1281 }
1282
1283 $versions = array(
1284 // New versions should be added here.
1285 '7' => false,
1286 '8' => false,
1287 '10' => false,
5ee4f581 1288 '39' => false,
7c10ad33
AN
1289 );
1290
1291 if (isset($tests['check_chrome_version'])) {
1292 // The test provider has overwritten some of the above checks.
1293 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1294 $versions = $tests['check_chrome_version'] + $versions;
1295 }
1296
1297 foreach ($versions as $version => $result) {
1298 $this->assertEquals($result, core_useragent::check_chrome_version($version),
1299 "Version incorrectly determined for Chrome version '{$version}'");
1300 }
1301 }
c3d2fbf9 1302
7c10ad33
AN
1303 /**
1304 * @dataProvider user_agents_providers
1305 */
1306 public function test_useragent_safari($useragent, $tests) {
1307 // Setup the core_useragent instance.
1308 core_useragent::instance(true, $useragent);
1309
1310 if (isset($tests['is_safari']) && $tests['is_safari']) {
1311 $this->assertTrue(core_useragent::is_safari(),
1312 "Browser was not identified as a safari browser");
1313 $this->assertTrue(core_useragent::check_safari_version());
1314 } else {
1315 $this->assertFalse(core_useragent::is_safari(),
1316 "Browser was incorrectly identified as a safari browser");
1317 $this->assertFalse(core_useragent::check_safari_version());
1318 }
1319
1320 // Check Safari (generic).
1321 $versions = array(
1322 // New versions should be added here.
1323 '1' => false,
1324 '312' => false,
1325 '500' => false,
1326 );
1327
1328 if (isset($tests['check_safari_version'])) {
1329 // The test provider has overwritten some of the above checks.
1330 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1331 $versions = $tests['check_safari_version'] + $versions;
1332 }
1333
1334 foreach ($versions as $version => $result) {
1335 $this->assertEquals($result, core_useragent::check_safari_version($version),
1336 "Version incorrectly determined for Safari (generic) version '{$version}'");
1337 }
1338 }
c3d2fbf9 1339
7c10ad33
AN
1340 /**
1341 * @dataProvider user_agents_providers
1342 */
1343 public function test_useragent_ios_safari($useragent, $tests) {
1344 // Setup the core_useragent instance.
1345 core_useragent::instance(true, $useragent);
1346
1347 if (isset($tests['is_safari_ios']) && $tests['is_safari_ios']) {
1348 $this->assertTrue(core_useragent::is_safari_ios(),
1349 "Browser was not identified as an iOS safari browser");
1350 $this->assertTrue(core_useragent::check_safari_ios_version());
1351 } else {
1352 $this->assertFalse(core_useragent::is_safari_ios(),
1353 "Browser was incorrectly identified as an iOS safari browser");
1354 $this->assertFalse(core_useragent::check_safari_ios_version());
1355 }
1356
1357 // Check iOS Safari.
1358 $versions = array(
1359 // New versions should be added here.
1360 '527' => false,
1361 '590' => false,
5ee4f581 1362 '600' => false,
7c10ad33
AN
1363 );
1364
1365 if (isset($tests['check_safari_ios_version'])) {
1366 // The test provider has overwritten some of the above checks.
1367 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1368 $versions = $tests['check_safari_ios_version'] + $versions;
1369 }
1370
1371 foreach ($versions as $version => $result) {
1372 $this->assertEquals($result, core_useragent::check_safari_ios_version($version),
1373 "Version incorrectly determined for iOS Safari version '{$version}'");
1374 }
1375 }
1376
1377 /**
1378 * @dataProvider user_agents_providers
1379 */
1380 public function test_useragent_gecko($useragent, $tests) {
1381 // Setup the core_useragent instance.
1382 core_useragent::instance(true, $useragent);
1383
1384 if (isset($tests['is_gecko']) && $tests['is_gecko']) {
1385 $this->assertTrue(core_useragent::is_gecko(),
1386 "Browser was not identified as a gecko browser");
1387 $this->assertTrue(core_useragent::check_gecko_version());
1388 } else {
1389 $this->assertFalse(core_useragent::is_gecko(),
1390 "Browser was incorrectly identified as a gecko browser");
1391 $this->assertFalse(core_useragent::check_gecko_version());
1392 }
1393
1394 $versions = array(
1395 // New versions should be added here.
1396 '1' => false,
1397 '2' => false,
1398 '3.6' => false,
1399 '4.0' => false,
1400 '20030516' => false,
1401 '20051116' => false,
1402 '2006010100' => false,
5ee4f581 1403 '20100101' => false,
7c10ad33
AN
1404 '15.0' => false,
1405 '18.0' => false,
1406 '19.0' => false,
1407 );
1408
1409 if (isset($tests['check_gecko_version'])) {
1410 // The test provider has overwritten some of the above checks.
1411 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1412 $versions = $tests['check_gecko_version'] + $versions;
1413 }
1414
1415 foreach ($versions as $version => $result) {
1416 $this->assertEquals($result, core_useragent::check_gecko_version($version),
1417 "Version incorrectly determined for Gecko version '{$version}'");
1418 }
1419 }
1420
1421 /**
1422 * @dataProvider user_agents_providers
1423 */
1424 public function test_useragent_firefox($useragent, $tests) {
1425 // Setup the core_useragent instance.
1426 core_useragent::instance(true, $useragent);
1427
1428 if (isset($tests['is_firefox']) && $tests['is_firefox']) {
1429 $this->assertTrue(core_useragent::is_firefox(),
1430 "Browser was not identified as a firefox browser");
1431 $this->assertTrue(core_useragent::check_firefox_version());
1432 } else {
1433 $this->assertFalse(core_useragent::is_firefox(),
1434 "Browser was incorrectly identified as a firefox browser");
1435 $this->assertFalse(core_useragent::check_firefox_version());
1436 }
1437
1438 $versions = array(
1439 // New versions should be added here.
1440 '1.5' => false,
1441 '3.0' => false,
1442 '4' => false,
1443 '10' => false,
1444 '15' => false,
1445 '18' => false,
1446 '19' => false,
5ee4f581 1447 '33' => false,
7c10ad33
AN
1448 );
1449
1450 if (isset($tests['check_firefox_version'])) {
1451 // The test provider has overwritten some of the above checks.
1452 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1453 $versions = $tests['check_firefox_version'] + $versions;
1454 }
1455
1456 foreach ($versions as $version => $result) {
1457 $this->assertEquals($result, core_useragent::check_firefox_version($version),
1458 "Version incorrectly determined for Firefox version '{$version}'");
1459 }
1460 }
c3d2fbf9 1461
7c10ad33
AN
1462 /**
1463 * @dataProvider user_agents_providers
1464 */
1465 public function test_useragent_opera($useragent, $tests) {
1466 // Setup the core_useragent instance.
1467 core_useragent::instance(true, $useragent);
1468
1469 if (isset($tests['is_opera']) && $tests['is_opera']) {
1470 $this->assertTrue(core_useragent::is_opera(),
1471 "Browser was not identified as a opera browser");
1472 $this->assertTrue(core_useragent::check_opera_version());
1473 } else {
1474 $this->assertFalse(core_useragent::is_opera(),
1475 "Browser was incorrectly identified as a opera browser");
1476 $this->assertFalse(core_useragent::check_opera_version());
1477 }
1478
1479 $versions = array(
1480 // New versions should be added here.
1481 '8.0' => false,
5ee4f581 1482 '9.0' => false,
7c10ad33 1483 '10.0' => false,
5ee4f581 1484 '12.15' => false,
7c10ad33
AN
1485 );
1486
1487 if (isset($tests['check_opera_version'])) {
1488 // The test provider has overwritten some of the above checks.
1489 // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
1490 $versions = $tests['check_opera_version'] + $versions;
1491 }
1492
1493 foreach ($versions as $version => $result) {
1494 $this->assertEquals($result, core_useragent::check_opera_version($version),
1495 "Version incorrectly determined for Opera version '{$version}'");
1496 }
1497 }
c3d2fbf9 1498
7c10ad33
AN
1499 /**
1500 * @dataProvider user_agents_providers
1501 */
1502 public function test_get_device_type($useragent, $tests) {
1503 // Setup the core_useragent instance.
1504 core_useragent::instance(true, $useragent);
c3d2fbf9 1505
7c10ad33
AN
1506 $expected = 'default';
1507 if (isset($tests['devicetype'])) {
1508 $expected = $tests['devicetype'];
1509 }
c3d2fbf9 1510
7c10ad33
AN
1511 $this->assertEquals($expected, core_useragent::get_device_type(),
1512 "Device Type was not correctly identified");
c3d2fbf9
SH
1513 }
1514
1515 /**
7c10ad33 1516 * @dataProvider user_agents_providers
c3d2fbf9 1517 */
7c10ad33
AN
1518 public function test_get_browser_version_classes($useragent, $tests) {
1519 // Setup the core_useragent instance.
1520 core_useragent::instance(true, $useragent);
1521
1522 $actual = core_useragent::get_browser_version_classes();
1523 foreach ($tests['versionclasses'] as $expectedclass) {
1524 $this->assertContains($expectedclass, $actual);
1525 }
1526 $this->assertCount(count($tests['versionclasses']), $actual);
c3d2fbf9 1527 }
378b3eac 1528}