[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/dao/article.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/dao/usercomment.class.php" ); 7 8 /** 9 * \ingroup Test 10 * 11 * Test cases for the Article class 12 */ 13 class Article_Test extends LifeTypeTestCase 14 { 15 function setUp() 16 { 17 // 18 // Note: if you are going to copy this code for another test, note that this code 19 // doesn't ever add this article to the database, since if it did, it could 20 // potentially overwrite your real blog data... 21 // 22 // build a dummy Article object 23 $this->article = new Article( 24 "dummy topic", 25 "dummy text", 26 Array( 1 ), // a dummy category 27 Array( 1 ), // a dummy user 28 1, // a dummy blog 29 POST_STATUS_PUBLISHED, // published status 30 0 // not read yet 31 ); 32 } 33 34 /** 35 * regression test for mantis case 986 (http://bugs.lifetype.net/view.php?id=986) 36 * and for method Article::hasExtendedText in general 37 */ 38 function testHasExtendedText() 39 { 40 // set some normal extended text, it should return true 41 $this->article->setExtendedText( "this is a test" ); 42 $this->assertTrue( $this->article->hasExtendedText(), "Extended text was set but hasExtendedText returned false!" ); 43 44 // remove the text and try again 45 $this->article->setExtendedText( "" ); 46 $this->assertFalse( $this->article->hasExtendedText(), "there is no text set but hasExtendedText did not return false!" ); 47 48 // set some text that should work as empty 49 foreach( Array( "<br/>", "<br />", "<p/>", "<p />", "" ) as $emptyText ) { 50 $this->article->setExtendedText( $emptyText ); 51 $this->assertFalse( $this->article->hasExtendedText(), 52 "extended text set to ".htmlspecialchars($emptyText).", which should count as no extended text ". 53 "but hasExtendedText did not return false!" ); 54 } 55 } 56 57 /** 58 * Test case for mantis issue http://bugs.lifetype.net/view.php?id=1244, 59 * Articles::setComments() not using the same internal array used by 60 * Articles::getComments() 61 */ 62 function testSetCommentsAndGetComments() 63 { 64 // create a dummy comment 65 $c = new UserComment( $this->article->getId(), 66 $this->article->getBlogId(), 67 0, 68 "topic", 69 "text" 70 ); 71 72 $cSpam = new UserComment( $this->article->getId(), 73 $this->article->getBlogId(), 74 0, 75 "topic spam", 76 "text spam" 77 ); 78 $cSpam->setStatus( COMMENT_STATUS_SPAM ); 79 80 // now calling Article::getComments() after Article::setComments() with the dummy comment above 81 // should not return the same 82 $this->article->setComments( Array( $c )); 83 $this->article->setComments( Array( $cSpam ), COMMENT_STATUS_SPAM ); 84 $this->assertEquals( Array( $c ), $this->article->getComments()); 85 $this->assertEquals( Array( $cSpam ), $this->article->getComments( COMMENT_STATUS_SPAM )); 86 } 87 } 88 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |