HamuSumo
HamuSumo

Reputation: 41

Looking for the exact config.xml location for PHPUnit testing in Magento

I'm currently trying to get PHPUnit working with together with Magento. On some places in the web people recommend the extension from EcomDev so I tried it out.

I build an example setup like written in this tutorial, I just replaced EcomDev_Example_... with Test_JustTest_...

However, it doesn't work as it should and I guess I put the data in the wrong config.xml. At the moment I've written down the module name in /app/code/local/Test/JustTest/etc/config.xml and in the config.xml of the extension to just try something different. Well, I can run PHPUnit but it always tells me that there's no test to run.

I spent a lot of time on Google not finding a more detailed example

Upvotes: 0

Views: 389

Answers (1)

Ricardo Martins
Ricardo Martins

Reputation: 6003

Im faced with the same problem, but now I get it worked. I created app/code/local/Namespace/Module/etc/config.xml with:

<?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>

In fact the name of these are not Namespace_Module, I just replaced to show you. Its a module that overrides numeric model from magento, but it has no big differences.

See that my test is under app/code/local/Namespace/Module/Test/Model/Entity/Increment/Numeric.php

And looks like:

<?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);
    }
}

After all set, you should run your tests using the following command on console/terminal:

phpunit UnitTests.php

Remember that you should enable your module by adding Namespace_Module.xml at app/etc/modules as any other model. My mistake was that i named the folder as Tests instead of Test in my model. I dont think you are doing the same thing...

Anyway, I hope it helps. For more information, the manual could help you a lot.

Upvotes: 1

Related Questions