mirror of
https://github.com/flextype/flextype.git
synced 2025-08-07 21:56:33 +02:00
feat(expressions): add date
expression function
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use function Glowy\Filesystem\filesystem;
|
||||
use function Flextype\entries;
|
||||
|
||||
beforeEach(function() {
|
||||
filesystem()->directory(FLEXTYPE_PATH_PROJECT . '/entries')->create();
|
||||
});
|
||||
|
||||
afterEach(function (): void {
|
||||
filesystem()->directory(FLEXTYPE_PATH_PROJECT . '/entries')->delete();
|
||||
});
|
||||
|
||||
test('ceil expression', function () {
|
||||
entries()->create('ceil', ['test' => '[[ ceil(42.1) ]]']);
|
||||
expect(entries()->fetch('ceil')['test'])->toBe('43');
|
||||
});
|
||||
|
||||
test('floor expression', function () {
|
||||
entries()->create('floor', ['test' => '[[ floor(4.3) ]]']);
|
||||
expect(entries()->fetch('floor')['test'])->toBe('4');
|
||||
});
|
||||
|
||||
test('min expression', function () {
|
||||
entries()->create('min', ['test' => '[[ min(2, 3, 1, 6, 7) ]]']);
|
||||
expect(entries()->fetch('min')['test'])->toBe('1');
|
||||
});
|
||||
|
||||
test('max expression', function () {
|
||||
entries()->create('max', ['test' => '[[ max(2, 3, 1, 6, 7) ]]']);
|
||||
expect(entries()->fetch('max')['test'])->toBe('7');
|
||||
});
|
Reference in New Issue
Block a user