mirror of
https://github.com/flextype/flextype.git
synced 2025-08-08 06:06:45 +02:00
feat(tests): fixing tests - next round #199
This commit is contained in:
@@ -11,6 +11,6 @@ afterEach(function (): void {
|
||||
});
|
||||
|
||||
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']);
|
||||
});
|
||||
|
@@ -15,4 +15,3 @@ define('PATH', [
|
||||
$flextype_loader = require_once $flextype_autoload;
|
||||
|
||||
include ROOT_DIR . '/src/flextype/flextype.php';
|
||||
|
||||
|
@@ -8,34 +8,34 @@ use Thunder\Shortcode\Events;
|
||||
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]'));
|
||||
});
|
||||
|
@@ -12,6 +12,6 @@ afterEach(function (): void {
|
||||
|
||||
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"]'));
|
||||
});
|
||||
|
@@ -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()->shortcode()->process('[raw][entries_fetch id="foo" field="title"][/raw]'));
|
||||
parsers()->shortcodes()->process('[raw][entries_fetch id="foo" field="title"][/raw]'));
|
||||
});
|
||||
|
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
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"]'));
|
||||
});
|
||||
|
@@ -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]'));
|
||||
});
|
||||
|
Reference in New Issue
Block a user