Amock

Mock objects library for PHP 5

Author: Roman Neuhauser
Contact: neuhauser@sigpipe.cz
Copyright: This document has been placed in the public domain.
Id:README.rest 267 2006-12-12 21:19:58Z roman
HeadURL:$HeadURL: https://svn.sigpipe.cz/r/trunk/amock/README.rest $

Contents

1   Introduction

Amock is an open-source [1] mocking library written in PHP 5 [3] for programs written in PHP 5. Mock objects for classes or interfaces are generated on the fly using a source code generator.

Amock is published under the MIT license [2] which means you are free and welcome to use it in any way.

Amock is an essential ingredient in BEER [4].

2   Prerequisities

3   Downloads

3.1   Repository

The latest source get be checked out from the Subversion [5] repository [6], which is also available for anonymous browsing using the viewvc [7] interface [8].

3.2   Official tarballs

Amock source releases are distributed as bzip2ed tarballs created with either Tim Kientzle's bsdtar [9] or GNU tar, Julian Seward's bzip2 [10] in all cases. Your operating system should include compatible extraction tools.

All Amock releases can be found in the download directory [11].

4   Build and Installation

4.1   From a package

The most comfortable way to install Amock is using your operating system's packaging system. Ask your OS vendor for a package of the latest Amock release.

The source distribution includes a FreeBSD port skeleton.

4.2   From the source

4.2.1   Wash and Go instructions

% url=http://www.amock.org/dist/amock-x.y.x.tar.gz
% fetch -o - $url | tar -xzf -
% cd amock-x.y.z
% make check install

4.2.2   Detailed description

The build and installation process can be configured using a number of variables. Use the help target to display builtin help.

% make help
these targets display help for individual topics:

help-targets:  help for targets
help-var:      help for variables
%

Functionality not described in the builtin help should be considered implementation details. If the documented features don't support all your configuration needs, please do send a feature request.

Amock is tested on FreeBSD 6 with the system make (should work on any BSD) and GNU make.

4.2.2.1   Running the test suite

Amock's Testilence [12]-based test suite can be exercised with or without installed Amock by running make check or make maint-check in the source directory. The former target excludes tests that use filesystem or other external resources, because a bug in Amock might prevent proper cleanup or (although unlikely) delete your files.

The test suite is described in more detail further below.

5   Reference

6   Examples

7   Releases

7.1   Release types

Amock releases fall into one of the following four categories:

  • snapshots
  • bugfix releases
  • new functionality
  • backward-incompatible change

7.2   Release versioning

Each release is tagged with a version number string with the following structure (ABNF [13]):

version-string    = compat-cnt "." newfun-cnt "." bugfix-cnt [rel-candidate]
compat-cnt    = counter
newfun-cnt    = counter
bugfix-cnt    = counter
rel-candidate = "." snapshot counter
; "snap"
snapshot          = %x73.6e.61.70
; counter is a positive integer (includes 0)
counter            = 1 * DIGIT

For each release of any type the appropriate counter is incremented by at least one and counters to the right of it are reset to 0 (the release-candidate part is removed altogether), while counters to the left of it are left at their current values.

Version string of the first nonsnapshot Amock release is 0.0.0, while "0.0.0.snap135" is the version string of a pre-0.0.0 snapshot. Note that there may be gaps between.

This handling is consistent with the way FreeBSD's pkg_version -t [14] interprets version strings.

8   Test suite

The suite is organized around Amock's classes, meaning there is one or more cases per class under test. These are in turn organized into suites, possibly multiple levels of them. Any part of the resulting tree can be run.

[1]http://opensource.org/docs/definition.php
[2]http://opensource.org/licenses/mit-license.php
[3]http://www.php.net/
[4]http://beer.sigpipe.cz/
[5]http://subversion.tigris.org/
[6]https://svn.sigpipe.cz/r/
[7]http://www.viewvc.org/
[8]http://svn.sigpipe.cz/
[9]http://people.freebsd.org/~kientzle/libarchive/
[10]http://www.bzip.org/
[11]http://www.amock.org/dist/
[12]http://www.testilence.org/
[13]http://tools.ietf.org/html/rfc4234
[14]http://www.freebsd.org/cgi/man.cgi?query=pkg_version