phpmyadmin/test/classes/plugin/transformations/Text_Plain_Substring_test.php
2013-08-05 22:48:49 +08:00

135 lines
2.9 KiB
PHP

<?php
/**
* Tests for Text_Plain_Substring class
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
/* 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_Substring.class.php';
/**
* Tests for Text_Plain_Substring class
*
* @package PhpMyAdmin-test
*/
class Text_Plain_Substring_Test extends PHPUnit_Framework_TestCase
{
/**
* @access protected
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
$this->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 getInfo
*
* @return void
*
* @group medium
*/
public function testGetInfo()
{
$info = 'Displays a part of a string. The first option is the number of'
. ' characters to skip from the beginning of the string (Default 0).'
. ' The second option is the number of characters to return (Default:'
. ' until end of string). The third option is the string to append';
$this->assertContains(
$info,
Text_Plain_Substring::getInfo()
);
}
/**
* 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";
$options = array(1, 3, 'suffix');
$this->assertEquals(
"suffixMA_suffix",
$this->object->applyTransformation($buffer, $options)
);
}
}