From cf961db1b336fc5c1c955b493ae25a8acef26fe8 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 22 May 2022 10:37:30 +0300 Subject: [PATCH] feat(tests): improvements --- .../flextype/core/Entries/Directives/TypesDirectiveTest.php | 2 ++ tests/src/flextype/core/Entries/EntriesTest.php | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tests/src/flextype/core/Entries/Directives/TypesDirectiveTest.php b/tests/src/flextype/core/Entries/Directives/TypesDirectiveTest.php index d08315ca..032014e4 100644 --- a/tests/src/flextype/core/Entries/Directives/TypesDirectiveTest.php +++ b/tests/src/flextype/core/Entries/Directives/TypesDirectiveTest.php @@ -21,6 +21,7 @@ test('types directive', function () { entries()->create('type-array-3', ['foo' => '@type[array] {"foo": "Foo"}']); entries()->create('type-array-4', ['foo' => '@type[array] foo']); entries()->create('type-collection', ['foo' => '@type[collection] foo']); + entries()->create('type-collection-2', ['foo' => '@type[collection] {"foo": "Foo"}']); entries()->create('type-null', ['foo' => '@type[null] foo']); entries()->create('type-string', ['foo' => '@type[string] foo']); entries()->create('type-json', ['foo' => '@type[json] foo=Foo']); @@ -37,6 +38,7 @@ test('types directive', function () { $this->assertEquals(['foo' => 'Foo'], entries()->fetch('type-array-3')['foo']); $this->assertEquals(['foo' => ''], entries()->fetch('type-array-4')['foo']); $this->assertEquals(['foo' => ''], entries()->fetch('type-collection')['foo']->toArray()); + $this->assertEquals(['foo' => 'Foo'], entries()->fetch('type-collection-2')['foo']->toArray()); $this->assertEquals(null, entries()->fetch('type-null')['foo']); $this->assertEquals('foo', entries()->fetch('type-string')['foo']); $this->assertEquals('{"foo":"Foo"}', entries()->fetch('type-json')['foo']); diff --git a/tests/src/flextype/core/Entries/EntriesTest.php b/tests/src/flextype/core/Entries/EntriesTest.php index ee54be8c..0f5652ea 100644 --- a/tests/src/flextype/core/Entries/EntriesTest.php +++ b/tests/src/flextype/core/Entries/EntriesTest.php @@ -1,6 +1,7 @@ directory(PATH['project'] . '/entries')->ensureExists(0755, true); @@ -10,6 +11,10 @@ afterEach(function () { filesystem()->directory(PATH['project'] . '/entries')->delete(); }); +test('entry construct', function () { + expect(new Entries(registry()->get('flextype.settings.entries')))->toBeInstanceOf(Entries::class); +}); + test('create new entry', function () { expect(entries()->create('foo', []))->toBeTrue(); expect(entries()->create('foo', []))->toBeFalse(); @@ -87,6 +92,7 @@ test('get cache ID for entry with cache enabled true', function () { registry()->set('flextype.settings.cache.enabled', true); expect(entries()->create('foo', []))->toBeTrue(); expect(strlen(entries()->getCacheID('foo')))->toEqual(32); + expect(strlen(entries()->getCacheID('foo2')))->toEqual(32); }); test('get cache ID for entry with cache enabled true and with salt', function () {