Skip to content

Commit

Permalink
serialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
jszobody committed Jun 27, 2024
1 parent ec69bf7 commit ab92012
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/SslCertificateSerializationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Carbon\Carbon;
use Spatie\SslCertificate\SslCertificate;

it('cannot json encode certificate array data', function() {
json_encode(
SslCertificate::createFromFile(__DIR__ . '/stubs/spatieCertificate.pem')->toArray()
);

expect(json_last_error_msg())->toEqual('Malformed UTF-8 characters, possibly incorrectly encoded');
});

it('can json encode serialized certificate', function() {
$json = json_encode(
serialize(SslCertificate::createFromFile(__DIR__ . '/stubs/spatieCertificate.pem'))
);

expect(json_last_error_msg())->toEqual('No error');
});

it('can unserialize serialized certificate', function() {
$serialized = serialize(SslCertificate::createFromFile(__DIR__ . '/stubs/spatieCertificate.pem'));

$unserialized = unserialize($serialized);

expect($unserialized->getDomain())->toEqual("analytics.spatie.be");
});

0 comments on commit ab92012

Please sign in to comment.