* @since 2.0 */ class FormatterTest extends TestCase { /** * @var Formatter */ protected $formatter; protected function setUp() { parent::setUp(); $this->mockApplication(); $this->formatter = new Formatter(); } protected function tearDown() { parent::tearDown(); $this->formatter = null; } public function testAsRaw() { $value = '123'; $this->assertSame($value, $this->formatter->asRaw($value)); $value = 123; $this->assertSame($value, $this->formatter->asRaw($value)); $value = '<>'; $this->assertSame($value, $this->formatter->asRaw($value)); } public function testAsText() { $value = '123'; $this->assertSame($value, $this->formatter->asText($value)); $value = 123; $this->assertSame("$value", $this->formatter->asText($value)); $value = '<>'; $this->assertSame('<>', $this->formatter->asText($value)); } public function testAsNtext() { $value = '123'; $this->assertSame($value, $this->formatter->asNtext($value)); $value = 123; $this->assertSame("$value", $this->formatter->asNtext($value)); $value = '<>'; $this->assertSame('<>', $this->formatter->asNtext($value)); $value = "123\n456"; $this->assertSame("123
\n456", $this->formatter->asNtext($value)); } public function testAsParagraphs() { $value = '123'; $this->assertSame("

$value

", $this->formatter->asParagraphs($value)); $value = 123; $this->assertSame("

$value

", $this->formatter->asParagraphs($value)); $value = '<>'; $this->assertSame('

<>

', $this->formatter->asParagraphs($value)); $value = "123\n456"; $this->assertSame("

123\n456

", $this->formatter->asParagraphs($value)); $value = "123\n\n456"; $this->assertSame("

123

\n

456

", $this->formatter->asParagraphs($value)); $value = "123\n\n\n456"; $this->assertSame("

123

\n

456

", $this->formatter->asParagraphs($value)); } public function testAsHtml() { // todo } public function testAsEmail() { $value = 'test@sample.com'; $this->assertSame("$value", $this->formatter->asEmail($value)); } public function testAsImage() { $value = 'http://sample.com/img.jpg'; $this->assertSame("\"\"", $this->formatter->asImage($value)); } }