DBUIHelpers_DOMTest.php
4.92 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
require_once 'basepath.inc.php';
require_once $__BASEPATH_EX.'include/config.php';
/**
* Language
*/
require_once $__BASEPATH_EX.'include/Forest/mensch.coop/php/class_Language.mensch.coop.inc.php';
require_once $__BASEPATH_EX.'include/System/php/class_Language.inc.php';
require_once $__BASEPATH_EX.'include/System/php/class_CONSTKindOf.inc.php';
/**
* Converter
*/
require_once $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/class_Converter.inc.php';
require_once $__BASEPATH_EX.'include/Lib/Tools/mcClasses/mcPUIX/class_mcPUIX_DOM.inc.php';
$_PHPUNIT_mcPUIX_DOMTest_XSD = $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/Element.xsd';
$_PHPUNIT_mcPUIX_DOMTest_XSL = $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/mcPUIX.xsl';
/**
* Test class for mcPUIX_DOM.
* Generated by PHPUnit on 2010-07-13 at 14:12:14.
*/
class mcPUIX_DOMTest extends PHPUnit_Framework_TestCase {
protected $stylesheet;
protected $processor;
protected function setUp() {
global $_PHPUNIT_mcPUIX_DOMTest_XSL;
$this->stylesheet = new DOMDocument;
$this->stylesheet->load($_PHPUNIT_mcPUIX_DOMTest_XSL);
$this->processor = new XSLTProcessor;
$this->processor->importStylesheet($this->stylesheet);
}
protected function tearDown() {
}
private function checkXML(DOMDocument $param_DOMDocument) {
$DOMHtml = new DOMDocument;
$this->assertTrue($DOMHtml->loadHTML($this->processor->transformToDoc($param_DOMDocument)->saveXML()), 'validate DOMElement with xsd');
return $DOMHtml;
}
private function checkXMLString(DOMDocument $param_DOMDocument, array $param_SearchStringArray, $param_SearchStringDirection=false) {
$this->checkXML($param_DOMDocument);
$HTMLString = $this->processor->transformToDoc($param_DOMDocument)->saveXML();
foreach($param_SearchStringArray as $TagName) {
$this->assertTrue(substr_count($HTMLString, $TagName)>0, 'found string('.$TagName.')');
// $this->assertTrue(substr_count($HTMLString, $TagName.'l')>0, 'found string('.$TagName.')');
if($param_SearchStringDirection) {
$HTMLString = strstr($HTMLString, $TagName);
}
}
return $HTMLString;
}
private function checkGetDOMElement_Element(array $param_OptionalAttributes=array(), array $param_SearchStringArray=array()) {
global $_LOSP_CHARSET;
global $_PHPUNIT_mcPUIX_DOMTest_XSD;
$DOMDocument = new DOMDocument('1.0', $_LOSP_CHARSET);
$DOMDocument->appendChild(mcPUIX_DOM::getDOMElement_Element($DOMDocument, 'objvar', $param_OptionalAttributes));
echo "\n".$DOMDocument->saveXML()."\n";
$this->assertTrue($DOMDocument->schemaValidate($_PHPUNIT_mcPUIX_DOMTest_XSD), 'validate DOMElement with xsd');
$this->checkXMLString($DOMDocument, $param_SearchStringArray, true);
}
private function checkGetDOMElement_DBUIArray(array $param_Array, array $param_SearchStringArray=array()) {
global $_LOSP_CHARSET;
global $_PHPUNIT_mcPUIX_DOMTest_XSD;
$DOMDocument = new DOMDocument('1.0', $_LOSP_CHARSET);
$DOMDocument->appendChild(mcPUIX_DOM::getDOMElement_DBUIArray($DOMDocument, $param_Array));
$this->assertTrue($DOMDocument->schemaValidate($_PHPUNIT_mcPUIX_DOMTest_XSD), 'validate DOMElement with xsd');
}
public function testGetDOMElement_Element() {
/**
* test default
*/
// $this->checkGetDOMElement_Element();
/**
* test as text
*/
$var_OptionalAttributes = array(
'type' => 'text',
'show' => true,
'edit' => true
);
$this->checkGetDOMElement_Element($var_OptionalAttributes, array('textarea'));
/**
* teset as select
*/
$var_OptionalAttributes = array(
'type' => 'select',
'show' => true,
'edit' => true,
'value' => '1',
'values' => array('1' => 'eins', '2' => 'zwei')
);
// $this->checkGetDOMElement_Element($var_OptionalAttributes, array('select', 'option'));
}
public function testGetDOMElement_DBUIArray() {
$array = array(
array(
'INT' => array('type'=> 'int', 'show'=> true, 'value' => 1),
'KEY' => array('show'=> true, 'value' => 'key'),
'TEXT' => array('type'=> 'text', 'show'=> true, 'value' => 1, 'edit' => true),
'SELECT'=> array('type'=> 'select', 'show'=> true, 'value' => '', 'values' => array('select1', 'select2'), 'edit' => true),
),
array(
'ID' => array('type'=> 'int', 'show'=> true, 'value' => 1),
'Key' => array('show'=> true, 'value' => 'key'),
'value' => array('type'=> 'text', 'show'=> true, 'value' => 1),
'select'=> array('type'=> 'select', 'show'=> true, 'values' => array('select1', 'select2')),
),
array(
'ID' => array('type'=>'int', 'show'=> true, 'value' => 1),
'Key' => array('show'=>true, 'value'=>'key'),
'value' => array('type'=>'text', 'show'=>true, 'value'=>1, 'edit'=>true, 'fixed'=>true),
'select'=> array('type'=>'select', 'show'=> true, 'values' => array('select1', 'select2'), 'value' => 1),
)
);
// $this->checkGetDOMElement_DBUIArray($array, array('<option value="1" selected="selected">', '</textarea>', '</select>', '</option>'));
}
}
?>