mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 07:29:51 +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');
|
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 {
|
class TestXml extends Object {
|
||||||
/**
|
|
||||||
* content property
|
|
||||||
*
|
|
||||||
* @var string ''
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $content = '';
|
var $content = '';
|
||||||
/**
|
|
||||||
* construct method
|
|
||||||
*
|
|
||||||
* @param mixed $content
|
|
||||||
* @access private
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function __construct($content) {
|
function __construct($content) {
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* toString method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function toString() {
|
function toString() {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
@ -72,21 +50,12 @@ class TestXml extends Object {
|
||||||
* @subpackage cake.tests.cases.libs.view.helpers
|
* @subpackage cake.tests.cases.libs.view.helpers
|
||||||
*/
|
*/
|
||||||
class XmlHelperTest extends UnitTestCase {
|
class XmlHelperTest extends UnitTestCase {
|
||||||
/**
|
|
||||||
* setUp method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
$this->Xml =& new XmlHelper();
|
$this->Xml =& new XmlHelper();
|
||||||
|
$this->Xml->beforeRender();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* testAddNamespace method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testAddNamespace() {
|
function testAddNamespace() {
|
||||||
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
||||||
$manager =& XmlManager::getInstance();
|
$manager =& XmlManager::getInstance();
|
||||||
|
@ -94,12 +63,7 @@ class XmlHelperTest extends UnitTestCase {
|
||||||
$expected = array('custom' => 'http://example.com/dtd.xml');
|
$expected = array('custom' => 'http://example.com/dtd.xml');
|
||||||
$this->assertEqual($manager->namespaces, $expected);
|
$this->assertEqual($manager->namespaces, $expected);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* testRemoveNamespace method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testRemoveNamespace() {
|
function testRemoveNamespace() {
|
||||||
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
||||||
$this->Xml->addNs('custom2', 'http://example.com/dtd2.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');
|
$expected = array('custom2' => 'http://example.com/dtd2.xml');
|
||||||
$this->assertEqual($manager->namespaces, $expected);
|
$this->assertEqual($manager->namespaces, $expected);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* testRenderZeroElement method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testRenderZeroElement() {
|
function testRenderZeroElement() {
|
||||||
$result = $this->Xml->elem('count', null, 0);
|
$result = $this->Xml->elem('count', null, 0);
|
||||||
$expected = '<count>0</count>';
|
$expected = '<count>0</count>';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* testRenderElementWithNamespace method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testRenderElementWithNamespace() {
|
function testRenderElementWithNamespace() {
|
||||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
|
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
|
||||||
$expected = '<myNameSpace:count>content</count>';
|
$expected = '<myNameSpace:count>content</myNameSpace:count>';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content', false);
|
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content', false);
|
||||||
$expected = '<myNameSpace:count>content';
|
$expected = '<myNameSpace:count>content';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$expected .= '</myNameSpace:count>';
|
||||||
|
$result .= $this->Xml->closeElem();
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* testSerialize method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testSerialize() {
|
function testSerialize() {
|
||||||
$data = array(
|
$data = array(
|
||||||
'test1' => 'test with no quotes',
|
'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" />';
|
$expected = '<std_class test1="test with no quotes" test2="test without double quotes" />';
|
||||||
$this->assertIdentical($result, $expected);
|
$this->assertIdentical($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* testHeader method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testHeader() {
|
function testHeader() {
|
||||||
$expectedDefaultEncoding = Configure::read('App.encoding');
|
$expectedDefaultEncoding = Configure::read('App.encoding');
|
||||||
if (empty($expectedDefaultEncoding)) {
|
if (empty($expectedDefaultEncoding)) {
|
||||||
|
@ -199,12 +147,7 @@ class XmlHelperTest extends UnitTestCase {
|
||||||
$expected = '<?xml encoding="UTF-8" someOther="value" ?>';
|
$expected = '<?xml encoding="UTF-8" someOther="value" ?>';
|
||||||
$this->assertIdentical($result, $expected);
|
$this->assertIdentical($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/*
|
||||||
* test__ComposeContent method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function test__ComposeContent() {
|
function test__ComposeContent() {
|
||||||
$content = 'some String';
|
$content = 'some String';
|
||||||
$result = $this->Xml->__composeContent($content);
|
$result = $this->Xml->__composeContent($content);
|
||||||
|
@ -247,7 +190,7 @@ class XmlHelperTest extends UnitTestCase {
|
||||||
$expected = '<para><note>simple note</note></para>';
|
$expected = '<para><note>simple note</note></para>';
|
||||||
$this->assertIdentical($result, $expected);
|
$this->assertIdentical($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test__prepareNamespaces() {
|
function test__prepareNamespaces() {
|
||||||
$this->Xml->__namespaces = array('namespace1', 'namespace2');
|
$this->Xml->__namespaces = array('namespace1', 'namespace2');
|
||||||
$result = $this->Xml->__prepareNamespaces();
|
$result = $this->Xml->__prepareNamespaces();
|
||||||
|
@ -260,10 +203,10 @@ class XmlHelperTest extends UnitTestCase {
|
||||||
$this->assertIdentical($result, $expected);
|
$this->assertIdentical($result, $expected);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
unset($this->Xml);
|
unset($this->Xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue