mirror of
https://github.com/flextype/flextype.git
synced 2025-08-08 14:16:46 +02:00
feat(tests): add tests for Serializer Json encode() decode() getCacheID() methods #477
This commit is contained in:
25
tests/Support/Serializers/JsonTest.php
Normal file
25
tests/Support/Serializers/JsonTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('test encode() method', function () {
|
||||
$this->assertEquals('{"title":"Foo","content":"Bar"}',
|
||||
flextype('json')
|
||||
->encode(['title' => 'Foo',
|
||||
'content' => 'Bar']));
|
||||
});
|
||||
|
||||
test('test decode() method', function () {
|
||||
$this->assertEquals(['title' => 'Foo',
|
||||
'content' => 'Bar'],
|
||||
flextype('json')
|
||||
->decode('{"title":"Foo","content":"Bar"}'));
|
||||
});
|
||||
|
||||
test('test getCacheID() method', function () {
|
||||
$string = '{"title":"Foo","content":"Bar"}';
|
||||
$cache_id = flextype('json')
|
||||
->getCacheID($string);
|
||||
$this->assertEquals(32, strlen($cache_id));
|
||||
$this->assertNotEquals($string, $cache_id);
|
||||
});
|
Reference in New Issue
Block a user