mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
2b0729d435
MINOR Added unit test for XMLDataFormatter::convertDataObjectWithoutHeader() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@115229 467b73ca-7a2a-4603-9d3b-597d59a354a9
40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
class XMLDataFormatterTest extends SapphireTest {
|
|
|
|
public static $fixture_file = 'sapphire/tests/api/XMLDataFormatterTest.yml';
|
|
|
|
protected $extraDataObjects = array(
|
|
'XMLDataFormatterTest_DataObject'
|
|
);
|
|
|
|
public function testConvertDataObjectWithoutHeader() {
|
|
$formatter = new XMLDataFormatter();
|
|
$obj = $this->objFromFixture('XMLDataFormatterTest_DataObject', 'test-do');
|
|
$xml = new SimpleXMLElement('<?xml version="1.0"?>' . $formatter->convertDataObjectWithoutHeader($obj));
|
|
$this->assertEquals(
|
|
Director::absoluteBaseURL() . sprintf('api/v1/XMLDataFormatterTest_DataObject/%d.xml', $obj->ID),
|
|
(string) $xml['href']
|
|
);
|
|
$this->assertEquals('Test DataObject', (string) $xml->Name);
|
|
$this->assertEquals('Test Company', (string) $xml->Company);
|
|
$this->assertEquals($obj->ID, (int) $xml->ID);
|
|
$this->assertEquals(
|
|
'<Content><![CDATA[<a href="http://mysite.com">mysite.com</a> is a link in this HTML content. <![CDATA[this is some nested CDATA]]]]><![CDATA[>]]></Content>',
|
|
$xml->Content->asXML()
|
|
);
|
|
$this->assertEquals(
|
|
'<a href="http://mysite.com">mysite.com</a> is a link in this HTML content. <![CDATA[this is some nested CDATA]]>',
|
|
(string) $xml->Content
|
|
);
|
|
}
|
|
|
|
}
|
|
class XMLDataFormatterTest_DataObject extends DataObject implements TestOnly {
|
|
|
|
public static $db = array(
|
|
'Name' => 'Varchar(50)',
|
|
'Company' => 'Varchar(50)',
|
|
'Content' => 'HTMLText'
|
|
);
|
|
|
|
} |