36 private $splitPosition;
40 private $highlightRenderer;
47 $this->colorMap = array(
'type1' =>
'red',
'type2' =>
'yellow',
'any' =>
'gray');
49 $this->prepareMocks();
57 public function prepareMocks()
59 $this->htmlElement = M::mock(SimpleHtmlElement::class);
60 $this->htmlElement->shouldReceive(
'getOpeningText')->andReturn(
'<element>');
61 $this->htmlElement->shouldReceive(
'getClosingText')->andReturn(
'</element>');
63 $this->highlight = M::mock(Highlight::class);
64 $this->highlight->shouldReceive(
'getType')->andReturn(Highlight::MATCH)->byDefault();
65 $this->highlight->shouldReceive(
'getInfoText')->andReturn(
"<infoText>")->byDefault();
66 $this->highlight->shouldReceive(
'getHtmlElement')->andReturn(null)->byDefault();
68 $this->splitPosition = M::mock(SplitPosition::class);
69 $this->splitPosition->shouldReceive(
'getLevel')->andReturn($this->level)->byDefault();
70 $this->splitPosition->shouldReceive(
'getHighlight')->andReturn($this->highlight)->byDefault();
73 public function testCreateSpanStart()
75 $result = $this->highlightRenderer->createSpanStart($this->splitPosition);
77 assertThat($result, is(
"<span class=\"hi-match\" title=\"<infoText>\">"));
80 public function testCreateSpanStartWrappingHtmlElement()
82 $this->highlight->shouldReceive(
'getHtmlElement')->andReturn($this->htmlElement);
84 $result = $this->highlightRenderer->createSpanStart($this->splitPosition);
86 assertThat($result, is(
"<span class=\"hi-match\" title=\"<infoText>\"><element>"));
89 public function testCreateSpanStartWithUndefinedType()
91 $this->highlight->shouldReceive(
'getType')->andReturn(
"<anything>");
92 $this->highlight->shouldReceive(
'getInfoText')->andReturn(null);
94 $result = $this->highlightRenderer->createSpanStart($this->splitPosition);
96 assertThat($result, is(
"<span class=\"hi-undefined\" title=\"\">"));
99 public function testCreateSpanStartWithPadding()
101 $this->splitPosition->shouldReceive(
'getLevel')->andReturn(-1);
103 $result = $this->highlightRenderer->createSpanStart($this->splitPosition);
105 assertThat($result, is(
"<span class=\"hi-match\" title=\"<infoText>\">"));
108 public function testCreateSpanEnd()
110 $result = $this->highlightRenderer->createSpanEnd($this->splitPosition);
112 assertThat($result, is(
"</span>"));
115 public function testCreateSpanEndWithWrappeingHtmlElement()
117 $this->highlight->shouldReceive(
'getHtmlElement')->andReturn($this->htmlElement);
119 $result = $this->highlightRenderer->createSpanEnd($this->splitPosition);
121 assertThat($result, is(
"</element></span>"));