CRM-20906 Add in unit test of Extenion check
[civicrm-core.git] / tests / phpunit / CRM / Admin / Form / ExtensionTest.php
CommitLineData
cbe2d1ae
SL
1<?php
2
3/**
4 * Class CRM_Admin_Form_ExtensionTest
5 * @group headless
6 */
7class CRM_Admin_Form_ExtensionTest extends CiviUnitTestCase {
8
9 /**
10 * @return array
11 */
12 public function extenionKeyTests() {
13 $keys = array();
14 $keys[] = array('org.civicrm.multisite');
15 $keys[] = array('au.org.contribute2016');
16 $keys[] = array('%3Csvg%20onload=alert(0)%3E');
17 return $keys;
18 }
19
20 /**
21 * @param $key
22 * @dataProvider extenionKeyTests
23 */
24 public function testExtenionKeyValid($key) {
25 if ($key == '%3Csvg%20onload=alert(0)%3E') {
26 $this->assertFalse(CRM_Admin_Form_Extensions::checkExtesnionKeyIsValid($key));
27 }
28 else {
29 $this->assertTrue(CRM_Admin_Form_Extensions::checkExtesnionKeyIsValid($key));
30 }
31 }
32
33}