-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCommonMarkAwareTraitTest.php
63 lines (53 loc) · 1.76 KB
/
CommonMarkAwareTraitTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Gourmet\CommonMark\Test\TestCase\Utility;
use Cake\Event\Event;
use Cake\TestSuite\TestCase;
class CommonMarkAwareTraitTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->CommonMark = $this->getMockForTrait(
'Gourmet\CommonMark\Utility\CommonMarkAwareTrait',
[],
'',
true,
true,
true,
['dispatchEvent'],
false
);
}
public function tearDown()
{
parent::tearDown();
unset($this->CommonMark);
}
public function testConvertToHtml()
{
$result = $this->CommonMark->convertToHtml('# Foo');
$expected = "<h1>Foo</h1>\n";
$this->assertEquals($expected, $result);
}
public function testParseMarkdown()
{
$result = $this->CommonMark->parseMarkdown('# Foo');
$this->assertInstanceOf('League\CommonMark\Block\Element\Document', $result);
}
public function testRenderDocument()
{
$result = $this->CommonMark->renderDocument($this->CommonMark->parseMarkdown('# Foo'));
$expected = "<h1>Foo</h1>\n";
$this->assertEquals($expected, $result);
}
public function testRenderMarkdown()
{
$this->CommonMark->expects($this->once())
->method('dispatchEvent')
->with('CommonMark.beforeRender', $this->CommonMark, ['document' => $this->CommonMark->parseMarkdown('# Foo')])
->will($this->returnValue(new Event('CommonMark.beforeRender', $this->CommonMark, ['document' => $this->CommonMark->parseMarkdown('# Foo')])));
$result = $this->CommonMark->renderMarkdown('# Foo');
$expected = "<h1>Foo</h1>\n";
$this->assertEquals($expected, $result);
}
}