qubit05/phpunit-mockfunction 问题修复 & 功能扩展

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

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

qubit05/phpunit-mockfunction

Composer 安装命令:

composer require --dev qubit05/phpunit-mockfunction

包简介

PHPUnit extension to Mock PHP internal functions using Runkit.

README 文档

README

PHPUnit extension to Mock PHP internal functions using Runkit.

Requirements

*This is an optional requirement. Runkit doesn't currently support the override of internal functions (exit, die etc).

Installation

Using composer, add the following to the composer.json file:

{
   "require": {
       "qubit05/phpunit-mockfunction": "1.*"
   }
}

Example

ExampleClass.php

<?php
class ExampleClass
{
    public function doExample()
    {
        return date();
    }
}

ExampleClassTest.php

<?php
class ExampleClassTest extends \PHPUnit_Framework_TestCase
{
    public function testExample()
    {
        $param = 'Y-m-d H:i:s';
        $value = 'non date value';
    
        $mockFunction = new PHPUnit_Extensions_MockFunction('date', $this);
        $mockFunction->expects($this->once())
            ->with($this->equalTo($param))
            ->will($this->returnValue($value));
        
        $exampleClass = new ExampleClass();
        $this->assertEquals($value, $exampleClass->doExample($param));
    }
}

Acknowledgement

When this class was created, some inspiration was taken from tcz/phpunit-mockfunction. The two classes are similar but not the same.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固