在Magento中查找PHPUnit测试的确切config.xml位置

时间:2012-09-06 13:41:33

标签: phpunit magento-1.7

我目前正在努力让PHPUnit与Magento一起工作。在网络的某些地方,人们推荐EcomDev的扩展,所以我试了一下。

我构建了一个像this tutorial中编写的示例设置,我刚用Test_JustTest _...替换了EcomDev_Example _...

然而,它不能正常工作,我想我把数据放在错误的config.xml中。目前我已经在/app/code/local/Test/JustTest/etc/config.xml和扩展程序的config.xml中写下了模块名称,只是尝试了不同的东西。好吧,我可以运行PHPUnit,但它总是告诉我没有测试可以运行。

我花了很多时间在Google上找不到更详细的例子

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,但现在我觉得它有用了。 我创建了 app / code / local / Namespace / Module / etc / config.xml

<?xml version="1.0"?>
<config>
    <phpunit>
        <suite>
            <modules>
                <Namespace_Module/>
            </modules>
        </suite>
    </phpunit>
    <modules>
        <namespace_module>
            <version>0.1</version>
        </namespace_module>
    </modules>
    <global>
        <models>
            <eav>
                <rewrite>
                    <entity_increment_numeric>Namespace_Module_Model_Entity_Increment_Numeric</entity_increment_numeric>
                </rewrite>
            </eav>
        </models>
    </global>
</config>

实际上这些名称不是Namespace_Module,我只是替换给你看。它是一个从magento覆盖数字模型的模块,但它没有太大的区别。

看到我的测试结果 应用/代码/本地/命名空间/模块/测试/型号/实体/递增/ Numeric.php

看起来像:

<?php
class Namespace_Module_Test_Model_Entity_Increment_Numeric extends EcomDev_PHPUnit_Test_Case
{

    /**
    * Test Next Id Never Returns zero
    *
    * @test
    */
    public function testGetNextIdNeverReturnsZero(){   
        $this->assertTrue(true);
    }
}

完成所有设置后,您应该在console / terminal上使用以下命令运行测试:

  

phpunit UnitTests.php

请记住,您应该通过在app / etc / modules中添加Namespace_Module.xml来启用您的模块,就像任何其他模型一样。我的错误是我在我的模型中将文件夹命名为Tests而不是Test。我不认为你在做同样的事情......

无论如何,我希望它有所帮助。有关详细信息,the manual可以为您提供很多帮助。