You are here

function NodeTeaserTest::testLength in SimpleTest 6

Simpletest test. Runs a test adapted from http://drupal.org/node/180425#comment-634230

File

tests/node_teaser.test, line 48

Class

NodeTeaserTest

Code

function testLength() {

  // This body string tests a number of edge cases.
  $body = "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>";

  // The teasers we expect node_teaser() to return when $size is the index
  // of each array item.
  // Using an input format with no line-break filter:
  $teasers = array(
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
    "<",
    "<p",
    "<p>",
    "<p>\n",
    "<p>\nH",
    "<p>\nHi",
    "<p>\nHi\n",
    "<p>\nHi\n<",
    "<p>\nHi\n</",
    "<p>\nHi\n</p",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
  );

  // And Using an input format WITH the line-break filter.
  $teasers_lb = array(
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
    "<",
    "<p",
    "<p>",
    "<p>",
    "<p>",
    "<p>",
    "<p>\nHi",
    "<p>\nHi",
    "<p>\nHi",
    "<p>\nHi",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>",
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
    "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
  );

  // Test node_teaser() for different sizes.
  for ($i = 0; $i <= 37; $i++) {
    $this
      ->callNodeTeaser($body, $teasers[$i], NULL, $i);
    $this
      ->callNodeTeaser($body, $teasers_lb[$i], 1, $i);
    $this
      ->callNodeTeaser($body, $teasers_lb[$i], 2, $i);
  }
}