Merge pull request #444 from adamgsoc2013/UT_pluginss
add other test case for more coverage
This commit is contained in:
commit
ab13abccaf
@ -12,7 +12,7 @@
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/plugins/PluginManager.class.php';
|
||||
require_once 'libraries/plugins/transformations/Text_Plain_Append.class.php';
|
||||
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
/**
|
||||
* Tests for Text_Plain_Append class
|
||||
*
|
||||
@ -127,5 +127,18 @@ class Text_Plain_Append_Test extends PHPUnit_Framework_TestCase
|
||||
"PMA_BUFFERoption1",
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
//no options
|
||||
$result = "PMA_BUFFER";
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($buffer)
|
||||
);
|
||||
//html string
|
||||
$result = "PMA_BUFFER<a>abc</a>";
|
||||
$options = array("<a>abc</a>");
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
*/
|
||||
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/plugins/PluginManager.class.php';
|
||||
require_once 'libraries/plugins/transformations/Text_Plain_Dateformat.class.php';
|
||||
|
||||
@ -141,6 +143,35 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
|
||||
$result,
|
||||
$this->object->applyTransformation($timestamp, $options, $meta)
|
||||
);
|
||||
|
||||
//other format timestamp, Detect TIMESTAMP(6 | 8 | 10 | 12 | 14)
|
||||
$meta->type = 'string';
|
||||
$timestamp = 12345678;
|
||||
$result = '<dfn onclick="alert(\'12345678\');" title="12345678">'
|
||||
. 'May 23, 1970 at 09:21 PM</dfn>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($timestamp, $options, $meta)
|
||||
);
|
||||
|
||||
//no MYSQL timestamp
|
||||
$timestamp = 123456789;
|
||||
$result = '<dfn onclick="alert(\'123456789\');" title="123456789">'
|
||||
. 'Nov 29, 1973 at 09:33 PM</dfn>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($timestamp, $options, $meta)
|
||||
);
|
||||
|
||||
//string
|
||||
$timestamp = "20100201";
|
||||
$result = '<dfn onclick="alert(\'20100201\');" title="20100201">Feb 01, 2010 at 12:00 AM</dfn>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($timestamp, $options, $meta)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
*/
|
||||
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/plugins/PluginManager.class.php';
|
||||
require_once 'libraries/plugins/transformations/Application_Octetstream_Download.class.php';
|
||||
|
||||
@ -35,6 +37,9 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new Application_Octetstream_Download(new PluginManager());
|
||||
global $row, $fields_meta;
|
||||
$fields_meta = array();
|
||||
$row = array("pma"=>"aaa", "pca"=>"bbb");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,6 +138,16 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
);
|
||||
|
||||
//using default filename: binary_file.dat
|
||||
$options = array("", 'cloumn', 'wrapper_link'=>'PMA_wrapper_link');
|
||||
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link&'
|
||||
. 'ct=application/octet-stream&cn=binary_file.dat" '
|
||||
. 'title="binary_file.dat">binary_file.dat</a>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/plugins/PluginManager.class.php';
|
||||
require_once 'libraries/plugins/transformations/Text_Plain_External.class.php';
|
||||
|
||||
@ -139,4 +140,35 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for applyTransformationNoWrap
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @group medium
|
||||
*/
|
||||
public function testApplyTransformationNoWrap()
|
||||
{
|
||||
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q");
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$this->object->applyTransformationNoWrap($options)
|
||||
);
|
||||
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", 1);
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$this->object->applyTransformationNoWrap($options)
|
||||
);
|
||||
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "1");
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$this->object->applyTransformationNoWrap($options)
|
||||
);
|
||||
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", 2);
|
||||
$this->assertEquals(
|
||||
false,
|
||||
$this->object->applyTransformationNoWrap($options)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/plugins/PluginManager.class.php';
|
||||
require_once 'libraries/plugins/transformations/Application_Octetstream_Hex.class.php';
|
||||
|
||||
@ -135,6 +136,14 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
"3131313131303031",
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
);
|
||||
|
||||
//no option
|
||||
$buffer = "11111001";
|
||||
$this->assertEquals(
|
||||
"31 31 31 31 31 30 30 31 ",
|
||||
$this->object->applyTransformation($buffer)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/plugins/PluginManager.class.php';
|
||||
require_once 'libraries/plugins/transformations/Text_Plain_Longtoipv4.class.php';
|
||||
|
||||
@ -126,6 +127,14 @@ class Text_Plain_Longtoipv4_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
"2.143.92.40",
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
);
|
||||
|
||||
//too big
|
||||
$buffer = 4294967295;
|
||||
$options = array("option1", "option2");
|
||||
$this->assertEquals(
|
||||
"255.255.255.255",
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user