Example #1
0
 /**
  * Test if trimming indentations with tabs are handled properly.
  */
 public function testLineWithTabsIsTrimmedCorrectly()
 {
     $ws = new ezcTemplateWhitespaceRemoval();
     $ws->tabSize = 8;
     for ($i = 0; $i <= 8; ++$i) {
         self::assertSame("", $ws->trimIndentationLine("", $i), "Empty string trimmed at indentation {$i} should be empty.");
     }
     self::assertSame("\t", $ws->trimIndentationLine("\t", 0), "String with tab trimmed at indentation 0 should have the tab marker.");
     self::assertSame("", $ws->trimIndentationLine("\t", 1), "String with tab trimmed at indentation 1 should be empty.");
     self::assertSame("", $ws->trimIndentationLine("\t", 7), "String with tab trimmed at indentation 7 should be empty.");
     self::assertSame("", $ws->trimIndentationLine("\t", 8), "String with tab trimmed at indentation 8 should be empty.");
     self::assertSame(" \t", $ws->trimIndentationLine(" \t", 0), "String with space+tab trimmed at indentation 0 should have the space+tab marker.");
     self::assertSame("\t", $ws->trimIndentationLine(" \t", 1), "String with space+tab trimmed at indentation 1 should have the tab marker.");
     self::assertSame("", $ws->trimIndentationLine(" \t", 2), "String with space+tab trimmed at indentation 2 should be empty.");
     self::assertSame("", $ws->trimIndentationLine(" \t", 7), "String with space+tab trimmed at indentation 7 should be empty.");
     self::assertSame("", $ws->trimIndentationLine(" \t", 8), "String with space+tab trimmed at indentation 8 should be empty.");
     self::assertSame("       \t", $ws->trimIndentationLine("       \t", 0), "String with 7*space+tab trimmed at indentation 0 should have the 7*space+tab marker.");
     self::assertSame("      \t", $ws->trimIndentationLine("       \t", 1), "String with 7*space+tab trimmed at indentation 1 should have the 6*space+tab marker.");
     self::assertSame("     \t", $ws->trimIndentationLine("       \t", 2), "String with 7*space+tab trimmed at indentation 2 should have the 5*space+tab marker.");
     self::assertSame("    \t", $ws->trimIndentationLine("       \t", 3), "String with 7*space+tab trimmed at indentation 3 should have the 4*space+tab marker.");
     self::assertSame("   \t", $ws->trimIndentationLine("       \t", 4), "String with 7*space+tab trimmed at indentation 4 should have the 3*space+tab marker.");
     self::assertSame("  \t", $ws->trimIndentationLine("       \t", 5), "String with 7*space+tab trimmed at indentation 5 should have the 2*space+tab marker.");
     self::assertSame(" \t", $ws->trimIndentationLine("       \t", 6), "String with 7*space+tab trimmed at indentation 6 should have the 1*space+tab marker.");
     self::assertSame("\t", $ws->trimIndentationLine("       \t", 7), "String with 7*space+tab trimmed at indentation 7 should have the tab marker.");
     self::assertSame("", $ws->trimIndentationLine("       \t", 8), "String with 7*space+tab trimmed at indentation 8 should be empty.");
 }