Overview

Namespaces

  • phpmock
    • mockery

Classes

  • PHPMockery
  • Overview
  • Namespace
  • Class

Class PHPMockery

Mock built-in PHP functions with Mockery.

<?php

namespace foo;

use phpmock\mockery\PHPMockery;

$mock = PHPMockery::mock(__NAMESPACE__, "time")->andReturn(3);
assert (3 == time());

\Mockery::close();
Namespace: phpmock\mockery
License: WTFPL
Author: Markus Malkusch markus@malkusch.de
Link: Donations
Located at PHPMockery.php
Methods summary
public static Mockery\Expectation
# mock( string $namespace, string $name )

Builds a function mock.

Builds a function mock.

Disable this mock after the test with Mockery::close().

Parameters

$namespace
The function namespace.
$name
The function name.

Returns

Mockery\Expectation
The mockery expectation.

Suppresswarnings(phpmd)

public static
# define( string $namespace, string $name )

Defines the mocked function in the given namespace.

Defines the mocked function in the given namespace.

In most cases you don't have to call this method. phpmock\mockery\PHPMockery::mock() is doing this for you. But if the mock is defined after the first call in the tested class, the tested class doesn't resolve to the mock. This is documented in Bug #68541. You therefore have to define the namespaced function before the first call.

Defining the function has no side effects. If the function was already defined this method does nothing.

Parameters

$namespace
The function namespace.
$name
The function name.

See

phpmock\mockery\PHPMockery::mock()

Link

Bug #68541
API documentation generated by ApiGen