1
0
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:
Awilum
2020-10-21 10:55:02 +03:00
parent aa50b5a580
commit 887e18b119

View 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);
});