Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 16, 2024 via composer

mockery/mockery 1.6.7

Mockery is a simple yet flexible PHP mock object framework
Package summary
Share
0
issues
1
license
2
BSD-3-Clause
Package created
21 Jan 2012
Version published
10 Dec 2023
Maintainers
3
Total deps
2
Direct deps
1
License
BSD-3-Clause

Issues

0
This package has no issues

Licenses

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
hamcrest/hamcrest-php@v2.0.1
mockery/mockery@1.6.7
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of mockery/mockery 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
hamcrest/hamcrest-phpv2.0.1116 kBBSD-3-Clause
prod

Visualizations

Frequently Asked Questions

What does mockery/mockery do?

Mockery/mockery is a flexible and simple PHP mock object framework that is used in unit testing with PHPUnit, PHPSpec or any other testing framework. The primary goal of Mockery is to offer a test double framework that has a succinct API capable of clearly defining all possible operations and interactions using a human-readable Domain Specific Language (DSL). It's designed to serve as an alternative to PHPUnit's phpunit-mock-objects library, and can operate alongside phpunit-mock-objects without causing any issues. It's useful to provide test isolation, to stand in for objects which do not yet exist, or to allow for the exploratory design of class APIs without requiring implementation upfront.

How do you use mockery/mockery?

To use Mockery, first, you need to install it using composer by running composer require --dev mockery/mockery. Once installed, you can start creating your test double, also known as mocks. Here is a basic example of how to create a test double with Mockery:

$double = Mockery::mock();

If you need Mockery to create a test double that satisfies a particular type hint, you can pass the type to the mock method.

class Book {}

interface BookRepository {
    function find($id): Book;
    function findAll(): array;
    function add(Book $book): void;
}

$double = Mockery::mock(BookRepository::class);

You can also create and set up method stubs, setup expectations on method calls, apply spyOn, and much more with Mockery. You need to call Mockery::close() at the end of every test.

public function tearDown()
{
    Mockery::close();
}

Where are the mockery/mockery docs?

The Mockery/mockery's documentation can be found at this location. The documentation provides extended guidance on how to use Mockery, including creating test doubles, setting up method stubs and expectations, using spies, and includes a variety of other utilities for testing.