Powererd code-x GmbH & webguys.de
$mock = $this->getModelMock('catalog/product', array('isAvailable') );
$mock->expects($this->any())
->method('isAvailable')
->willReturn($productIsAvailable);
$this->addModelMock('catalog/product', $mock);
$mock = $this->getHelperMock('codex_demo', array('getDemoMethod'));
$mock->expects($this->any())
->method('getDemoMethod')
->willReturn('some value');
$this->addHelperMock('codex_demo', $mock);
class Codex_Demo_Model_Weather extends Varien_Object
{
protected function _apiCall($city, $country)
{
return file_get_contents('http://api.openweathermap.org/data/2.5/weather?q='.$city.','.$country);
}
}
class Codex_Demo_Test_Double_Model_Weather extends Codex_Demo_Model_Weather
{
protected function _apiCall($city, $country)
{
return '{ "coord": { "lon": 8.75, "lat": 51.72 }, "sys": { "type": 3, "id": 177301, "message": 0.0283, "country": "DE", "sunrise": 1425190178, "sunset": 1425229494 }, "weather": [ { "id": 803, "main": "Clouds", "description": "broken clouds", "icon": "04d" } ], "base": "cmc stations", "main": { "temp": 283.41, "humidity": 65, "pressure": 1001, "temp_min": 283.15, "temp_max": 283.55 }, "wind": { "speed": 1, "gust": 3, "deg": 180 }, "rain": { "3h": 0 }, "clouds": { "all": 64 }, "dt": 1425221237, "id": 2855745, "name": "Paderborn", "cod": 200 }';
}
}
/** @var $orderFixture Codex_Xtest_Xtest_Fixture_Order */
$orderFixture = Xtest::getXtest('xtest/fixture_order');
$testOrder = $orderFixture->getTest();
/** @var $customerFixture Codex_Xtest_Xtest_Fixture_Customer */
$customerFixture = Xtest::getXtest('xtest/fixture_customer');
$testCustomer = $customerFixture->getTest()
/** @var $mailqueue Codex_Xtest_Xtest_Helper_Mailqueue */
$mailqueue = Xtest::getXtest('xtest/helper_mailqueue');
$this->assertMailTemplateIdSent($yourTemplateId);
$this->assertMailsSent($yourMailsSentCount);
cd htdocs/tests
php phpunit.phar ../app/code/local/