Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
Created September 15, 2013 06:42
Show Gist options
  • Select an option

  • Save ScreamingDev/6568535 to your computer and use it in GitHub Desktop.

Select an option

Save ScreamingDev/6568535 to your computer and use it in GitHub Desktop.
Evil eval
function testMike()
{
// mock Mage_Catalog_Model_Product::save for throwing errors
$alias = 'catalog/product';
$cookieMock = $this->getMock($alias, array('save'));
$cookieMock->expects($this->exactly(2))->method('save')->will(
$this->returnCallback(function () {
throw Exception();
})
);
$this->replaceByMock('model', $alias, $cookieMock);
Mage::getModel($alias)->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment