<?php

	include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
	include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );

	/**
	 * \ingroup Test
	 *
	 * Test cases for the Article class
	 */
	class Article_Test extends LifeTypeTestCase
	{
		function setUp()
		{
			// build a dummy Article object			
			$this->article = new Article(
				"dummy topic",
				"dummy text",
				Array( 1 ),   // a dummy category
				Array( 1 ),   // a dummy user
				POST_STATUS_PUBLISHED,  // published status
				0   // not read yet
			);	
		}
		
		/** 
		 * regression test for mantis case 986 (http://bugs.lifetype.net/view.php?id=986)
		 * and for method Article::hasExtendedText in general
		 */
		function testHasExtendedText()
		{
			// set some normal extended text, it should return true
			$this->article->setExtendedText( "this is a test" );
			$this->assertTrue( $this->article->hasExtendedText(), "Extended text was set but hasExtendedText returned false!" );
			
			// remove the text and try again
			$this->article->setExtendedText( "" );
			$this->assertFalse( $this->article->hasExtendedText(), "there is no text set but hasExtendedText did not return false!" );			
			
			// set some text that should work as empty
			foreach( Array( "<br/>", "<br />", "<p/>", "<p />", "" ) as $emptyText ) {
				$this->article->setExtendedText( $emptyText );
				$this->assertFalse( $this->article->hasExtendedText(), 
				                    "extended text set to ".htmlspecialchars($emptyText).", which should count as no extended text ".
				                    "but hasExtendedText did not return false!" );						
			}
		}
	}
?>