From ffe98a3baba224dcb5904625c6ad977ac113949f Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 31 Jul 2021 21:17:03 +0300 Subject: [PATCH] feat(tests): fixing tests - next round #199 --- .../Entries/Fields/ParsersFieldTest.php | 2 +- tests/Pest.php | 1 - tests/Support/Parsers/ShortcodeTest.php | 26 +++++++++---------- .../Shortcodes/EntriesShortcodeTest.php | 4 +-- .../Parsers/Shortcodes/RawShortcodeTest.php | 2 +- .../Shortcodes/RegistryShortcodeTest.php | 4 +-- .../Parsers/Shortcodes/UrlShortcodeTest.php | 4 +-- 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/Foundation/Entries/Fields/ParsersFieldTest.php b/tests/Foundation/Entries/Fields/ParsersFieldTest.php index 79d842dfb..e034b1fe4 100644 --- a/tests/Foundation/Entries/Fields/ParsersFieldTest.php +++ b/tests/Foundation/Entries/Fields/ParsersFieldTest.php @@ -11,6 +11,6 @@ }); test('test ParsersField', function () { - entries()->create('bar', ['entries' => '[registry_get name="Bar" default="Zed"]', 'parsers' => ['shortcode' => ['enabled' => true, 'fields' => ['entries']]]]); + entries()->create('bar', ['entries' => '[registry_get name="Bar" default="Zed"]', 'parsers' => ['shortcodes' => ['enabled' => true, 'fields' => ['entries']]]]); $this->assertEquals('Zed', entries()->fetch('bar')['entries']); }); diff --git a/tests/Pest.php b/tests/Pest.php index 4cd622d4c..c5eaaa7f6 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -15,4 +15,3 @@ $flextype_loader = require_once $flextype_autoload; include ROOT_DIR . '/src/flextype/flextype.php'; - diff --git a/tests/Support/Parsers/ShortcodeTest.php b/tests/Support/Parsers/ShortcodeTest.php index 06b637806..30bd8556a 100644 --- a/tests/Support/Parsers/ShortcodeTest.php +++ b/tests/Support/Parsers/ShortcodeTest.php @@ -8,34 +8,34 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface; test('test getInstance() method', function () { - $this->assertInstanceOf(Flextype\Support\Parsers\Shortcode::class, parsers()->shortcode()->getInstance()); + $this->assertInstanceOf(Flextype\Support\Parsers\Shortcode::class, parsers()->shortcodes()->getInstance()); }); test('test addHandler() method', function () { - $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcode()->addHandler('foo', static function() { return ''; })); + $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('foo', static function() { return ''; })); }); test('test addEventHandler() method', function () { - parsers()->shortcode()->addHandler('barz', static function () { + parsers()->shortcodes()->addHandler('barz', static function () { return 'Barz'; }); - parsers()->shortcode()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['barz'])); - $this->assertEquals('Barz', parsers()->shortcode()->process('[barz]')); + parsers()->shortcodes()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['barz'])); + $this->assertEquals('Barz', parsers()->shortcodes()->process('[barz]')); }); test('test parse() method', function () { - $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcode()->addHandler('bar', static function() { return ''; })); - $this->assertTrue(is_array(parsers()->shortcode()->parse('[bar]'))); - $this->assertTrue(is_object(parsers()->shortcode()->parse('[bar]')[0])); + $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('bar', static function() { return ''; })); + $this->assertTrue(is_array(parsers()->shortcodes()->parse('[bar]'))); + $this->assertTrue(is_object(parsers()->shortcodes()->parse('[bar]')[0])); }); test('test process() method', function () { - $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcode()->addHandler('zed', static function() { return 'Zed'; })); - $this->assertEquals('Zed', parsers()->shortcode()->process('[zed]')); - $this->assertEquals('fòôBàřZed', parsers()->shortcode()->process('fòôBàř[zed]')); + $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('zed', static function() { return 'Zed'; })); + $this->assertEquals('Zed', parsers()->shortcodes()->process('[zed]')); + $this->assertEquals('fòôBàřZed', parsers()->shortcodes()->process('fòôBàř[zed]')); }); test('test getCacheID() method', function () { - $this->assertNotEquals(parsers()->shortcode()->getCacheID('fòôBàř[bar]'), - parsers()->shortcode()->getCacheID('fòôBàř[foo]')); + $this->assertNotEquals(parsers()->shortcodes()->getCacheID('fòôBàř[bar]'), + parsers()->shortcodes()->getCacheID('fòôBàř[foo]')); }); diff --git a/tests/Support/Parsers/Shortcodes/EntriesShortcodeTest.php b/tests/Support/Parsers/Shortcodes/EntriesShortcodeTest.php index 0d0acb99d..68965801e 100644 --- a/tests/Support/Parsers/Shortcodes/EntriesShortcodeTest.php +++ b/tests/Support/Parsers/Shortcodes/EntriesShortcodeTest.php @@ -12,6 +12,6 @@ test('test entries_fetch shortcode', function () { $this->assertTrue(entries()->create('foo', ['title' => 'Foo'])); - $this->assertEquals('Foo', parsers()->shortcode()->process('[entries_fetch id="foo" field="title"]')); - $this->assertEquals('Bar', parsers()->shortcode()->process('[entries_fetch id="foo" field="bar" default="Bar"]')); + $this->assertEquals('Foo', parsers()->shortcodes()->process('[entries_fetch id="foo" field="title"]')); + $this->assertEquals('Bar', parsers()->shortcodes()->process('[entries_fetch id="foo" field="bar" default="Bar"]')); }); diff --git a/tests/Support/Parsers/Shortcodes/RawShortcodeTest.php b/tests/Support/Parsers/Shortcodes/RawShortcodeTest.php index 776d9057c..950da38ce 100644 --- a/tests/Support/Parsers/Shortcodes/RawShortcodeTest.php +++ b/tests/Support/Parsers/Shortcodes/RawShortcodeTest.php @@ -13,5 +13,5 @@ test('test raw shortcode', function () { $this->assertTrue(entries()->create('foo', ['title' => 'Foo'])); $this->assertEquals('[entries_fetch id="foo" field="title"]', - parsers()->shortcode()->process('[raw][entries_fetch id="foo" field="title"][/raw]')); + parsers()->shortcodes()->process('[raw][entries_fetch id="foo" field="title"][/raw]')); }); diff --git a/tests/Support/Parsers/Shortcodes/RegistryShortcodeTest.php b/tests/Support/Parsers/Shortcodes/RegistryShortcodeTest.php index 155b44051..367a6c1ed 100644 --- a/tests/Support/Parsers/Shortcodes/RegistryShortcodeTest.php +++ b/tests/Support/Parsers/Shortcodes/RegistryShortcodeTest.php @@ -4,7 +4,7 @@ test('test registry_get shortcode', function () { $this->assertEquals('Flextype', - parsers()->shortcode()->process('[registry_get name="flextype.manifest.name"]')); + parsers()->shortcodes()->process('[registry_get name="flextype.manifest.name"]')); $this->assertEquals('default-value', - parsers()->shortcode()->process('[registry_get name="item-name" default="default-value"]')); + parsers()->shortcodes()->process('[registry_get name="item-name" default="default-value"]')); }); diff --git a/tests/Support/Parsers/Shortcodes/UrlShortcodeTest.php b/tests/Support/Parsers/Shortcodes/UrlShortcodeTest.php index b730ae63d..15ab1b714 100644 --- a/tests/Support/Parsers/Shortcodes/UrlShortcodeTest.php +++ b/tests/Support/Parsers/Shortcodes/UrlShortcodeTest.php @@ -3,8 +3,8 @@ declare(strict_types=1); test('test registry_get shortcode', function () { - $this->assertStringContainsString('http', parsers()->shortcode()->process('[url]')); + $this->assertStringContainsString('http', parsers()->shortcodes()->process('[url]')); registry()->set('flextype.settings.url', 'https://flextype.org'); - $this->assertStringContainsString('https://flextype.org', parsers()->shortcode()->process('[url]')); + $this->assertStringContainsString('https://flextype.org', parsers()->shortcodes()->process('[url]')); });