1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(tests): add tests for Shortcode addEventHandler() method #477

This commit is contained in:
Awilum
2020-10-20 00:37:19 +03:00
parent b89b9a0807
commit f763562634

View File

@@ -3,15 +3,26 @@
declare(strict_types=1);
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\EventHandler\FilterRawEventHandler;
use Thunder\Shortcode\Events;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
test('test getInstance() method', function () {
$this->assertInstanceOf(ShortcodeFacade::class, flextype('shortcode')->getInstance());
});
test('test addEventHandler() method', function () {
test('test addHandler() method', function () {
$this->assertInstanceOf(ShortcodeFacade::class, flextype('shortcode')->addHandler('foo', static function() { return ''; }));
});
test('test addEventHandler() method', function () {
flextype('shortcode')->addHandler('barz', static function () {
return 'Barz';
});
flextype('shortcode')->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['barz']));
$this->assertEquals('Barz', flextype('shortcode')->process('[barz]'));
});
test('test parse() method', function () {
$this->assertInstanceOf(ShortcodeFacade::class, flextype('shortcode')->addHandler('bar', static function() { return ''; }));
$this->assertTrue(is_array(flextype('shortcode')->parse('[bar]')));