fp/fumocker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

fp/fumocker

Composer 安装命令:

composer require fp/fumocker

包简介

A php function mocker

README 文档

README

Are you wonna mock mail function?

<?php

class FooTestCase extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Fumocker\Fumocker
     */
    protected $fumocker;

    public function setUp()
    {
        $this->fumocker = new \Fumocker\Fumocker;
    }

    public function tearDown()
    {
        $this->fumocker->cleanup();
    }

    public function testMailNeverCalled()
    {
        /**
         * @var $mock \PHPUnit_Framework_MockObject_MockObject
         */
        $mock = $this->fumocker->getMock('Namespace\Where\Tested\Class\Is', 'mail');
        $mock
            ->expects($this->never())
            ->method('mail')
        ;

        //test your Namespace\Where\Tested\Class\Is\Foo
    }


    public function testMailSendToAdminWithStatisticSubject()
    {
        $expectedEmailTo = 'admin@example.com';

        /**
         * @var $mock \PHPUnit_Framework_MockObject_MockObject
         */
        $mock = $this->fumocker->getMock('Namespace\Where\Tested\Class\Is', 'mail');
        $mock
            ->expects($this->once())
            ->method('mail')
            ->with(
                $this->equalTo($expectedEmailTo),
                $this->equalTo('Statisitic of money earned by a week')
            )
        ;

        //test your Namespace\Where\Tested\Class\Is\Foo
    }


    public function testRealMailSend()
    {
        /**
         * Dont do a mock and real function will be called
         */
    }
}

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2011-11-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固