Skip to content

Commit 0a13c5b

Browse files
authored
Travis will now run phpunit after phpcs. (#7)
* 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.
1 parent 677c02b commit 0a13c5b

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ php:
44
- 7.0
55
install: composer install --prefer-source --dev
66
script:
7+
- ./vendor/bin/phpunit
78
- ./vendor/bin/phpcs --standard=PSR2 --ignore=vendor/ .

composer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
"require-dev": {
2020
"mockery/mockery": "~1.0",
2121
"phpunit/phpunit": "~6.0",
22-
"squizlabs/PHP_CodeSniffer": "^3.1"
22+
"squizlabs/PHP_CodeSniffer": "^3.1",
23+
"orchestra/testbench": "~3.0"
2324
},
2425
"autoload": {
25-
"psr-4": {
26-
"Smcrow\\SlackLog\\": "src/"
26+
"psr-4": {
27+
"Smcrow\\SlackLog\\": "src/"
2728
}
2829
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"Smcrow\\SlackLog\\Testing\\": "tests/"
33+
}
34+
},
2935
"extra": {
3036
"laravel": {
3137
"providers": [

src/Services/Logger.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@
1515

1616
class Logger
1717
{
18-
public function debug(string $message, $channelName = null): void
18+
public function debug(string $message, $channelName = null)
1919
{
2020
if ($this->isDebugEnabled()) {
2121
$this->log(Debug::message($message), $channelName);
2222
}
2323
}
2424

25-
public function info(string $message, $channelName = null): void
25+
public function info(string $message, $channelName = null)
2626
{
2727
if ($this->isInfoEnabled()) {
2828
$this->log(Info::message($message), $channelName);
2929
}
3030
}
3131

32-
public function trace(string $message, $channelName = null): void
32+
public function trace(string $message, $channelName = null)
3333
{
3434
if ($this->isTraceEnabled()) {
3535
$this->log(Trace::message($message), $channelName);
3636
}
3737
}
3838

39-
public function warn(string $message, $channelName = null): void
39+
public function warn(string $message, $channelName = null)
4040
{
4141
if ($this->isWarnEnabled()) {
4242
$this->log(Warn::message($message), $channelName);
4343
}
4444
}
4545

46-
public function error(string $message, $channelName = null): void
46+
public function error(string $message, $channelName = null)
4747
{
4848
if ($this->isErrorEnabled()) {
4949
$this->log(Error::message($message), $channelName);
@@ -88,7 +88,7 @@ private function isLogLevelEnabled(int $level): bool
8888
*
8989
* @throws WebhookNotDefined
9090
*/
91-
protected function log(Log $message, string $channelName = null): void
91+
protected function log(Log $message, string $channelName = null)
9292
{
9393
if (!config('slack-log.webhook-url')) {
9494
throw new WebhookNotDefined;

tests/Services/LoggerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Smcrow\SlackLog\Services\Tests;
3+
namespace Smcrow\SlackLog\Testing\Services;
44

55
use Illuminate\Support\Facades\Config;
66
use Illuminate\Support\Facades\Notification;
@@ -14,7 +14,7 @@
1414
use Smcrow\SlackLog\Notifiables\Channel;
1515
use Smcrow\SlackLog\Notifications\LogMessageRequested;
1616
use Smcrow\SlackLog\Services\Logger;
17-
use Tests\TestCase;
17+
use Smcrow\SlackLog\Testing\TestCase;
1818

1919
class LoggerTest extends TestCase
2020
{
@@ -151,7 +151,7 @@ public function testDebugTriggersBuildsDebugNotification()
151151
$this->logger->debug('test', self::DUMMY_CHANNEL);
152152
}
153153

154-
private function notificationShouldReceive(string $logInstance): void
154+
private function notificationShouldReceive(string $logInstance)
155155
{
156156
Notification::shouldReceive('send')
157157
->once()
@@ -165,7 +165,7 @@ private function notificationShouldReceive(string $logInstance): void
165165
});
166166
}
167167

168-
private function setLogLevel(int $logLevel): void
168+
private function setLogLevel(int $logLevel)
169169
{
170170
Config::set('slack-log.log-level', $logLevel);
171171
}

tests/TestCase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Smcrow\SlackLog\Testing;
4+
5+
class TestCase extends \Orchestra\Testbench\TestCase
6+
{
7+
8+
}

0 commit comments

Comments
 (0)