Skip to content

Commit

Permalink
Assert the log call
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Oct 14, 2024
1 parent 8c33cbb commit 0572cc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/TrixAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DOMElement;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

class TrixAttachment
Expand Down Expand Up @@ -56,9 +57,7 @@ private static function typeCast(string $key, $value)
};
}

public function __construct(public DOMElement $node)
{
}
public function __construct(public DOMElement $node) {}

public function attributes(): array
{
Expand Down Expand Up @@ -93,7 +92,7 @@ private function readJsonAttribute(string $key): array
$data = json_decode($value ?: '[]', true);

if (json_last_error() !== JSON_ERROR_NONE) {
logger(sprintf(
Log::notice(sprintf(
'[%s] Couldnt parse JSON %s from NODE %s',
static::class,
$value,
Expand Down
3 changes: 3 additions & 0 deletions tests/ContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tonysm\RichTextLaravel\Tests;

use Illuminate\Support\Facades\Log;
use Tonysm\RichTextLaravel\Attachables\ContentAttachment;
use Tonysm\RichTextLaravel\Attachables\MissingAttachable;
use Tonysm\RichTextLaravel\Attachables\RemoteImage;
Expand Down Expand Up @@ -209,6 +210,8 @@ public function converts_trix_formatetd_attachments_with_custom_tag_name()
/** @test */
public function ignores_trix_formatteed_attachments_with_bad_json()
{
Log::shouldReceive('notice')->once();

$html = <<<'HTML'
<div data-trix-attachment='{"sgid": "pure garbate...}'></div>
HTML;
Expand Down

0 comments on commit 0572cc6

Please sign in to comment.