Skip to content

Commit

Permalink
Add tests for the safe mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jun 28, 2016
1 parent 83f8210 commit 4d3cc5f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/Block/Renderer/HtmlBlockRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ public function testRender()
$this->assertContains('<button>Test</button>', $result);
}

public function testRenderSafeMode()
{
$this->renderer->setConfiguration(new Configuration([
'safe' => true,
]));

/** @var HtmlBlock|\PHPUnit_Framework_MockObject_MockObject $block */
$block = $this->getMockBuilder('League\CommonMark\Block\Element\HtmlBlock')
->setConstructorArgs([HtmlBlock::TYPE_6_BLOCK_ELEMENT])
->getMock();
$block->expects($this->any())
->method('getStringContent')
->will($this->returnValue('<button>Test</button>'));

$fakeRenderer = new FakeHtmlRenderer();

$result = $this->renderer->render($block, $fakeRenderer);

$this->assertInternalType('string', $result);
$this->assertEquals('', $result);
}

/**
* @expectedException \InvalidArgumentException
*/
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/Inline/Renderer/HtmlInlineRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ public function testRender()
$this->assertContains('<h1>Test</h1>', $result);
}

public function testRenderSafeMode()
{
$this->renderer->setConfiguration(new Configuration([
'safe' => true,
]));

$inline = new HtmlInline('<h1>Test</h1>');
$fakeRenderer = new FakeHtmlRenderer();

$result = $this->renderer->render($inline, $fakeRenderer);

$this->assertInternalType('string', $result);
$this->assertEquals('', $result);
}

/**
* @expectedException \InvalidArgumentException
*/
Expand Down

0 comments on commit 4d3cc5f

Please sign in to comment.