@@ 64-85 (lines=22) @@ | ||
61 | * |
|
62 | * @return void |
|
63 | */ |
|
64 | public function testAddNode() |
|
65 | { |
|
66 | // The source data. |
|
67 | $xml1 = simplexml_load_string('<form><fields /></form>'); |
|
68 | ||
69 | // The new data for adding the field. |
|
70 | $xml2 = simplexml_load_string('<form><field name="foo" /></form>'); |
|
71 | ||
72 | if ($xml1 === false || $xml2 === false) |
|
73 | { |
|
74 | $this->fail('Error in text XML data'); |
|
75 | } |
|
76 | ||
77 | JFormInspector::addNode($xml1->fields, $xml2->field); |
|
78 | ||
79 | $fields = $xml1->xpath('fields/field[@name="foo"]'); |
|
80 | $this->assertThat( |
|
81 | count($fields), |
|
82 | $this->equalTo(1), |
|
83 | 'Line:' . __LINE__ . ' The field should be added, ungrouped.' |
|
84 | ); |
|
85 | } |
|
86 | ||
87 | /** |
|
88 | * Tests the Form::bind method. |
|
@@ 1401-1422 (lines=22) @@ | ||
1398 | * |
|
1399 | * @return void |
|
1400 | */ |
|
1401 | public function testMergeNode() |
|
1402 | { |
|
1403 | // The source data. |
|
1404 | $xml1 = simplexml_load_string('<form><field name="foo" /></form>'); |
|
1405 | ||
1406 | // The new data for adding the field. |
|
1407 | $xml2 = simplexml_load_string('<form><field name="bar" type="text" /></form>'); |
|
1408 | ||
1409 | if ($xml1 === false || $xml2 === false) |
|
1410 | { |
|
1411 | $this->fail('Line:' . __LINE__ . ' Error in text XML data'); |
|
1412 | } |
|
1413 | ||
1414 | JFormInspector::mergeNode($xml1->field, $xml2->field); |
|
1415 | ||
1416 | $fields = $xml1->xpath('field[@name="foo"] | field[@type="text"]'); |
|
1417 | $this->assertThat( |
|
1418 | count($fields), |
|
1419 | $this->equalTo(1), |
|
1420 | 'Line:' . __LINE__ . ' Existing attribute "name" should merge, new attribute "type" added.' |
|
1421 | ); |
|
1422 | } |
|
1423 | ||
1424 | /** |
|
1425 | * Test the Form::mergeNode method. |