Skip to content

Commit

Permalink
Merge branch 'no_remote_exception_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasgrimm committed Mar 15, 2016
2 parents da1a4b9 + fe5b470 commit 68e19f4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Repos/FakeLogsRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

class FakeLogsRepo implements LogsRepoInterface
{
private $config;
private $logs;
protected $config;
protected $logs;

public function __construct(array $config)
{
Expand Down
15 changes: 15 additions & 0 deletions src/Repos/FakeRemoteLogsRepo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php namespace MathiasGrimm\LaravelLogKeeper\Repos;

use Exception;

class FakeRemoteLogsRepo extends FakeLogsRepo
{
public function __construct(array $config)
{
parent::__construct($config);

if ($this->config['enabled_remote'] && !$this->config['remote_disk']) {
throw new Exception("remote_disk not configured for Laravel Log Keeper");
}
}
}
5 changes: 3 additions & 2 deletions src/Repos/RemoteLogsRepo.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace MathiasGrimm\LaravelLogKeeper\Repos;

use Exception;
use \Storage;
use MathiasGrimm\LaravelLogKeeper\Support\LogUtil;

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

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

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

public function compress($log, $compressedName)
{
throw new \Exception("Method not implemented yet");
throw new Exception("Method not implemented yet");
// TODO: Implement compress() method.
}

Expand Down
29 changes: 29 additions & 0 deletions tests/Repos/FakeRemoteLogsRepoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use MathiasGrimm\LaravelLogKeeper\Repos\FakeRemoteLogsRepo;

class FakeRemoteLogsRepoTest extends TestCase
{
/**
* @test
*/
public function it_throws_exception_when_enable_remote_is_true_and_remote_disk_is_null()
{
$config = config('laravel-log-keeper');

$config['enabled_remote'] = true;
$config['remote_disk' ] = null;

try {
$repo = new FakeRemoteLogsRepo($config);
$this->fail('It should not get here');
} catch (Exception $e) {
$this->assertSame('remote_disk not configured for Laravel Log Keeper', $e->getMessage());
}

}




}
3 changes: 1 addition & 2 deletions tests/Services/LogKeeperServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,4 @@ public function it_does_nothing_remotely_if_enabled_remote_is_false()
$this->assertSame(["laravel-today-{$today->toDateString()}.log"], $logs);
$this->assertSame([], $remoteRepo->getCompressed());
}

}
}

0 comments on commit 68e19f4

Please sign in to comment.