草庐IT

test_event

全部标签

php - wp_schedule_event 未触发

我正在尝试在主题的functions.php中安排一个事件,但我无法让它“启动”。我正在使用CronView插件,它显示事件已正确安排,但在执行时什么也没发生。这是我的代码if(!wp_next_scheduled('prefix_hourly_event')){wp_schedule_event(time(),'hourly','prefixhourlyevent');}add_action('prefixhourlyevent','prefix_do_this_hourly');functionprefix_do_this_hourly(){wp_mail('myemail@gma

php - 拉维尔 4.2 : Test Case Autoloading

现在,当我为我的Laravel应用程序设置一个新测试时,它从基础TestCase类扩展classSomeTestextendsTestCase{}我想创建一个名为AnotherTestCase的新基测试类,这样我就可以创建共享设置/拆卸/辅助方法等的测试用例...classSomeTestextendsAnotherTestCase{}但是,当我运行phpunitapp/tests/SomeTest.php出现以下错误PHPFatalerror:Class'AnotherTestCase'notfoundin/[...]/app/tests/SomeTest.phponline3尽管我

php - PHPUnit 测试需要在 "/test"目录中吗?

使用PHPUnit时,是否需要将测试放在/tests目录中?PHPUnit如何知道测试是“测试”?它是解析文件并查找方法名称,还是使用某种文件命名约定? 最佳答案 itrequiredforteststobeinsideofa/testsdirectory?没有。HowdoesPHPUnitknowthatatestisa"test"?通过反射(以及由用户指定要查看的目录)。 关于php-PHPUnit测试需要在"/test"目录中吗?,我们在StackOverflow上找到一个类似的问

php - wp_schedule_event()在类激活函数中不起作用

当我在主插件文件(plugin.php)的顶部安排一个事件时,cron被添加到wp_optionscron选项。wp_schedule_event(time()+10,'hourly','this_is_my_action');这很好用,它添加了新的cron。但是,当我尝试在插件类中的激活函数中使用相同的函数时,它不起作用。在plugin.php里面我有:$plugin=newMy_Plugin(__FILE__);$plugin->initialize();在My_Plugin类中我有:classMy_Plugin{function__construct($plugin_file){

php - 如何使用 Zend_Application 引导 Zend_Test_PHPUnit_ControllerTestCase?

我习惯于为我的应用程序使用PHPUnit_Framework_TestCase在ZendFramework1.9中编写单元测试。现在我正在尝试通过使用ZendFramework的Zend_Application的Bootstrap来编写基于Zend_Test_PHPUnit_ControllerTestCase的单元测试。但是我无法让它运行。这是我的非工作示例:classFamilyControllerTestextendsZend_Test_PHPUnit_ControllerTestCase{public$application;publicfunctionsetUp(){$thi

php - DDD : Should I use the Symfony EventDispatcher for my domain events?

我想知道我是否应该使用SymfonyEventDispatcherComponent用于在我的DDD应用程序中处理领域事件。对我来说,当一个经过良好测试的组件可用时,从头开始重新实现一个事件调度器毫无意义。但另一方面,Symfony组件使所有事件都从基类Event扩展而来。这不会将我的域事件绑定(bind)到EventDispatcher组件吗?此外,如果我确实使用这个组件,我应该在应用程序范围的event_dispatcher服务上引发域事件,还是应该将Symfony的应用程序事件和我的域事件分开(即创建一个新的EventDispatcher)? 最佳答案

php - Symfony Doctrine 事件订阅者未在调试 :event-dispatcher 中列出

Symfonyv3.3.4,DoctrineORMv2.5.6我已经为一个学说实体创建了一个事件订阅者:AppBundle\EventListener\LivreSubscriber:tags:-{name:doctrine.event_subscriber}它工作正常!但是很长一段时间我都认为它不起作用,因为监听器未在debug:event-dispatcher命令中列出:$docker-composeexecphpappbin/consoledebug:event-dispatcherdoctrine.event_subscriber[WARNING]Theevent"doctri

PHPUnit 和 Git : How to test with unreadable file?

简短版本:对于单元测试,我需要一个不可读的文件来确保抛出正确的异常。显然,Git无法存储那个不可读的文件,所以我在测试时chmod000并使用gitupdate-index--assume-unchanged这样Git就不会“t尝试存储不可读的文件。但是后来我无法checkout不同的分支,但收到错误消息“您对以下文件的本地更改将被checkout覆盖。”是否有更好的测试方法,或者更好的Git使用方法,以便一切正常运行?长版本:在一个类中,我有一个方法来读取文件,以便可以将其内容导入数据库:publicfunctionreadFile($path){...if(!is_readable

php - 插件中的 wp_schedule_event() 未安排 cron 事件

我正在创建一个WordPress插件,当插件被激活时,我需要一个cron作业来安排每5分钟运行一次。这是我的代码;//Registerpluginactivationhookfunctionmy_plugin_activate(){if(!wp_next_scheduled('my_function_hook')){wp_schedule_event(time(),'5','my_function_hook');}}register_activation_hook(__FILE__,'my_plugin_activate');//Registerplugindeactivationho

php - 脚本@php artisan package :discover handling the post-autoload-dump event returned with error code 255

我把我的项目从办公table搬到了另一个办公table。当我运行phpartisan时,它不起作用。我尝试运行composerupdate,但它返回错误Script@phpartisanpackage:discoverhandlingthepost-autoload-dumpeventreturnedwitherrorcode255 最佳答案 这就是我在从Laravel版本6.x-7.x升级后解决这个问题的方法:在App\Exceptions\Handler中更改//UseException;UseThrowable;然后方法接受T