Skip to content

Commit 86174e6

Browse files
committed
add unit tests for toString methods
1 parent a0d7b13 commit 86174e6

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

tests/CodeSnippetTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,26 @@ public function it_ensures_the_entire_surrounding_lines_are_displayed()
149149

150150
$this->assertMatchesSnapshot($snippet->getLines());
151151
}
152+
153+
/** @test */
154+
public function it_returns_the_snippet_as_a_string()
155+
{
156+
$snippet = (new CodeSnippet())
157+
->surroundingLines(10, 12)
158+
->snippetLineCount(8)
159+
->fromFile($this->testsPath('data/file3.php'));
160+
161+
$this->assertMatchesSnapshot($snippet->toString());
162+
}
163+
164+
/** @test */
165+
public function it_returns_a_string_when_the_snippet_is_cast_to_a_string()
166+
{
167+
$snippet = (new CodeSnippet())
168+
->surroundingLines(10, 12)
169+
->snippetLineCount(8)
170+
->fromFile($this->testsPath('data/file3.php'));
171+
172+
$this->assertMatchesSnapshot((string)$snippet);
173+
}
152174
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
@var Ray $ray
3+
*/
4+
$ray = ray()->text('hello world')
5+
->blue()
6+
->large();
7+
8+
Ray
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
@var Ray $ray
3+
*/
4+
$ray = ray()->text('hello world')
5+
->blue()
6+
->large();
7+
8+
Ray

0 commit comments

Comments
 (0)