单元测试WooCommerce扩展

问题描述 投票:0回答:1

我是PHARMtorm和PHPUnit以及wordpress-develop软件包的新手。

我的项目很多都依赖于WooCommerce。

是否可以将其添加为项目的依赖项?

目前我得到了这个结果:enter image description here

并进行以下设置:

enter image description here

enter image description here

任何帮助赞赏。

wordpress unit-testing woocommerce phpunit
1个回答
0
投票

搞定了

我做的是使用git来克隆woocommerce项目

git clone https://github.com/woocommerce/woocommerce/ temp

然后我复制了tests文件夹并将其放入我的项目中。然后我一直在编辑,直到它与我现有的代码一起工作。

这是我的项目现在的样子:

enter image description here

我在我的包含中有一份正常的woocommerce项目。没有测试的那个,你可以从WordPress插件库下载的那个。

我将WooCommerce测试复制到项目中,请参阅文件夹wc_tests。

这是tests / bootstrap.php文件的样子

enter image description here

请注意需要wc_tests / bootstrap.php文件的最后一行。

我只对wc_tests文件进行了一次更改,我更改了插件目录。

enter image description here

        $this->plugin_dir   = dirname( $this->tests_dir ) . '/includes/woocommerce';

结合屏幕外的一行代码,它使WC可用于项目

        require_once $this->plugin_dir . '/woocommerce.php';

我可能做错了一些,但它确实有效。

任何进一步的问题,提示或建议赞赏。

© www.soinside.com 2019 - 2024. All rights reserved.