-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathPrmComboTestCase.php
More file actions
43 lines (34 loc) · 1.49 KB
/
Copy pathPrmComboTestCase.php
File metadata and controls
43 lines (34 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
class PrmComboTestCase extends TBSUnitTestCase {
function __construct() {
$this->UnitTestCase('Parameter combo Unit Tests');
}
function setUp() {
// Reset global combo list before each test to avoid pollution
$GLOBALS['_TBS_PrmCombo'] = array();
}
function tearDown() {
$GLOBALS['_TBS_PrmCombo'] = array();
}
function testKnownCombo() {
// A registered combo's parameters are applied to the field.
// Here 'safe' adds noerr so a missing variable produces no error.
$this->newInstance = false;
$this->tbs = new clsTinyButStrong;
$this->tbs->SetOption('prm_combo', array('safe' => array('noerr' => '')));
$this->assertEqualMergeFieldStrings('[onshow.nonexistent;combo=safe]', array(), '', 'known combo #1 - output is empty');
$this->assertNoTbsError('known combo #1 - no TBS error');
}
function testUnknownComboRaisesTbsError() {
// Referencing an undefined combo must raise a TBS error instead of a PHP fatal error.
// Before the fix, this caused: "Fatal error: Using $this when not in object context"
// because meth_Misc_ApplyPrmCombo is static but called $this->meth_Misc_Alert().
$this->tbs = new clsTinyButStrong;
$this->tbs->NoErr = true;
$this->tbs->Source = '[onshow.msg;combo=undefined_combo]';
$this->tbs->VarRef['msg'] = 'hello';
$this->tbs->Show(TBS_NOTHING);
$this->assertTrue($this->tbs->ErrCount > 0, 'unknown combo - TBS error is raised');
$this->assertEqual($this->tbs->Source, 'hello', 'unknown combo - field value still rendered');
}
}