Skip to content

Commit

Permalink
SimpleXML string casting in tests for older PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Dec 17, 2012
1 parent 546d202 commit 7950584
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tests/api/XMLDataFormatterTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public function testShortcodesInDataObject() {
$page->Content = 'This is some test content [test_shortcode]test[/test_shortcode]'; $page->Content = 'This is some test content [test_shortcode]test[/test_shortcode]';


$xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($page)); $xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($page));
$this->assertEquals('This is some test content test', $xml->Content); $this->assertEquals('This is some test content test', (string)$xml->Content);


$page->Content = '[test_shortcode,id=-1]'; $page->Content = '[test_shortcode,id=-1]';
$xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($page)); $xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($page));
$this->assertEmpty('', $xml->Content); $this->assertEmpty('', (string)$xml->Content);


$page->Content = '[bad_code,id=1]'; $page->Content = '[bad_code,id=1]';


$xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($page)); $xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($page));
$this->assertContains('[bad_code,id=1]', $xml->Content); $this->assertContains('[bad_code,id=1]', (string)$xml->Content);
} }


/** /**
Expand Down
8 changes: 4 additions & 4 deletions tests/forms/HtmlEditorFieldTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public function testImageInsertion() {


$parser = new CSSContentParser($obj->Content); $parser = new CSSContentParser($obj->Content);
$xml = $parser->getByXpath('//img'); $xml = $parser->getByXpath('//img');
$this->assertEquals('', $xml[0]['alt'], 'Alt tags are added by default.'); $this->assertEquals('', (string)$xml[0]['alt'], 'Alt tags are added by default.');
$this->assertEquals('', $xml[0]['title'], 'Title tags are added by default.'); $this->assertEquals('', (string)$xml[0]['title'], 'Title tags are added by default.');


$editor->setValue('<img src="assets/example.jpg" alt="foo" title="bar" />'); $editor->setValue('<img src="assets/example.jpg" alt="foo" title="bar" />');
$editor->saveInto($obj); $editor->saveInto($obj);


$parser = new CSSContentParser($obj->Content); $parser = new CSSContentParser($obj->Content);
$xml = $parser->getByXpath('//img'); $xml = $parser->getByXpath('//img');
$this->assertEquals('foo', $xml[0]['alt'], 'Alt tags are preserved.'); $this->assertEquals('foo', (string)$xml[0]['alt'], 'Alt tags are preserved.');
$this->assertEquals('bar', $xml[0]['title'], 'Title tags are preserved.'); $this->assertEquals('bar', (string)$xml[0]['title'], 'Title tags are preserved.');
} }


public function testMultiLineSaving() { public function testMultiLineSaving() {
Expand Down
12 changes: 6 additions & 6 deletions tests/forms/SelectionGroupTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function testFieldHolder() {
$this->assertEquals('one', (string)$listElOne->input[0]['value']); $this->assertEquals('one', (string)$listElOne->input[0]['value']);
$this->assertEquals('two', (string)$listElTwo->input[0]['value']); $this->assertEquals('two', (string)$listElTwo->input[0]['value']);


$this->assertEquals('one title', $listElOne->label[0]); $this->assertEquals('one title', (string)$listElOne->label[0]);
$this->assertEquals('two title', $listElTwo->label[0]); $this->assertEquals('two title', (string)$listElTwo->label[0]);


$this->assertContains('one view', (string)$listElOne->div); $this->assertContains('one view', (string)$listElOne->div);
$this->assertContains('two view', (string)$listElTwo->div); $this->assertContains('two view', (string)$listElTwo->div);
Expand All @@ -44,8 +44,8 @@ function testLegacyItemsFieldHolder() {
$this->assertEquals('one', (string)$listElOne->input[0]['value']); $this->assertEquals('one', (string)$listElOne->input[0]['value']);
$this->assertEquals('two', (string)$listElTwo->input[0]['value']); $this->assertEquals('two', (string)$listElTwo->input[0]['value']);


$this->assertEquals('one', $listElOne->label[0]); $this->assertEquals('one', (string)$listElOne->label[0]);
$this->assertEquals('two', $listElTwo->label[0]); $this->assertEquals('two', (string)$listElTwo->label[0]);
} }


function testLegacyItemsFieldHolderWithTitle() { function testLegacyItemsFieldHolderWithTitle() {
Expand All @@ -62,8 +62,8 @@ function testLegacyItemsFieldHolderWithTitle() {
$this->assertEquals('one', (string)$listElOne->input[0]['value']); $this->assertEquals('one', (string)$listElOne->input[0]['value']);
$this->assertEquals('two', (string)$listElTwo->input[0]['value']); $this->assertEquals('two', (string)$listElTwo->input[0]['value']);


$this->assertEquals('one title', $listElOne->label[0]); $this->assertEquals('one title', (string)$listElOne->label[0]);
$this->assertEquals('two title', $listElTwo->label[0]); $this->assertEquals('two title', (string)$listElTwo->label[0]);
} }


} }

0 comments on commit 7950584

Please sign in to comment.