From d84327e69e858d369ea0c78f6106cfaa54994032 Mon Sep 17 00:00:00 2001
From: knut <>
Date: Fri, 12 May 2006 06:11:39 +0000
Subject: Added unit tests for TXmlTransform control #99
---
.../unit/Web/UI/WebControls/TXmlTransformTest.php | 129 +++++++++++++++++++++
tests/unit/Web/UI/WebControls/data/hello.xml | 2 +
tests/unit/Web/UI/WebControls/data/hello.xsl | 5 +
3 files changed, 136 insertions(+)
create mode 100644 tests/unit/Web/UI/WebControls/TXmlTransformTest.php
create mode 100644 tests/unit/Web/UI/WebControls/data/hello.xml
create mode 100644 tests/unit/Web/UI/WebControls/data/hello.xsl
(limited to 'tests/unit/Web')
diff --git a/tests/unit/Web/UI/WebControls/TXmlTransformTest.php b/tests/unit/Web/UI/WebControls/TXmlTransformTest.php
new file mode 100644
index 00000000..e277edbd
--- /dev/null
+++ b/tests/unit/Web/UI/WebControls/TXmlTransformTest.php
@@ -0,0 +1,129 @@
+documentPath = dirname(__FILE__).'/data/hello.xml';
+ $this->documentContent = file_get_contents($this->documentPath);
+ $this->transformPath = dirname(__FILE__).'/data/hello.xsl';
+ $this->transformContent = file_get_contents($this->transformPath);
+ }
+
+ public function testSetDocumentContent() {
+ $expected = $this->documentContent;
+ $transform = new TXmlTransform();
+ $transform->setDocumentContent($expected);
+ $this->assertEquals($expected, $transform->getDocumentContent());
+ }
+
+ public function testSetDocumentPathAsFile() {
+ $expected = $this->documentPath;
+ $transform = new TXmlTransform();
+ $transform->setDocumentPath($expected);
+ $this->assertEquals($expected, $transform->getDocumentPath());
+ }
+
+ public function testSetDocumentPathAsNamespace() {
+ if(Prado::getPathOfAlias('UnitTest') === null) {
+ Prado::setPathOfAlias('UnitTest', dirname(__FILE__).'/data');
+ }
+ $expected = $this->documentPath;
+ $transform = new TXmlTransform();
+ $transform->setDocumentPath('UnitTest.hello');
+ $this->assertEquals($expected, $transform->getDocumentPath());
+ }
+
+ public function testSetTransformContent() {
+ $expected = $this->transformContent;
+ $transform = new TXmlTransform();
+ $transform->setTransformContent($expected);
+ $this->assertEquals($expected, $transform->getTransformContent());
+ }
+
+ public function testSetTransformPathAsFile() {
+ $expected = $this->transformPath;
+ $transform = new TXmlTransform();
+ $transform->setTransformPath($expected);
+ $this->assertEquals($expected, $transform->getTransformPath());
+ }
+
+ public function testSetTransformPathAsNamespace() {
+ if(Prado::getPathOfAlias('UnitTest') === null) {
+ Prado::setPathOfAlias('UnitTest', dirname(__FILE__).'/data');
+ }
+ $expected = $this->transformPath;
+ $transform = new TXmlTransform();
+ $transform->setTransformPath('UnitTest.hello');
+ $this->assertEquals($expected, $transform->getTransformPath());
+ }
+
+ public function testAddParameter() {
+ throw new PHPUnit2_Framework_IncompleteTestError();
+ }
+
+ public function testRenderWithDocumentContentAndTransformContent() {
+ $expected = "Hello World!\n";
+ $transform = new TXmlTransform();
+ $transform->setDocumentContent($this->documentContent);
+ $transform->setTransformContent($this->transformContent);
+ $textWriter = new TTextWriter();
+ $htmlWriter = new THtmlWriter($textWriter);
+ $transform->render($htmlWriter);
+ $actual = $textWriter->flush();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testRenderWithDocumentPathAndTransformContent() {
+ $expected = "Hello World!\n";
+ $transform = new TXmlTransform();
+ $transform->setDocumentPath($this->documentPath);
+ $transform->setTransformContent($this->transformContent);
+ $textWriter = new TTextWriter();
+ $htmlWriter = new THtmlWriter($textWriter);
+ $transform->render($htmlWriter);
+ $actual = $textWriter->flush();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testRenderWithDocumentContentAndTransformPath() {
+ $expected = "Hello World!\n";
+ $transform = new TXmlTransform();
+ $transform->setDocumentContent($this->documentContent);
+ $transform->setTransformPath($this->transformPath);
+ $textWriter = new TTextWriter();
+ $htmlWriter = new THtmlWriter($textWriter);
+ $transform->render($htmlWriter);
+ $actual = $textWriter->flush();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testRenderWithDocumentPathAndTransformPath() {
+ $expected = "Hello World!\n";
+ $transform = new TXmlTransform();
+ $transform->setDocumentPath($this->documentPath);
+ $transform->setTransformPath($this->transformPath);
+ $textWriter = new TTextWriter();
+ $htmlWriter = new THtmlWriter($textWriter);
+ $transform->render($htmlWriter);
+ $actual = $textWriter->flush();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testRenderWithBodyAsDocumentAndTransformPath() {
+ throw new PHPUnit2_Framework_IncompleteTestError();
+ }
+}
+
+?>
diff --git a/tests/unit/Web/UI/WebControls/data/hello.xml b/tests/unit/Web/UI/WebControls/data/hello.xml
new file mode 100644
index 00000000..9f8b12ee
--- /dev/null
+++ b/tests/unit/Web/UI/WebControls/data/hello.xml
@@ -0,0 +1,2 @@
+
+Hello World!
diff --git a/tests/unit/Web/UI/WebControls/data/hello.xsl b/tests/unit/Web/UI/WebControls/data/hello.xsl
new file mode 100644
index 00000000..f0664464
--- /dev/null
+++ b/tests/unit/Web/UI/WebControls/data/hello.xsl
@@ -0,0 +1,5 @@
+
+
+
+
+
--
cgit v1.2.3