betooliveirame / codeception-magento
此包已弃用且不再维护。未建议替代包。
Codeception 集成到 Magento
1.0.3
2019-09-02 15:00 UTC
Requires
- php: >=5.6
- codeception/codeception: ~2.2
README
Composer 安装
composer require betooliveira/codeception-magento
配置
codeception.yml
extensions:
enabled:
- Codeception\Extension\RunFailed
- Magento\Codeception\Extension\Magento
config:
Magento\Codeception\Extension\Magento:
magento-dir: 'src'
unit.suite.yml
class_name: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
- \Magento\Codeception\Helper\Magento
模拟模型
$modelMock = $this->getMockBuilder('Custom_Custom_Model_Custom')
->setMethods(array('getData'))
->getMock();
$modelMock->expects($this->once())
->method('getData')
->will($this->returnValue(array('teste)));
$this->tester->replaceModelByMock('custom/custom', $modelMock);
$result = Mage::getModel('custom/custom);
$this->tester->assertSame($modelMock, $result);
模拟单例
$singletonMock = $this->getMockBuilder('Custom_Custom_Model_Custom')
->setMethods(array('getData'))
->getMock();
$singletonMock->expects($this->once())
->method('getData')
->will($this->returnValue(array('teste)));
$this->tester->replaceSingletonByMock('custom/custom', $singletonMock);
$result = Mage::getSingleton('custom/custom);
$this->tester->assertSame($singletonMock, $result);
模拟助手
$helperMock = $this->getMockBuilder('Custom_Custom_helper_Custom')
->setMethods(array('getData'))
->getMock();
$helperMock->expects($this->once())
->method('getData')
->will($this->returnValue(array('teste)));
$this->tester->replaceHelperByMock('custom/custom', $helperMock);
$result = Mage::helper('custom/custom);
$this->tester->assertSame($helperMock, $result);