-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MageSpec not load Mage::* class #99
Comments
Magespec is trying to encourage you to design your module in a way that separates your logic from the framework. Magespec is ideally suited to designing and verifying the business logic in your objects, and leaving simple stuff like pulling a config value to objects that you don't need to design. You might choose to create an object that acts as a facade in front of the store config like so:
You can then set up the constructor of your Gateway object to create the adapter if one isn't injected:
So now it's easy to use a mock of your config adapter in your specs:
|
First, thanks for help me, I'm an newbie with spec, BDD and TDD but I try this. First I create the Adapter folder and ConfigAdapter file in my module directory, look the tree: └── Cammino
└── Clearsale
├── Adapter
│ └── ConfigAdapter.php
├── Block
│ └── Info.php
├── etc
│ ├── config.xml
│ └── system.xml
└── Model
└── Gateway.php But when I execute the tests, the result is: Cammino_Clearsale_Model_Gateway
14 - it should be return the base url for homolog
collaborator does not exist : spec\Cammino_Clearsale_Adapter_ConfigAdapter
Cammino_Clearsale_Model_Gateway
20 - it should be return the standard base url
collaborator does not exist : spec\Cammino_Clearsale_Adapter_ConfigAdapter Sorry if this is a easy to resolve, I'm a newbie in this world, so what I need to do? |
Ah, sorry. That's an error on my part. You need to set those classes to the root namespace:
|
Look for my environment:
Suppose that I have this model:
Company/ModuleName/Model/Gateway
:And this spec Company_ModuleName_Model_GatewaySpec:
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?
The text was updated successfully, but these errors were encountered: