From 96df159e5225edf7232519c3b60f8199285b7073 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 16 Oct 2020 18:31:26 +0300 Subject: [PATCH] feat(core): restore code for testing #477 --- src/flextype/bootstrap.php | 2 +- tests/Entries/EntriesTest.php | 54 +++++++++++++++++++++++++++++++++++ tests/Pest.php | 12 ++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/flextype/bootstrap.php b/src/flextype/bootstrap.php index 9bcd86a9..d984236e 100755 --- a/src/flextype/bootstrap.php +++ b/src/flextype/bootstrap.php @@ -187,4 +187,4 @@ flextype('cors')->init(); /** * Run application */ -flextype()->run(true); +flextype()->run(); diff --git a/tests/Entries/EntriesTest.php b/tests/Entries/EntriesTest.php index b3d9bbc7..8bc7cc5d 100644 --- a/tests/Entries/EntriesTest.php +++ b/tests/Entries/EntriesTest.php @@ -1 +1,55 @@ directory(PATH['project'] . '/entries')->create(); +}); + +afterEach(function (): void { + filesystem()->directory(PATH['project'] . '/entries')->delete(); +}); + +test('test create single entry', function () { + $this->assertTrue(flextype('entries')->create('foo', [])); + $this->assertFalse(flextype('entries')->create('foo', [])); +}); + +test('test has single entry', function () { + flextype('entries')->create('foo', []); + + $this->assertTrue(flextype('entries')->has('foo')); + $this->assertFalse(flextype('entries')->has('bar')); +}); + +test('test update single entry', function () { + flextype('entries')->create('foo', []); + + $this->assertTrue(flextype('entries')->update('foo', ['title' => 'Test'])); + $this->assertFalse(flextype('entries')->update('bar', ['title' => 'Test'])); +}); + +test('test fetch single entry', function () { + // 1 + flextype('entries')->create('foo', []); + $fetch = flextype('entries')->fetch('foo'); + $this->assertTrue(count($fetch) > 0); + + // 2 + $this->assertEquals([], flextype('entries')->fetch('bar')); + + // 3 + flextype('entries')->create('zed', ['title' => 'Zed']); + $fetch = flextype('entries')->fetch('zed'); + $this->assertEquals('Zed', $fetch['title']); +}); + +test('test fetch collection entry', function () { + // 1 + flextype('entries')->create('foo', []); + flextype('entries')->create('foo/bar', []); + flextype('entries')->create('foo/baz', []); + $fetch = flextype('entries')->fetchCollection('foo'); + $this->assertTrue(count($fetch) > 0); +}); diff --git a/tests/Pest.php b/tests/Pest.php index b3d9bbc7..4c187f69 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1 +1,13 @@ ROOT_DIR . '/project', + 'tmp' => ROOT_DIR . '/var/tmp', +]); + +! is_file($flextype_autoload = ROOT_DIR . '/vendor/autoload.php') and exit('Please run: composer install for flextype'); +$flextype_loader = require_once $flextype_autoload; +include ROOT_DIR . '/src/flextype/bootstrap.php'; +s