Git Product home page Git Product logo

uopz-expectations's Introduction

uopz-expectations

Mock core functions and set up expectations similar to Mockery.

Full documentation is available at http://duncan3dc.github.io/uopz-expectations/
PHPDoc API documentation is also available at http://duncan3dc.github.io/uopz-expectations/api/

release build coverage

Introduction

The uopz extension offers an easy to way mock core functions.
The Mockery library offers a succinct API to declare expectation method calls.
This library combines the two to offer core function mocking with a familiar API.

Installation

The recommended method of installing this library is via Composer.

Run the following command from your project root:

$ composer require --dev duncan3dc/uopz-expectations

Getting Started

use duncan3dc\Mock\CoreFunction;

CoreFunction::mock("time")->twice()->with()->andReturn(777);

time(); # 777

/**
 * At this point the expectations will be checked,
 * and an exception will be throw as `time()`
 * should have been called twice.
 */
CoreFunction::close();

Read more at http://duncan3dc.github.io/uopz-expectations/

Where to get help

Found a bug? Got a question? Just not sure how something works?
Please create an issue and I'll do my best to help out.
Alternatively you can catch me on Twitter

duncan3dc/uopz-expectations for enterprise

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/uopz-expectations and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

uopz-expectations's People

Contributors

duncan3dc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

uopz-expectations's Issues

Can't mock include

Steps to reproduce:

Uopz-expectations is working:

public function test() {
    CoreFunction::mock('time')->andReturn(666);
    echo time();
}

This test did not perform any assertions
666

Call to include fails:

public function test() {
    //		CoreFunction::mock('include');
    include('some/path');
}

include(some/path): failed to open stream: No such file or directory

Mocked call to include also fails

public function test() {
	CoreFunction::mock('include');
	include('some/path');
}

ReflectionException : Function include() does not exist
     /vendor/duncan3dc/uopz-expectations/src/ClosureGenerator.php:79
     /vendor/duncan3dc/uopz-expectations/src/ClosureGenerator.php:31
     /vendor/duncan3dc/uopz-expectations/src/CoreFunction.php:33

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.