1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 05:36:54 +02:00

feat(tests): improvements

This commit is contained in:
Awilum
2022-05-22 10:37:30 +03:00
parent 783bb7e73b
commit cf961db1b3
2 changed files with 8 additions and 0 deletions

View File

@@ -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']);

View File

@@ -1,6 +1,7 @@
<?php
use Glowy\Arrays\Arrays;
use Flextype\Entries\Entries;
beforeEach(function() {
filesystem()->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 () {