Skip to content

Commit

Permalink
adding regression test. creating fake remote repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasgrimm committed Mar 15, 2016
1 parent fae8bb2 commit fe5b470
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 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
6 changes: 1 addition & 5 deletions src/Repos/FakeRemoteLogsRepo.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<?php namespace MathiasGrimm\LaravelLogKeeper\Repos;

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

class FakeRemoteLogsRepo extends FakeLogsRepo
{
private $config;
private $logs;

public function __construct(array $config)
{
parent::__construct($config);
Expand Down
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
20 changes: 15 additions & 5 deletions tests/Repos/FakeRemoteLogsRepoTest.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?php


use MathiasGrimm\LaravelLogKeeper\Repos\FakeLogsRepo;
use MathiasGrimm\LaravelLogKeeper\Repos\FakeRemoteLogsRepo;

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

return $repo;
$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());
}

}


Expand Down
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 fe5b470

Please sign in to comment.