From cbe0bebbb95ea0846a424af6f49cb98dd0727925 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Wed, 12 Jun 2013 22:38:35 +0800 Subject: [PATCH 1/4] add test case for Text_Plain_$type classes --- .../Text_Plain_Dateformat_test.php | 158 ++++++++++++++++++ .../Text_Plain_Download_test.php | 138 +++++++++++++++ .../Text_Plain_External_test.php | 142 ++++++++++++++++ .../Text_Plain_Formatted_test.php | 133 +++++++++++++++ .../transformations/Text_Plain_Hex_test.php | 133 +++++++++++++++ .../Text_Plain_Imagelink_test.php | 136 +++++++++++++++ .../transformations/Text_Plain_Link_test.php | 135 +++++++++++++++ .../Text_Plain_Longtoipv4_test.php | 131 +++++++++++++++ .../transformations/Text_Plain_Sql_test.php | 131 +++++++++++++++ .../Text_Plain_Substring_test.php | 112 +++++++++++++ 10 files changed, 1349 insertions(+) create mode 100644 test/classes/plugin/transformations/Text_Plain_Dateformat_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Download_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_External_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Formatted_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Hex_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Imagelink_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Link_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Longtoipv4_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Sql_test.php create mode 100644 test/classes/plugin/transformations/Text_Plain_Substring_test.php diff --git a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php new file mode 100644 index 0000000000..2804c1aaf0 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php @@ -0,0 +1,158 @@ +object = new Text_Plain_Dateformat(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = 'Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp' + . ' column as formatted date. The first option is the offset (in' + . ' hours) which will be added to the timestamp (Default: 0). Use' + . ' second option to specify a different date/time format string.' + . ' Third option determines whether you want to see local date or' + . ' UTC one (use "local" or "utc" strings) for that. According to' + . ' that, date format has different value - for "local" see the' + . ' documentation for PHP\'s strftime() function and for "utc" it' + . ' is done using gmdate() function.'; + + $this->assertEquals( + $info, + Text_Plain_Dateformat::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Date Format", + Text_Plain_Dateformat::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Dateformat::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Dateformat::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array(2); + $meta = new Text_Plain_Dateformat_Meta(); + $meta->type = 'int'; + $result = '' + . 'Dec 31, 1969 at 11:00 PM'; + $this->assertEquals( + $result, + $this->object->applyTransformation($buffer, $options, $meta) + ); + + $meta->type = 'char'; + $result = '' + . 'Dec 31, 1969 at 11:00 PM'; + $this->assertEquals( + $result, + $this->object->applyTransformation($buffer, $options, $meta) + ); + } +} + +class Text_Plain_Dateformat_Meta +{ + var $blob = null; + var $max_length = null; + var $type = null; +} \ No newline at end of file diff --git a/test/classes/plugin/transformations/Text_Plain_Download_test.php b/test/classes/plugin/transformations/Text_Plain_Download_test.php new file mode 100644 index 0000000000..0f132b968d --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Download_test.php @@ -0,0 +1,138 @@ +object = new Application_Octetstream_Download(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = + 'Displays a link to download the binary data of the column. You can' + . ' use the first option to specify the filename, or use the second' + . ' option as the name of a column which contains the filename. If' + . ' you use the second option, you need to set the first option to' + . ' the empty string.'; + $this->assertEquals( + $info, + Application_Octetstream_Download::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Download", + Application_Octetstream_Download::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Application", + Application_Octetstream_Download::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "OctetStream", + Application_Octetstream_Download::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array("filename", 'wrapper_link'=>'PMA_wrapper_link'); + $result = 'filename'; + $this->assertEquals( + $result, + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_External_test.php b/test/classes/plugin/transformations/Text_Plain_External_test.php new file mode 100644 index 0000000000..5db293bd23 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_External_test.php @@ -0,0 +1,142 @@ +object = new Text_Plain_External(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = + 'LINUX ONLY: Launches an external application and feeds it the column' + . ' data via standard input. Returns the standard output of the' + . ' application. The default is Tidy, to pretty-print HTML code.' + . ' For security reasons, you have to manually edit the file' + . ' libraries/plugins/transformations/Text_Plain_External' + . '.class.php and list the tools you want to make available.' + . ' The first option is then the number of the program you want to' + . ' use and the second option is the parameters for the program.' + . ' The third option, if set to 1, will convert the output using' + . ' htmlspecialchars() (Default 1). The fourth option, if set to 1,' + . ' will prevent wrapping and ensure that the output appears all on' + . ' one line (Default 1).'; + $this->assertEquals( + $info, + Text_Plain_External::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "External", + Text_Plain_External::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_External::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_External::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array("option1", "option2"); + $this->assertEquals( + "PMA_BUFFER", + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Formatted_test.php b/test/classes/plugin/transformations/Text_Plain_Formatted_test.php new file mode 100644 index 0000000000..63e5211673 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Formatted_test.php @@ -0,0 +1,133 @@ +object = new Text_Plain_Formatted(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = + 'Displays the contents of the column as-is, without running it' + . ' through htmlspecialchars(). That is, the column is assumed' + . ' to contain valid HTML.'; + $this->assertEquals( + $info, + Text_Plain_Formatted::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Formatted", + Text_Plain_Formatted::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Formatted::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Formatted::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array("option1", "option2"); + $this->assertEquals( + "PMA_BUFFER", + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Hex_test.php b/test/classes/plugin/transformations/Text_Plain_Hex_test.php new file mode 100644 index 0000000000..ea00904c2c --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Hex_test.php @@ -0,0 +1,133 @@ +object = new Application_Octetstream_Hex(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = + 'Displays hexadecimal representation of data. Optional first' + . ' parameter specifies how often space will be added (defaults' + . ' to 2 nibbles).'; + $this->assertEquals( + $info, + Application_Octetstream_Hex::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Hex", + Application_Octetstream_Hex::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Application", + Application_Octetstream_Hex::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "OctetStream", + Application_Octetstream_Hex::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array(3, "option2"); + $this->assertEquals( + "504 d41 5f4 255 464 645 52 ", + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php b/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php new file mode 100644 index 0000000000..86aa56f873 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php @@ -0,0 +1,136 @@ +object = new Text_Plain_Imagelink(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = 'Displays an image and a link; ' + . 'the column contains the filename. The first option' + . ' is a URL prefix like "http://www.example.com/". The second and third options' + . ' are the width and the height in pixels.'; + $this->assertEquals( + $info, + Text_Plain_Imagelink::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Image Link", + Text_Plain_Imagelink::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Imagelink::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Imagelink::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array("option1", "option2"); + $result = '' + . 'PMA_BUFFER'; + $this->assertEquals( + $result, + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Link_test.php b/test/classes/plugin/transformations/Text_Plain_Link_test.php new file mode 100644 index 0000000000..72032ffdf7 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Link_test.php @@ -0,0 +1,135 @@ +object = new Text_Plain_Link(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = + 'Displays a link; the column contains the filename. The first option' + . ' is a URL prefix like "http://www.example.com/". The second option' + . ' is a title for the link.'; + $this->assertEquals( + $info, + Text_Plain_Link::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "TextLink", + Text_Plain_Link::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Link::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Link::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $options = array("option1", "option2"); + $result = 'option2'; + $this->assertEquals( + $result, + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Longtoipv4_test.php b/test/classes/plugin/transformations/Text_Plain_Longtoipv4_test.php new file mode 100644 index 0000000000..be73fb9ea7 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Longtoipv4_test.php @@ -0,0 +1,131 @@ +object = new Text_Plain_Longtoipv4(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = 'Converts an (IPv4) Internet network address into a string in' + . ' Internet standard dotted format.'; + $this->assertEquals( + $info, + Text_Plain_Longtoipv4::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Long To IPv4", + Text_Plain_Longtoipv4::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Longtoipv4::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Longtoipv4::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = 42949672; + $options = array("option1", "option2"); + $this->assertEquals( + "2.143.92.40", + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Sql_test.php b/test/classes/plugin/transformations/Text_Plain_Sql_test.php new file mode 100644 index 0000000000..c1d0903157 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Sql_test.php @@ -0,0 +1,131 @@ +object = new Text_Plain_Sql(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getInfo + * + * @return void + * + * @group medium + */ + public function testGetInfo() + { + $info = 'Formats text as SQL query with syntax highlighting.'; + $this->assertEquals( + $info, + Text_Plain_Sql::getInfo() + ); + + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "SQL", + Text_Plain_Sql::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Sql::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Sql::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "select *"; + $options = array("option1", "option2"); + $result = '
select *
'; + $this->assertEquals( + $result, + $this->object->applyTransformation($buffer, $options) + ); + } +} diff --git a/test/classes/plugin/transformations/Text_Plain_Substring_test.php b/test/classes/plugin/transformations/Text_Plain_Substring_test.php new file mode 100644 index 0000000000..474a0b05b1 --- /dev/null +++ b/test/classes/plugin/transformations/Text_Plain_Substring_test.php @@ -0,0 +1,112 @@ +object = new Text_Plain_Substring(new PluginManager()); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getName + * + * @return void + * + * @group medium + */ + public function testGetName() + { + $this->assertEquals( + "Substring", + Text_Plain_Substring::getName() + ); + } + + /** + * Test for getMIMEType + * + * @return void + * + * @group medium + */ + public function testGetMIMEType() + { + $this->assertEquals( + "Text", + Text_Plain_Substring::getMIMEType() + ); + } + + /** + * Test for getMIMESubtype + * + * @return void + * + * @group medium + */ + public function testGetMIMESubtype() + { + $this->assertEquals( + "Plain", + Text_Plain_Substring::getMIMESubtype() + ); + } + + /** + * Test for applyTransformation + * + * @return void + * + * @group medium + */ + public function testApplyTransformation() + { + $buffer = "PMA_BUFFER"; + $this->assertEquals( + "PMA_BUFFER", + $this->object->applyTransformation($buffer) + ); + } +} From e03be6c62f75554676af88173f36371b25b3ff37 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Wed, 12 Jun 2013 22:45:30 +0800 Subject: [PATCH 2/4] fix assert failed --- .../plugin/transformations/Text_Plain_Dateformat_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php index 2804c1aaf0..4341bbfc96 100644 --- a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php @@ -134,7 +134,7 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase $meta = new Text_Plain_Dateformat_Meta(); $meta->type = 'int'; $result = '' - . 'Dec 31, 1969 at 11:00 PM'; + . 'Dec 31, 1969 at 10:00 PM'; $this->assertEquals( $result, $this->object->applyTransformation($buffer, $options, $meta) @@ -142,7 +142,7 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase $meta->type = 'char'; $result = '' - . 'Dec 31, 1969 at 11:00 PM'; + . 'Dec 31, 1969 at 10:00 PM'; $this->assertEquals( $result, $this->object->applyTransformation($buffer, $options, $meta) From 3cea36f8b002ca108f9d0426ab99eb0a17cbc05d Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Thu, 13 Jun 2013 21:09:33 +0800 Subject: [PATCH 3/4] modify the test cases to better ones --- .../Text_Plain_Dateformat_test.php | 18 +++++------------- .../Text_Plain_External_test.php | 2 +- .../transformations/Text_Plain_Hex_test.php | 13 ++++++++++--- .../Text_Plain_Imagelink_test.php | 10 +++++----- .../transformations/Text_Plain_Link_test.php | 8 ++++---- .../Text_Plain_Substring_test.php | 5 +++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php index 4341bbfc96..dc677127ab 100644 --- a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php @@ -129,23 +129,15 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase */ public function testApplyTransformation() { - $buffer = "PMA_BUFFER"; - $options = array(2); + $timestamp = 12345; + $options = array(0); $meta = new Text_Plain_Dateformat_Meta(); $meta->type = 'int'; - $result = '' - . 'Dec 31, 1969 at 10:00 PM'; + $result = '' + . 'Jan 01, 1970 at 04:25 AM'; $this->assertEquals( $result, - $this->object->applyTransformation($buffer, $options, $meta) - ); - - $meta->type = 'char'; - $result = '' - . 'Dec 31, 1969 at 10:00 PM'; - $this->assertEquals( - $result, - $this->object->applyTransformation($buffer, $options, $meta) + $this->object->applyTransformation($timestamp, $options, $meta) ); } } diff --git a/test/classes/plugin/transformations/Text_Plain_External_test.php b/test/classes/plugin/transformations/Text_Plain_External_test.php index 5db293bd23..9a37cdcd81 100644 --- a/test/classes/plugin/transformations/Text_Plain_External_test.php +++ b/test/classes/plugin/transformations/Text_Plain_External_test.php @@ -133,7 +133,7 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase public function testApplyTransformation() { $buffer = "PMA_BUFFER"; - $options = array("option1", "option2"); + $options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q"); $this->assertEquals( "PMA_BUFFER", $this->object->applyTransformation($buffer, $options) diff --git a/test/classes/plugin/transformations/Text_Plain_Hex_test.php b/test/classes/plugin/transformations/Text_Plain_Hex_test.php index ea00904c2c..138aac1b0b 100644 --- a/test/classes/plugin/transformations/Text_Plain_Hex_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Hex_test.php @@ -123,10 +123,17 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase */ public function testApplyTransformation() { - $buffer = "PMA_BUFFER"; - $options = array(3, "option2"); + $buffer = "11111001"; + $options = array(3); $this->assertEquals( - "504 d41 5f4 255 464 645 52 ", + "313 131 313 130 303 1 ", + $this->object->applyTransformation($buffer, $options) + ); + + $buffer = "11111001"; + $options = array(0); + $this->assertEquals( + "3131313131303031", $this->object->applyTransformation($buffer, $options) ); } diff --git a/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php b/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php index 86aa56f873..7a88c08350 100644 --- a/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Imagelink_test.php @@ -123,11 +123,11 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase */ public function testApplyTransformation() { - $buffer = "PMA_BUFFER"; - $options = array("option1", "option2"); - $result = '' - . 'PMA_BUFFER'; + $buffer = "PMA_IMAGE"; + $options = array("./image/", "200"); + $result = '' + . 'PMA_IMAGE'; $this->assertEquals( $result, $this->object->applyTransformation($buffer, $options) diff --git a/test/classes/plugin/transformations/Text_Plain_Link_test.php b/test/classes/plugin/transformations/Text_Plain_Link_test.php index 72032ffdf7..39ba902a14 100644 --- a/test/classes/plugin/transformations/Text_Plain_Link_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Link_test.php @@ -123,10 +123,10 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase */ public function testApplyTransformation() { - $buffer = "PMA_BUFFER"; - $options = array("option1", "option2"); - $result = 'option2'; + $buffer = "PMA_TXT_LINK"; + $options = array("./php/", "text_name"); + $result = 'text_name'; $this->assertEquals( $result, $this->object->applyTransformation($buffer, $options) diff --git a/test/classes/plugin/transformations/Text_Plain_Substring_test.php b/test/classes/plugin/transformations/Text_Plain_Substring_test.php index 474a0b05b1..64c554e682 100644 --- a/test/classes/plugin/transformations/Text_Plain_Substring_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Substring_test.php @@ -104,9 +104,10 @@ class Text_Plain_Substring_Test extends PHPUnit_Framework_TestCase public function testApplyTransformation() { $buffer = "PMA_BUFFER"; + $options = array(1, 3, 'suffix'); $this->assertEquals( - "PMA_BUFFER", - $this->object->applyTransformation($buffer) + "suffixMA_suffix", + $this->object->applyTransformation($buffer, $options) ); } } From a2e21be0b73beddf085cd7c34db84887438d9cc0 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Thu, 13 Jun 2013 22:54:20 +0800 Subject: [PATCH 4/4] using HTML tag when testing Text_Plain_Formatted --- .../plugin/transformations/Text_Plain_Formatted_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/plugin/transformations/Text_Plain_Formatted_test.php b/test/classes/plugin/transformations/Text_Plain_Formatted_test.php index 63e5211673..93484fd260 100644 --- a/test/classes/plugin/transformations/Text_Plain_Formatted_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Formatted_test.php @@ -123,10 +123,10 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase */ public function testApplyTransformation() { - $buffer = "PMA_BUFFER"; + $buffer = "PMA_BUFFER"; $options = array("option1", "option2"); $this->assertEquals( - "PMA_BUFFER", + $buffer, $this->object->applyTransformation($buffer, $options) ); }