Commit | Line | Data |
---|---|---|
b49164dd TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
6 | | This work is published under the GNU AGPLv3 license with some | | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
9 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | ||
12 | /** | |
13 | * Class CRM_Core_KeyTest | |
14 | * @group headless | |
15 | */ | |
16 | class CRM_Core_KeyTest extends CiviUnitTestCase { | |
17 | ||
18 | public function testOK() { | |
19 | $key = CRM_Core_Key::get('CRM_Bread_Butter'); | |
20 | $this->assertTrue(CRM_Core_Key::valid($key)); | |
21 | $this->assertEquals($key, CRM_Core_Key::validate($key, 'CRM_Bread_Butter')); | |
22 | } | |
23 | ||
24 | public function testMalformed() { | |
25 | $key = CRM_Core_Key::get('CRM_Bread_Butter') . '<script>'; | |
26 | $this->assertFalse(CRM_Core_Key::valid($key)); | |
27 | $this->assertEquals(NULL, CRM_Core_Key::validate($key, 'CRM_Bread_Butter')); | |
28 | } | |
29 | ||
30 | public function testMixedUp() { | |
31 | $key = CRM_Core_Key::get('CRM_Toast_Jam'); | |
32 | $this->assertTrue(CRM_Core_Key::valid($key)); | |
33 | $this->assertEquals(NULL, CRM_Core_Key::validate($key, 'CRM_Bread_Butter')); | |
34 | } | |
35 | ||
36 | } |