Skip to content

Commit

Permalink
Merge pull request #346 from ARCANEDEV/patch-1
Browse files Browse the repository at this point in the history
Fixing minor stuff
  • Loading branch information
arcanedev-maroc authored Jun 17, 2020
2 parents 9ce03f7 + c546c2b commit 602f66b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LogViewer/rel
| `pt-BR` | Brazilian Portuguese |
| `ro` | Romanian |
| `ru` | Russian |
| `si` | Sinhalese |
| `sv` | Swedish |
| `th` | Thai |
| `tr` | Turkish |
| `uk` | Ukrainian |
| `zh` | Chinese (Simplified) |
| `zh-TW` | Chinese (Traditional) |
| `si` | Sinhalese (සිංහල) |

## Contribution

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev": {
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.0|^9.0"
"phpunit/phpunit": "^8.5"
},
"autoload": {
"psr-4": {
Expand Down
34 changes: 27 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

namespace Arcanedev\LogViewer\Tests;

use Arcanedev\LogViewer\Contracts\Utilities\Filesystem;
use Arcanedev\LogViewer\Entities\Log;
use Arcanedev\LogViewer\Entities\LogEntry;
use Arcanedev\LogViewer\Entities\LogEntryCollection;
use Arcanedev\LogViewer\Helpers\LogParser;
use Arcanedev\LogViewer\LogViewerServiceProvider;
use Arcanedev\LogViewer\Providers\DeferredServicesProvider;
use Carbon\Carbon;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Arr;
use Orchestra\Testbench\TestCase as BaseTestCase;
use PHPUnit\Framework\Constraint\RegularExpression;
use Psr\Log\LogLevel;
use ReflectionClass;

Expand All @@ -33,7 +38,7 @@ abstract class TestCase extends BaseTestCase
/** @var array */
protected static $locales = [
'ar', 'bg', 'de', 'en', 'es', 'et', 'fa', 'fr', 'hu', 'hy', 'id', 'it', 'ja', 'ko', 'ms', 'nl', 'pl',
'pt-BR', 'ro', 'ru', 'sv', 'th', 'tr', 'uk', 'zh-TW', 'zh'
'pt-BR', 'ro', 'ru', 'si', 'sv', 'th', 'tr', 'uk', 'zh-TW', 'zh'
];

/* -----------------------------------------------------------------
Expand Down Expand Up @@ -65,8 +70,8 @@ public static function tearDownAfterClass(): void
protected function getPackageProviders($app): array
{
return [
\Arcanedev\LogViewer\LogViewerServiceProvider::class,
\Arcanedev\LogViewer\Providers\DeferredServicesProvider::class,
LogViewerServiceProvider::class,
DeferredServicesProvider::class,
];
}

Expand Down Expand Up @@ -98,7 +103,7 @@ protected function getEnvironmentSetUp($app): void
*/
public static function assertJsonObject($object, $message = ''): void
{
static::assertInstanceOf(\Illuminate\Contracts\Support\Jsonable::class, $object);
static::assertInstanceOf(Jsonable::class, $object);
static::assertJson($object->toJson(JSON_PRETTY_PRINT), $message);

static::assertInstanceOf('JsonSerializable', $object);
Expand Down Expand Up @@ -221,7 +226,7 @@ public static function assertDates(array $dates, $message = ''): void
*/
public static function assertDate($date, $message = ''): void
{
static::assertRegExp('/'.LogParser::REGEX_DATE_PATTERN.'/', $date, $message);
static::assertMatchesRegExp('/'.LogParser::REGEX_DATE_PATTERN.'/', $date, $message);
}

/**
Expand Down Expand Up @@ -258,7 +263,22 @@ protected static function assertHexColor($color, $message = ''): void
{
$pattern = '/^#?([a-f0-9]{3}|[a-f0-9]{6})$/i';

static::assertRegExp($pattern, $color, $message);
static::assertMatchesRegExp($pattern, $color, $message);
}

/**
* Asserts that a string matches a given regular expression.
*
* @todo Remove this method when phpunit 8 not used
*
* @param string $pattern
* @param string $string
* @param string $message
*
*/
public static function assertMatchesRegExp($pattern, $string, $message = ''): void
{
static::assertThat($string, new RegularExpression($pattern), $message);
}

/* -----------------------------------------------------------------
Expand All @@ -283,7 +303,7 @@ public function illuminateFile()
*/
protected function filesystem()
{
return $this->app->make(\Arcanedev\LogViewer\Contracts\Utilities\Filesystem::class);
return $this->app->make(Filesystem::class);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Utilities/LogStylerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function it_can_ben_instantiated(): void
public function it_can_get_icon(): void
{
foreach (self::$logLevels as $level) {
static::assertRegExp(
static::assertMatchesRegExp(
'/^<i class="fa fa-fw fa-(.*)"><\/i>$/',
$this->styler->icon($level)->toHtml()
);
Expand Down Expand Up @@ -95,7 +95,7 @@ public function it_can_get_default_when_color_not_found(): void
public function it_can_use_helper_to_get_icon(): void
{
foreach (self::$logLevels as $level) {
static::assertRegExp(
static::assertMatchesRegExp(
'/^<i class="fa fa-fw fa-(.*)"><\/i>$/',
log_styler()->icon($level)->toHtml()
);
Expand Down

0 comments on commit 602f66b

Please sign in to comment.