<?php

	include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
	include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
	include_once( 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");
				
			// process each one of them
			foreach( $tests as $input => $output ) {
				$result = $this->tf->slugify( $input );
				$this->assertEquals( $output, $result );
			}
		}
	}
?>