downshiftorg/wp-event-emitter

WordPress 行为的对象化事件发射器

6.0.0 2018-01-15 17:42 UTC

This package is not auto-updated.

Last update: 2024-09-15 05:44:32 UTC


README

WordPress 行为的对象化事件发射器

动机

提供一个熟悉的事件接口,该接口委托给 WordPress 的全局 add_actiondo_action 函数。它还提供了一个更容易测试的接口,因为它只在它们可用时使用 WP 函数。

方法

on

委托给 WordPress 的 add_action 函数。在测试环境中将使用本地监听器集合。

emit

委托给 WordPress 的 do_action 函数。在测试环境中将使用本地监听器集合。

filter

委托给 WordPress 的 add_filter 函数。在测试环境中将使用本地监听器集合。

applyFilters

委托给 WordPress 的 apply_filters 函数。在测试环境中将使用本地监听器集合。

测试

测试使用 PHPUnit

$ vendor/bin/phpunit