Skip to content

MageSpec not load Mage::* class #99

@jonatanrdsantos

Description

@jonatanrdsantos

Look for my environment:

Suppose that I have this model: Company/ModuleName/Model/Gateway:

class Company_ModuleName_Model_Gateway {
    public function getBaseUrl() {
        if (Mage::getStoreConfig("payment_services/payment/environment") == 'homolog'){
            $url = 'http://homolog.example.com/sendRequest.aspx';
        } else {
            $url = 'http://example.com/sendRequest.aspx';
        }

        return $url;
    }
}

And this spec Company_ModuleName_Model_GatewaySpec:

class Company_ModuleName_Model_GatewaySpec {
    function it_should_be_return_the_base_url()
    {
        $this->getBaseUrl()->shouldBeLike('http://homolog.example.com/sendRequest.aspx');
    }
}

But when run $ bin/phpspec run, I receive this error:
PHP Fatal error: Class 'Mage' not found in /home/joridos/Documents/projects/magento/magento-test/.modman/magento-clearsale/app/code/community/Cammino/Clearsale/Model/Gateway.php on line 151

This is because this call: Mage::getStoreConfig("payment_services/payment/environment").

How I solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions