forked from artesis/ting_search_extendform
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ting_search_extendform.test
82 lines (65 loc) · 3.01 KB
/
ting_search_extendform.test
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @file
* Test of the extended search form.
*/
class TingSearchExtendFormTestCase extends DrupalUnitTestCase {
const ADVANCED_SEARCH_KEY = 'advanced_search';
const FIELDS_KEY = 'fields';
const TYPE_ATTR = '#type';
const TITLE_ATTR = '#title';
const SIZE_ATTR = '#size';
const MAXLEN_ATTR = '#maxlength';
const COLLAPSIBLE_ATTR = '#collapsible';
const COLLAPSED_ATTR = '#collapsed';
const ATTRIBUTES_ATTR = '#attributes';
const PREFIX_ATTR = '#prefix';
const SUFFIX_ATTR = '#suffix';
const SUBMIT_ATTR = '#submit';
const FIELDSET_TYPE = 'fieldset';
const TEXTFIELD_TYPE = 'textfield';
const TEXTFIELD_SIZE = 50;
const TEXTFIELD_MAXSIZE = 255;
public static function getInfo() {
return array(
'name' => 'Ting search extend form',
'description' => 'Test of the Ting Search Extend Module',
'group' => 'Ding!',
);
}
function testAlterFormInitState() {
$form = array();
$form_state = array();
ting_search_extendform_form_search_block_form_alter($form, $form_state, 'search_block_form');
$this->assertTrue( is_array($form) );
$tf = $form[self::ADVANCED_SEARCH_KEY];
$this->assertTrue( is_array($tf) );
$this->assertEqual( $tf[self::TYPE_ATTR], self::FIELDSET_TYPE);
$this->assertEqual( $tf[self::TITLE_ATTR], t('Advanced'));
$this->assertTrue( $tf[self::COLLAPSIBLE_ATTR] );
$this->assertTrue( $tf[self::COLLAPSED_ATTR] );
$this->assertEqual( $tf[self::ATTRIBUTES_ATTR], array('class' => array('extendsearch-advanced')));
$this->assertEqual( $tf[self::PREFIX_ATTR], '<br/>');
$this->assertTrue( is_array($form[self::ADVANCED_SEARCH_KEY][self::FIELDS_KEY]) );
$tf = $form[self::ADVANCED_SEARCH_KEY][self::FIELDS_KEY]['ting_search_extendform_creator_field'];
$this->assertTrue( is_array($tf) );
$this->assertEqual( $tf[self::TYPE_ATTR], self::TEXTFIELD_TYPE);
$this->assertEqual( $tf[self::TITLE_ATTR], t('Author'));
$this->assertEqual( $tf[self::SIZE_ATTR], self::TEXTFIELD_SIZE);
$this->assertEqual( $tf[self::MAXLEN_ATTR], self::TEXTFIELD_MAXSIZE);
$tf = $form[self::ADVANCED_SEARCH_KEY][self::FIELDS_KEY]['ting_search_extendform_title_field'];
$this->assertTrue( is_array($tf) );
$this->assertEqual( $tf[self::TYPE_ATTR], self::TEXTFIELD_TYPE);
$this->assertEqual( $tf[self::TITLE_ATTR], t('Title'));
$this->assertEqual( $tf[self::SIZE_ATTR], self::TEXTFIELD_SIZE);
$this->assertEqual( $tf[self::MAXLEN_ATTR], self::TEXTFIELD_MAXSIZE);
$tf = $form[self::ADVANCED_SEARCH_KEY][self::FIELDS_KEY]['ting_search_extendform_subject_field'];
$this->assertTrue( is_array($tf) );
$this->assertEqual( $tf[self::TYPE_ATTR], self::TEXTFIELD_TYPE);
$this->assertEqual( $tf[self::TITLE_ATTR], t('Subjects'));
$this->assertEqual( $tf[self::SIZE_ATTR], self::TEXTFIELD_SIZE);
$this->assertEqual( $tf[self::MAXLEN_ATTR], self::TEXTFIELD_MAXSIZE);
$this->assertEqual( $form[self::SUBMIT_ATTR], array('ting_search_extendform_submit'));
}
function testAlterFormSearchState() { }
}