Skip to content

Commit 824432e

Browse files
committed
Add support for Laravel 7
1 parent ffc1c26 commit 824432e

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: php
22
php:
3-
- 7.1
43
- 7.2
54
- 7.3
5+
- 7.4
66
before_script:
77
- composer self-update
88
- composer install

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
"source": "https://github.com/hedii/laravel-gelf-logger"
2727
},
2828
"require": {
29-
"php": "^7.1.3",
30-
"illuminate/log": "5.6.*|5.7.*|5.8.*|^6.0",
31-
"graylog2/gelf-php": "^1.5"
29+
"php": "^7.2.5",
30+
"illuminate/log": "^7.0",
31+
"graylog2/gelf-php": "^1.6"
3232
},
3333
"require-dev": {
34-
"phpunit/phpunit": "^7.0",
35-
"orchestra/testbench": "^3.7"
34+
"orchestra/testbench": "^5.0"
3635
},
3736
"autoload": {
3837
"psr-4": {

tests/GelfLoggerTest.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function it_should_use_default_max_length_when_max_length_is_not_provided
161161
$logger = Log::channel('gelf');
162162

163163
$this->assertSame(
164-
GelfMessageFormatter::DEFAULT_MAX_LENGTH,
164+
$this->getConstant(GelfMessageFormatter::class, 'DEFAULT_MAX_LENGTH'),
165165
$this->getAttribute($logger->getHandlers()[0]->getFormatter(), 'maxLength')
166166
);
167167
}
@@ -178,21 +178,20 @@ public function it_should_use_default_max_length_when_max_length_is_null(): void
178178
$logger = Log::channel('gelf');
179179

180180
$this->assertSame(
181-
GelfMessageFormatter::DEFAULT_MAX_LENGTH,
181+
$this->getConstant(GelfMessageFormatter::class, 'DEFAULT_MAX_LENGTH'),
182182
$this->getAttribute($logger->getHandlers()[0]->getFormatter(), 'maxLength')
183183
);
184184
}
185185

186186
/**
187187
* Get protected or private attribute from an object.
188-
* NOTICE: This method is for testing purposes only.
189188
*
190189
* @param object $object
191190
* @param string $property
192191
* @return mixed
193192
* @throws \Exception
194193
*/
195-
protected function getAttribute($object, string $property)
194+
protected function getAttribute(object $object, string $property)
196195
{
197196
try {
198197
$reflector = new ReflectionClass($object);
@@ -201,7 +200,26 @@ protected function getAttribute($object, string $property)
201200

202201
return $attribute->getValue($object);
203202
} catch (Exception $e) {
204-
throw new Exception("Can't get attribute from the provided object");
203+
throw new Exception('Cannot get attribute from the provided object');
204+
}
205+
}
206+
207+
/**
208+
* Get protected or private constant from a class.
209+
*
210+
* @param string $class
211+
* @param string $constant
212+
* @return mixed
213+
* @throws \Exception
214+
*/
215+
protected function getConstant(string $class, string $constant)
216+
{
217+
try {
218+
$reflector = new ReflectionClass($class);
219+
220+
return $reflector->getConstant($constant);
221+
} catch (Exception $e) {
222+
throw new Exception('Cannot get attribute from the provided class');
205223
}
206224
}
207225
}

0 commit comments

Comments
 (0)