mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Additional tests added for XmlHelper
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7106 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6affb7f70a
commit
57b6dedc49
1 changed files with 20 additions and 77 deletions
|
@ -31,36 +31,14 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|||
}
|
||||
|
||||
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'xml');
|
||||
/**
|
||||
* TestXml class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
*/
|
||||
|
||||
class TestXml extends Object {
|
||||
/**
|
||||
* content property
|
||||
*
|
||||
* @var string ''
|
||||
* @access public
|
||||
*/
|
||||
var $content = '';
|
||||
/**
|
||||
* construct method
|
||||
*
|
||||
* @param mixed $content
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function __construct($content) {
|
||||
$this->content = $content;
|
||||
}
|
||||
/**
|
||||
* toString method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function toString() {
|
||||
return $this->content;
|
||||
}
|
||||
|
@ -72,21 +50,12 @@ class TestXml extends Object {
|
|||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
*/
|
||||
class XmlHelperTest extends UnitTestCase {
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function setUp() {
|
||||
$this->Xml =& new XmlHelper();
|
||||
$this->Xml->beforeRender();
|
||||
}
|
||||
/**
|
||||
* testAddNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function testAddNamespace() {
|
||||
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
||||
$manager =& XmlManager::getInstance();
|
||||
|
@ -94,12 +63,7 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$expected = array('custom' => 'http://example.com/dtd.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
}
|
||||
/**
|
||||
* testRemoveNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function testRemoveNamespace() {
|
||||
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
||||
$this->Xml->addNs('custom2', 'http://example.com/dtd2.xml');
|
||||
|
@ -112,38 +76,27 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$expected = array('custom2' => 'http://example.com/dtd2.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
}
|
||||
/**
|
||||
* testRenderZeroElement method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function testRenderZeroElement() {
|
||||
$result = $this->Xml->elem('count', null, 0);
|
||||
$expected = '<count>0</count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testRenderElementWithNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function testRenderElementWithNamespace() {
|
||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
|
||||
$expected = '<myNameSpace:count>content</count>';
|
||||
$expected = '<myNameSpace:count>content</myNameSpace:count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content', false);
|
||||
$expected = '<myNameSpace:count>content';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected .= '</myNameSpace:count>';
|
||||
$result .= $this->Xml->closeElem();
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testSerialize method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function testSerialize() {
|
||||
$data = array(
|
||||
'test1' => 'test with no quotes',
|
||||
|
@ -161,12 +114,7 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$expected = '<std_class test1="test with no quotes" test2="test without double quotes" />';
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testHeader method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function testHeader() {
|
||||
$expectedDefaultEncoding = Configure::read('App.encoding');
|
||||
if (empty($expectedDefaultEncoding)) {
|
||||
|
@ -199,12 +147,7 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$expected = '<?xml encoding="UTF-8" someOther="value" ?>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test__ComposeContent method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
/*
|
||||
function test__ComposeContent() {
|
||||
$content = 'some String';
|
||||
$result = $this->Xml->__composeContent($content);
|
||||
|
@ -247,7 +190,7 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$expected = '<para><note>simple note</note></para>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
|
||||
|
||||
function test__prepareNamespaces() {
|
||||
$this->Xml->__namespaces = array('namespace1', 'namespace2');
|
||||
$result = $this->Xml->__prepareNamespaces();
|
||||
|
@ -260,10 +203,10 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$this->assertIdentical($result, $expected);
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
function tearDown() {
|
||||
unset($this->Xml);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
Loading…
Add table
Reference in a new issue