/** * Checks if stdWrap.cropHTML handles linebreaks correctly (by ignoring them) * * @test */ public function cropHtmlWorksWithLinebreaks() { $subject = "Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam"; $expected = "Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna"; $result = $this->subject->cropHTML($subject, '121'); $this->assertEquals($expected, $result); }
/** * Checks if stdWrap.cropHTML works with a complex content with many tags. Currently cropHTML * counts multiple invisible characters not as one (as the browser will output the content). * * @test */ public function cropHtmlWorksWithComplexContent() { $GLOBALS['TSFE']->renderCharset = 'iso-8859-1'; $subject = ' <h1>Blog Example</h1> <hr> <div class="csc-header csc-header-n1"> <h2 class="csc-firstHeader">Welcome to Blog #1</h2> </div> <p class="bodytext"> A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>. </p> <div class="tx-blogexample-list-container"> <p class="bodytext"> Below are the most recent posts: </p> <ul> <li> <h3> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog]=&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=003b0131ed">The Post #1</a> </h3> <p class="bodytext"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut... </p> <p class="metadata"> Published on 26.08.2009 by Jochen Rau </p> <p> Tags: [MVC] [Domain Driven Design] <br> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=f982643bc3">read more >></a><br> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=edit&tx_blogexample_pi1[controller]=Post&cHash=5b481bc8f0">Edit</a> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=delete&tx_blogexample_pi1[controller]=Post&cHash=4e52879656">Delete</a> </p> </li> </ul> <p> <a href="index.php?id=99&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=new&tx_blogexample_pi1[controller]=Post&cHash=2718a4b1a0">Create a new Post</a> </p> </div> <hr> <p> ? TYPO3 Association </p> '; $result = $this->cObj->cropHTML($subject, '300'); $expected = ' <h1>Blog Example</h1> <hr> <div class="csc-header csc-header-n1"> <h2 class="csc-firstHeader">Welcome to Blog #1</h2> </div> <p class="bodytext"> A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>. </p> <div class="tx-blogexample-list-container"> <p class="bodytext"> Below are the most recent posts: </p> <ul> <li> <h3> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog]=&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=003b0131ed">The Pos</a></h3></li></ul></div>'; $this->assertEquals($expected, $result); $result = $this->cObj->cropHTML($subject, '-100'); $expected = '<div class="tx-blogexample-list-container"><ul><li><p>Design] <br> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=f982643bc3">read more >></a><br> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=edit&tx_blogexample_pi1[controller]=Post&cHash=5b481bc8f0">Edit</a> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=delete&tx_blogexample_pi1[controller]=Post&cHash=4e52879656">Delete</a> </p> </li> </ul> <p> <a href="index.php?id=99&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=new&tx_blogexample_pi1[controller]=Post&cHash=2718a4b1a0">Create a new Post</a> </p> </div> <hr> <p> ? TYPO3 Association </p> '; $this->assertEquals($expected, $result); }