Skip to content

Commit

Permalink
feat(tests): fixing tests - next round #199
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jul 31, 2021
1 parent c89d34c commit ffe98a3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tests/Foundation/Entries/Fields/ParsersFieldTest.php
Expand Up @@ -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']);
});
1 change: 0 additions & 1 deletion tests/Pest.php
Expand Up @@ -15,4 +15,3 @@
$flextype_loader = require_once $flextype_autoload;

include ROOT_DIR . '/src/flextype/flextype.php';

26 changes: 13 additions & 13 deletions tests/Support/Parsers/ShortcodeTest.php
Expand Up @@ -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]'));
});
4 changes: 2 additions & 2 deletions tests/Support/Parsers/Shortcodes/EntriesShortcodeTest.php
Expand Up @@ -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"]'));
});
2 changes: 1 addition & 1 deletion tests/Support/Parsers/Shortcodes/RawShortcodeTest.php
Expand Up @@ -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]'));
});
4 changes: 2 additions & 2 deletions tests/Support/Parsers/Shortcodes/RegistryShortcodeTest.php
Expand Up @@ -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"]'));
});
4 changes: 2 additions & 2 deletions tests/Support/Parsers/Shortcodes/UrlShortcodeTest.php
Expand Up @@ -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]'));
});

0 comments on commit ffe98a3

Please sign in to comment.