⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textfilter_test.class.php

📁 一个用PHP编写的
💻 PHP
字号:
<?php	lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );	lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );	lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );	/**	 * \ingroup Test	 *	 * Test cases for the Textfilter class	 */	class Textfilter_Test extends LifeTypeTestCase	{		function setup()		{			$this->tf = new Textfilter();		}				/**		 * Verifies the 'slugify' method		 */		function testSlugify()		{			// load the value of the default separator			$config =& Config::getConfig();            $sep = $config->getValue( "urlize_word_separator", URLIZE_WORD_SEPARATOR_DEFAULT );									$tests = Array(  // associative array where the key is the input and the value is the expected output				"simple" => "simple",				"two words" => "two{$sep}words",				"two  spaces" => "two{$sep}spaces",				"   leadingblanks" => "leadingblanks",				"trailingblanks  " => "trailingblanks",				"!@#extraseparators'''" => "extraseparators",				"<a>html</a><b>is</b><h1>not</h1><p>allowed</p>"                 => "htmlisnotallowed",				"unclosed < html</a><b >shouldn't </b>be<h1> <p>stripped</p>"                 => "unclosed{$sep}htmlshouldn{$sep}t{$sep}be{$sep}stripped",                "SOME uppercase CHARAcTERS" => "some{$sep}uppercase{$sep}characters" );							// process each one of them			foreach( $tests as $input => $output ) {				$result = $this->tf->slugify( $input );				$this->assertEquals( $output, $result );			}		}				/**		 * Verifies the domainize() method		 */		function testDomainize()		{			// load the value of the default separator			$config =& Config::getConfig();            $sep = $config->getValue( "urlize_word_separator", URLIZE_WORD_SEPARATOR_DEFAULT );									// set of input values and their expected output			$tests = Array(				"TesT BlOg" => "test{$sep}blog",				"test-blog" => "test{$sep}blog",				"test_blog" => "test{$sep}blog",				"test.blog" => "test.blog",				"??test//blog" => "test{$sep}blog",				"==================test blog" => "test{$sep}blog",				"this.has.dots_and-hyphens----and   spaces		    " => "this.has.dots{$sep}and{$sep}hyphens{$sep}and{$sep}spaces"			);						foreach( $tests as $input => $output ) {				$result = $this->tf->domainize( $input );				$this->assertEquals( $output, $result, "input was: $input" );			}		}		/**		 * Verifies the urlize() method		 */		function testUrlize()		{			// load the value of the default separator			$config =& Config::getConfig();            $sep = $config->getValue( "urlize_word_separator", URLIZE_WORD_SEPARATOR_DEFAULT );									// set of input values and their expected output			$tests = Array(				"teSt blog" => "test{$sep}blog",				"test-blog" => "test-blog",				"test_blog" => "test_blog",				"test.blog" => "test.blog",				"??test//blog" => "test{$sep}blog",				"==================test blog" => "test{$sep}blog",				"this.has.dots_and-hyphens----and   spaces		    " => "this.has.dots_and-hyphens{$sep}and{$sep}spaces",				"multiple__underscores______" => "multiple__underscores______"			);						foreach( $tests as $input => $output ) {				$result = $this->tf->urlize( $input );				$this->assertEquals( $output, $result, "input was: $input" );			}		}        		/**		 * tests the htmlDecode() method		 */		function testHtmlDecode()		{			// array with strings and the expected result, the key is the			// input and the value is the expected output, add more if needed			$tests = Array(				"&amp;" => "&",				"test" => "test",				"&aacute;&eacute;" => "衢",				"&auml;&Uuml;" => "滠"			);						foreach( $tests as $input => $output ) {				// check that the input is equal to the output after processing it with TextFilter::htmlDecode				$this->assertEquals( $output, TextFilter::htmlDecode( $input ), "Error htmlDecode()-ing string: $input" );				// and that htmlDecode and filterHTMLEntities are really the opposite of each other				$this->assertEquals( $output, Textfilter::htmlDecode( TextFilter::filterHTMLEntities( $output )));			}		}	}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -