Skip to content

Commit eb70e2b

Browse files
committed
mock changelog
1 parent 39c973e commit eb70e2b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Changelog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Changelog
1313
*
1414
* @return string
1515
*/
16-
private function getFile(): string
16+
public function path(): string
1717
{
1818
return config('changelog.file', base_path('CHANGELOG.md'));
1919
}
@@ -26,7 +26,7 @@ private function getFile(): string
2626
*/
2727
public function raw(): string
2828
{
29-
$file = $this->getFile();
29+
$file = $this->path();
3030

3131
if (!file_exists($file)) {
3232
throw new ChangelogNotFoundException();

tests/ChangelogTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace BlameButton\Laravel\Changelog\Tests;
44

5+
use BlameButton\Laravel\Changelog\Changelog;
56
use BlameButton\Laravel\Changelog\ChangelogFacade;
67
use BlameButton\Laravel\Changelog\ChangelogServiceProvider;
78
use Illuminate\Support\Facades\Storage;
9+
use Mockery\MockInterface;
810
use Orchestra\Testbench\TestCase;
911

1012
class ChangelogTest extends TestCase
@@ -29,7 +31,13 @@ public function testRaw(): void
2931

3032
Storage::put(base_path('CHANGELOG.md'), $expected);
3133

32-
$content = ChangelogFacade::raw();
34+
/** @var Changelog $changelog */
35+
$changelog = $this->mock(Changelog::class, function(MockInterface $mock) {
36+
$mock->shouldReceive('path')->andReturn(Storage::path(base_path('CHANGELOG.md')));
37+
$mock->shouldReceive('raw')->passthru();
38+
});
39+
40+
$content = $changelog->raw();
3341

3442
self::assertNotNull($content);
3543
self::assertEquals($expected, $content);

0 commit comments

Comments
 (0)