Skip to content

Commit

Permalink
Travis will now run phpunit after phpcs. (#7)
Browse files Browse the repository at this point in the history
* Travis will now run phpunit after phpcs.
* Updated tests to use Orchestra\Testbench to avoid extra dependencies on laravel framework.

Additional fixes discovered thanks to testing:
* Removed void return type for 7.0 compatability.
  • Loading branch information
cr0wst committed Jan 15, 2018
1 parent 677c02b commit 0a13c5b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ php:
- 7.0
install: composer install --prefer-source --dev
script:
- ./vendor/bin/phpunit
- ./vendor/bin/phpcs --standard=PSR2 --ignore=vendor/ .
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
"require-dev": {
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0",
"squizlabs/PHP_CodeSniffer": "^3.1"
"squizlabs/PHP_CodeSniffer": "^3.1",
"orchestra/testbench": "~3.0"
},
"autoload": {
"psr-4": {
"Smcrow\\SlackLog\\": "src/"
"psr-4": {
"Smcrow\\SlackLog\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Smcrow\\SlackLog\\Testing\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
Expand Down
12 changes: 6 additions & 6 deletions src/Services/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@

class Logger
{
public function debug(string $message, $channelName = null): void
public function debug(string $message, $channelName = null)
{
if ($this->isDebugEnabled()) {
$this->log(Debug::message($message), $channelName);
}
}

public function info(string $message, $channelName = null): void
public function info(string $message, $channelName = null)
{
if ($this->isInfoEnabled()) {
$this->log(Info::message($message), $channelName);
}
}

public function trace(string $message, $channelName = null): void
public function trace(string $message, $channelName = null)
{
if ($this->isTraceEnabled()) {
$this->log(Trace::message($message), $channelName);
}
}

public function warn(string $message, $channelName = null): void
public function warn(string $message, $channelName = null)
{
if ($this->isWarnEnabled()) {
$this->log(Warn::message($message), $channelName);
}
}

public function error(string $message, $channelName = null): void
public function error(string $message, $channelName = null)
{
if ($this->isErrorEnabled()) {
$this->log(Error::message($message), $channelName);
Expand Down Expand Up @@ -88,7 +88,7 @@ private function isLogLevelEnabled(int $level): bool
*
* @throws WebhookNotDefined
*/
protected function log(Log $message, string $channelName = null): void
protected function log(Log $message, string $channelName = null)
{
if (!config('slack-log.webhook-url')) {
throw new WebhookNotDefined;
Expand Down
8 changes: 4 additions & 4 deletions tests/Services/LoggerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Smcrow\SlackLog\Services\Tests;
namespace Smcrow\SlackLog\Testing\Services;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Notification;
Expand All @@ -14,7 +14,7 @@
use Smcrow\SlackLog\Notifiables\Channel;
use Smcrow\SlackLog\Notifications\LogMessageRequested;
use Smcrow\SlackLog\Services\Logger;
use Tests\TestCase;
use Smcrow\SlackLog\Testing\TestCase;

class LoggerTest extends TestCase
{
Expand Down Expand Up @@ -151,7 +151,7 @@ public function testDebugTriggersBuildsDebugNotification()
$this->logger->debug('test', self::DUMMY_CHANNEL);
}

private function notificationShouldReceive(string $logInstance): void
private function notificationShouldReceive(string $logInstance)
{
Notification::shouldReceive('send')
->once()
Expand All @@ -165,7 +165,7 @@ private function notificationShouldReceive(string $logInstance): void
});
}

private function setLogLevel(int $logLevel): void
private function setLogLevel(int $logLevel)
{
Config::set('slack-log.log-level', $logLevel);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Smcrow\SlackLog\Testing;

class TestCase extends \Orchestra\Testbench\TestCase
{

}

0 comments on commit 0a13c5b

Please sign in to comment.