1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-10 23:24:04 +02:00

feat(tests): update tests for shortcodes #562

This commit is contained in:
Awilum
2021-08-05 11:57:39 +03:00
parent 6dadd31eb5
commit 3c696e825e
5 changed files with 15 additions and 15 deletions

View File

@@ -20,19 +20,19 @@ test('test addEventHandler() method', function () {
return 'Barz';
});
parsers()->shortcodes()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['barz']));
$this->assertEquals('Barz', parsers()->shortcodes()->process('[barz]'));
$this->assertEquals('Barz', parsers()->shortcodes()->parse('[barz]'));
});
test('test parseText() method', function () {
$this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('bar', static function() { return ''; }));
$this->assertTrue(is_array(parsers()->shortcodes()->parseText('[bar]')));
$this->assertTrue(is_object(parsers()->shortcodes()->parseText('[bar]')[0]));
});
test('test parse() method', function () {
$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()->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]'));
$this->assertEquals('Zed', parsers()->shortcodes()->parse('[zed]'));
$this->assertEquals('fòôBàřZed', parsers()->shortcodes()->parse('fòôBàř[zed]'));
});
test('test getCacheID() method', function () {

View File

@@ -12,6 +12,6 @@ afterEach(function (): void {
test('test entries_fetch shortcode', function () {
$this->assertTrue(entries()->create('foo', ['title' => 'Foo']));
$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"]'));
$this->assertEquals('Foo', parsers()->shortcodes()->parse('[entries_fetch id="foo" field="title"]'));
$this->assertEquals('Bar', parsers()->shortcodes()->parse('[entries_fetch id="foo" field="bar" default="Bar"]'));
});

View File

@@ -13,5 +13,5 @@ afterEach(function (): void {
test('test raw shortcode', function () {
$this->assertTrue(entries()->create('foo', ['title' => 'Foo']));
$this->assertEquals('[entries_fetch id="foo" field="title"]',
parsers()->shortcodes()->process('[raw][entries_fetch id="foo" field="title"][/raw]'));
parsers()->shortcodes()->parse('[raw][entries_fetch id="foo" field="title"][/raw]'));
});

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
test('test registry_get shortcode', function () {
$this->assertEquals('Flextype',
parsers()->shortcodes()->process('[registry_get name="flextype.manifest.name"]'));
parsers()->shortcodes()->parse('[registry_get name="flextype.manifest.name"]'));
$this->assertEquals('default-value',
parsers()->shortcodes()->process('[registry_get name="item-name" default="default-value"]'));
parsers()->shortcodes()->parse('[registry_get name="item-name" default="default-value"]'));
});

View File

@@ -5,5 +5,5 @@ declare(strict_types=1);
test('test registry_get shortcode', function () {
registry()->set('flextype.settings.url', 'https://flextype.org');
$this->assertStringContainsString('https://flextype.org', parsers()->shortcodes()->process('[url]'));
$this->assertStringContainsString('https://flextype.org', parsers()->shortcodes()->parse('[url]'));
});