Download the PHP package rmiller/exemplify-extension without Composer
On this page you can find all versions of the php package rmiller/exemplify-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rmiller/exemplify-extension
More information about rmiller/exemplify-extension
Files in rmiller/exemplify-extension
Package exemplify-extension
Short Description PhpSpec extension that adds exemplify command to generate examples in specs
License MIT
Homepage https://github.com/richardmiller/ExemplifyExtension
Informations about the package exemplify-extension
ExemplifyExtension
PhpSpec extension that adds exemplify command to generate examples in specs.
For example, running:
And choosing the default option of 'instance method', will add the following example to the spec/RMiller/BadgerSpec class:
This can then be modified to describe the behaviour for the method.
Installation
Requires:
- PhpSpec 3.0+
- PHP 5.6+
To use 'named constructor' examples , you need to use phpspec >2.1
.
Otherwise the examples will be created but will not run.
Require the extension:
Configuration
Activate the extension by specifying its class in your phpspec.yml
:
Method Types
Three different method types are supported, on running the command you will be asked which type of method is being described. These are:
- Instance Method (e.g. $this->dig())
- Static Method (e.g. $this::dig())
- Named Constructor
The names constructor option is for static methods used to instantiate and return an instance of the class. It is essentially another name for a factory method. This is listed separately as the example created is different.
For example, running:
And choosing the option of 'named constructor', will add the following to the spec/RMiller/BadgerSpec class:
Other Potentially Useful Extensions
-
For further laziness PhpSpecRunExtension will execute the phpspec run command after the describe and exemplify commands, saving a few keystrokes.
- This extension and PhpSpecRun are also part of BehatSpec which provides integration between Behat and PhpSpec. This includes running the exemplify command automatically for missing methods encountered when running Behat features.