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:
@@ -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]')));
|
||||
|
Reference in New Issue
Block a user