[ 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/bloginfo.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); 6 7 /** 8 * \ingroup Test 9 * 10 * Test cases for the Blogs class 11 */ 12 class Blogs_Test extends LifeTypeTestCase 13 { 14 /** 15 * regression test for Mantis 1005 (http://bugs.lifetype.net/view.php?id=1005) 16 */ 17 function testAddBlogUniqueMangledBlog() 18 { 19 $blogs = new Blogs(); 20 21 // create two blogs, both with the same name. The mangled_blog field should be 'xxx' for the first 22 // one that was added and 'xxx2' for the second one. If not, throw an error. 23 24 // an absolutely random name 25 $randomName = md5(time()); 26 27 // add the blogs 28 $blog1 = new BlogInfo( $randomName, 1, "About blog 1", new BlogSettings()); 29 $blog2 = new BlogInfo( $randomName, 1, "About blog 2", new BlogSettings()); 30 $blog3 = new BlogInfo( $randomName, 1, "About blog 3", new BlogSettings()); 31 $blogs->addBlog( $blog1 ); 32 $blogs->addBlog( $blog2 ); 33 $blogs->addBlog( $blog3 ); 34 35 // compare the mangled names 36 $this->assertEquals( $randomName, $blog1->getMangledBlogName()); 37 $this->assertEquals( $randomName."2", $blog2->getMangledBlogName()); 38 $this->assertEquals( $randomName."3", $blog3->getMangledBlogName()); 39 40 // delete the temporary blogs 41 $blogs->deleteBlog( $blog1->getId()); 42 $blogs->deleteBlog( $blog2->getId()); 43 $blogs->deleteBlog( $blog3->getId()); 44 } 45 46 /** 47 * regression test for Mantis 1005 (http://bugs.lifetype.net/view.php?id=1005) 48 * Blog names ("mangled names") should be kept unique accross blog updates! 49 */ 50 function testUpdateBlogUniqueMangledBlog() 51 { 52 $blogs = new Blogs(); 53 54 // create two blogs, both with the same name. The mangled_blog field should be 'xxx' for the first 55 // one that was added and 'xxx2' for the second one. If not, throw an error. 56 57 // an absolutely random name 58 $randomName = md5(time()); 59 60 // add the blogs 61 $blog1 = new BlogInfo( $randomName, 1, "About blog 1", new BlogSettings()); 62 $blog2 = new BlogInfo( $randomName, 1, "About blog 2", new BlogSettings()); 63 $blog3 = new BlogInfo( $randomName, 1, "About blog 3", new BlogSettings()); 64 $blogs->addBlog( $blog1 ); 65 $blogs->addBlog( $blog2 ); 66 $blogs->addBlog( $blog3 ); 67 68 // update the name and the mangled blog name, in the same way it is done in 69 // class/action/admin/adminupdateblogsettingsaction.class.php 70 $blog1->setBlog( $randomName ); 71 $blog1->setMangledBlogName( $randomName, true ); 72 $blogs->updateBlog( $blog1 ); 73 $blog2->setMangledBlogName( $randomName, true ); 74 $blog2->setBlog( $randomName ); 75 $blog2->setMangledBlogName( $randomName, true ); 76 $blogs->updateBlog( $blog2 ); 77 $blog3->setMangledBlogName( $randomName, true ); 78 $blog3->setBlog( $randomName ); 79 $blogs->updateBlog( $blog3 ); 80 81 // compare the mangled names 82 $this->assertEquals( $randomName, $blog1->getMangledBlogName()); 83 $this->assertEquals( $randomName."2", $blog2->getMangledBlogName()); 84 $this->assertEquals( $randomName."3", $blog3->getMangledBlogName()); 85 86 // delete the temporary blogs 87 $blogs->deleteBlog( $blog1->getId()); 88 $blogs->deleteBlog( $blog2->getId()); 89 $blogs->deleteBlog( $blog3->getId()); 90 } 91 92 93 } 94 ?>
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 |
![]() |