定制 dav-m85/magento-mock 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dav-m85/magento-mock

最新稳定版本:v0.1.1

Composer 安装命令:

composer require dav-m85/magento-mock

包简介

README 文档

README

Magento mock

Hat trick to have Mage class mocked.

Installation

Setup autoloading

// Register Varien autoloader for Mage related stuff
include_once "Varien/Autoload.php";
include_once "core/Mage/Core/functions.php";

spl_autoload_register(array(Varien_Autoload::instance(), 'autoload'));

// Mock Mage instance
include_once "Mage.php";
include_once "MageMockInterface.php";

Usage

class CustomerTest extends PHPUnit_Framework_TestCase
{
    private $mage;

    public function setUp()
    {
        $this->mage = $this->prophesize("MageMockInterface");
        Mage::setMageInstance($this->mage->reveal());

        // Getting an helper ?
        $this->mage->helper('some-helper')->willReturn(...);
        
        // New Model ?
        $this->mage->getResourceSingleton("customer/customer", \Prophecy\Argument::cetera())->willReturn(
            $this->prophesize('Mage_Core_Model_Resource_Db_Abstract')->reveal()
        );
    }

    public function testSomething()
    {
        ...
    }

统计信息

  • 总下载量: 5.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-13