Skip to content

Commit 68e19f4

Browse files
committed
Merge branch 'no_remote_exception_fix'
2 parents da1a4b9 + fe5b470 commit 68e19f4

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

src/Repos/FakeLogsRepo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
class FakeLogsRepo implements LogsRepoInterface
77
{
8-
private $config;
9-
private $logs;
8+
protected $config;
9+
protected $logs;
1010

1111
public function __construct(array $config)
1212
{

src/Repos/FakeRemoteLogsRepo.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php namespace MathiasGrimm\LaravelLogKeeper\Repos;
2+
3+
use Exception;
4+
5+
class FakeRemoteLogsRepo extends FakeLogsRepo
6+
{
7+
public function __construct(array $config)
8+
{
9+
parent::__construct($config);
10+
11+
if ($this->config['enabled_remote'] && !$this->config['remote_disk']) {
12+
throw new Exception("remote_disk not configured for Laravel Log Keeper");
13+
}
14+
}
15+
}

src/Repos/RemoteLogsRepo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace MathiasGrimm\LaravelLogKeeper\Repos;
22

3+
use Exception;
34
use \Storage;
45
use MathiasGrimm\LaravelLogKeeper\Support\LogUtil;
56

@@ -15,7 +16,7 @@ public function __construct(array $config)
1516
$this->config = $config;
1617

1718
if ($this->config['enabled_remote'] && !$this->config['remote_disk']) {
18-
throw new \Exception("remote_disk not configured for Laravel Log Keeper");
19+
throw new Exception("remote_disk not configured for Laravel Log Keeper");
1920
}
2021

2122
$this->localLogPath = storage_path('logs');
@@ -57,7 +58,7 @@ public function getCompressed()
5758

5859
public function compress($log, $compressedName)
5960
{
60-
throw new \Exception("Method not implemented yet");
61+
throw new Exception("Method not implemented yet");
6162
// TODO: Implement compress() method.
6263
}
6364

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use MathiasGrimm\LaravelLogKeeper\Repos\FakeRemoteLogsRepo;
4+
5+
class FakeRemoteLogsRepoTest extends TestCase
6+
{
7+
/**
8+
* @test
9+
*/
10+
public function it_throws_exception_when_enable_remote_is_true_and_remote_disk_is_null()
11+
{
12+
$config = config('laravel-log-keeper');
13+
14+
$config['enabled_remote'] = true;
15+
$config['remote_disk' ] = null;
16+
17+
try {
18+
$repo = new FakeRemoteLogsRepo($config);
19+
$this->fail('It should not get here');
20+
} catch (Exception $e) {
21+
$this->assertSame('remote_disk not configured for Laravel Log Keeper', $e->getMessage());
22+
}
23+
24+
}
25+
26+
27+
28+
29+
}

tests/Services/LogKeeperServiceTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,4 @@ public function it_does_nothing_remotely_if_enabled_remote_is_false()
226226
$this->assertSame(["laravel-today-{$today->toDateString()}.log"], $logs);
227227
$this->assertSame([], $remoteRepo->getCompressed());
228228
}
229-
230-
}
229+
}

0 commit comments

Comments
 (0)