Download the PHP package netrivet/ezekiel without Composer

On this page you can find all versions of the php package netrivet/ezekiel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ezekiel

Ezekiel

Ezekiel gives you an alternate wrapper, some syntactic sugar, and added convenience methods for working with the phpspec/prophecy library from within PHPUnit.

For making simple stubs and mocks with Prophecy, Ezekiel reduces a lot of the boilerplate code and gives you a terse, but fairly expressive syntax for creating test double objects.

A simple example

Say you wanted to a quick and dirty test dummy. Using Prophecy directly, you'd need to do something like this:

With Ezekiel, you would just write this:

Short syntax

For really simple stub objects, when you don't care about argument matching or returning different values on different invocations, you can use Ezekiel's short syntax:

Special return values

Stubs/mocks can return the first argument passed by using the special string ~firstArg

Stubs/mocks can return the arbitrary arguments passed by using the special string ~arg=X

Stubs/mocks can return themselves by using the special string ~self

Stub/mocks can also return references to test-case public properties using the coffee script-ish @ syntax. This is really useful if you want to setup a generic stub or mock in a test case setUp() method and modify individual components of what the test double returns for different test methods.

Stub/mocks can also pass arguments through callable function names using the skinny arrow ->

Stub/mocks can also return a joined version of all arguments passed by using the special string ~joinArgs or ~joinArgs|DELIMETER. This can be useful in very simple situations for verifying method invocations when it's not worth it to use the longer syntax or $this->calls()

Stubs/mocks can also return the result of invoking an anonymous function which is bound to the test-case's $this and receives the invocation arguments as arguments.

You can also combine the @prop syntax with anonymous functions to dynamically return the result of invoking a public property which is a anonymous function:

Longer syntax

Ezekiel can also accept a longer syntax that allows you to match arguments and return different values using 'with' and 'return' keywords.

Normally, the 'with' property must be an array, and correponds to the arguments that are being matched. If you don't care to match a certain argument, pass in the string * as a wildcard:

You can also pass in the non-array string value '*' to match any combination of arguments. This is useful for specifying default return values.

Creating mocks

By default, Ezekiel creates test stubs, not mocks. That means that we're specifying the behavior of the test double objects within the system under tests, but not directly testing how these objects are used. If we want to create true mock objects that contain expections, Ezekiel can help with that too. To create a mock object that contains expectation, just use the longer syntax explained above, but use 'expect' in place of 'with'.

You can also specify how many times a mock invocation is expected using the 'times' keyword. If you do not set the 'times' property, Ezekiel will treat it as though you expected an invocation of that method with those arguments at least once.

Ezekiel also allows you to do simple argument wildcarding by using the special string '*'.

You can make multiple expectations for a single method:

If you want to expect that a method should never be called, you can use a form of the short-syntax and the special string ~neverCalled to indicate that:

Inspecting invocations

Prophecy keeps a record of your test double method invocations, so you can do cool stuff like:

Ezekiel gives you an alternative method for inspecting recorded invocations that can be helpful in making very specific test spy assertions without writing crazy prediction matchers and callbacks.

You can also pass the special string ~last for the third paramater $invocationIndex as a shortcut to returning the last invocation of the requested method. This is useful if you're re-using a cached stub and want to inspect the most recent invocation of a method.

Note: to use Ezekiel::calls() you need to reset the recorded invocations in your teardown method like this: $this->recordedCalls = []; The Ezekiel trait provides a tearDown method that does this for you, but if you define your own in your test class, you'll need to do it yourself.

Transforming class names

If you want to make shortcuts to namespaced class names or otherwise transform the class names used by Ezekiel, just overwrite the transformClass method of the Ezekiel trait.

Caching

Ezekiel also caches stubbed objects and will returned a cached value if you request a stub with the exact same specifications. This can give you a noticable speed increase since prophecy doesn't have to dynamically recreate the stubbed class multiple times. It also allows you to not worry about performance when setting up identical stubbed objects in different test methods.

Installation

Pull the package in through Composer.

Then, just use the Ezekiel trait in a TestCase class that extends PHPUnit_Framework_TestCase.

If you want to have Ezekiel automatically available in all of your test cases, add the trait to a child class of PHPUnit_Framework_TestCase that all of your test case classes extend, like so:


All versions of ezekiel with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package netrivet/ezekiel contains the following files

Loading the files please wait ....