我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

模拟Wordpress单元测试

The function I'm testing requires another plugin, but I want to test it in isolation without having that plugin activated.

function functionName() {
   ...
   if (!is_plugin_active('path/to/plugin.php')) {
      return false;
   }
   return true;
}

How can I simulate that call returning true when I write a unit test?

You can modify the 'active_plugins' option during your tests to include that plugin.

See https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-admin/includes/plugin.php#L434.

近期文章

  • 使用复选框删除多行
  • TinyMCE数据操作
  • PHP Openssl Decrypt失败不一致
  • 403 Hostserver中的禁止错误(Codeigniter)
  • AWS ELB - 应用程序运行状况检查 - 示例PHP页面
  • opencart 2.x中产品页面的自定义SEO URL
  • 如何通过PHP将我的Android应用程序连接到MySQL
  • Codeigniter在多个JOIN上显示重复行
  • .htaccess重定向L,NC,QSA不按计划工作
  • 基于客户群的Magento税收计算方法
  • 试图阻止循环覆盖以前存储的值
  • 包括PayPal SDK PHP
  • Magento - 从控制器重定向到结帐成功页面不起作用
  • 由于htaccess而难以访问子目录文件
  • PDO:管理sql错误
  • PHP MySqli插入
  • 关于PHP,MYSQL,AJAX的问题
  • PHP语法中的JavaScript
  • php多语言获得两个参数
  • 安装时出现ErrorException

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华