Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Jan 17, 2025
1 parent f53caae commit d182885
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 52 deletions.
41 changes: 0 additions & 41 deletions tests/ExceptionTraceArgumentsJsonSerializationTest.php

This file was deleted.

11 changes: 0 additions & 11 deletions tests/Fakes/NotExtendedDataClass.php

This file was deleted.

19 changes: 19 additions & 0 deletions tests/SerializeableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@


use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Exceptions\CannotCreateData;
use Spatie\LaravelData\Lazy;
use Spatie\LaravelData\Support\Lazy\DefaultLazy;
use Spatie\LaravelData\Tests\Fakes\LazyData;
use Spatie\LaravelData\Tests\Fakes\SimpleData;

use function Spatie\Snapshots\assertMatchesSnapshot;

beforeEach(function () {
ini_set('zend.exception_ignore_args', 'Off');
});

it('can serialize and unserialize a data object', function () {
$object = SimpleData::from('Hello world');

Expand Down Expand Up @@ -83,3 +88,17 @@
expect($unserialized)->toBeInstanceOf(LazyData::class);
expect($unserialized->toArray())->toMatchArray(['name' => 'Hello world']);
});

it('can json_encode exception trace with args when not all required properties passed', function () {
// When zend.exception_ignore_args is set to Off, the trace will contain the arguments
// We want to make sure these all can be encoded into JSON

try {
SimpleData::from([]);
} catch (CannotCreateData $e) {
$trace = $e->getTrace();
$encodedJson = json_encode($trace, JSON_THROW_ON_ERROR);

expect($encodedJson)->toBeJson();
}
});

0 comments on commit d182885

Please sign in to comment.