Download the PHP package jlippitt/tusk without Composer

On this page you can find all versions of the php package jlippitt/tusk. 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 tusk

tusk

A PHP testing framework for elephants

The Basics

tusk is a testing framework for PHP in the style of BDD (behaviour-driven development) frameworks such as Jasmine (JavaScript) or RSpec (Ruby).

Each spec is denoted by an it block in the test file. describe blocks are used to group multiple specs into a suite. describe blocks can be nested to as deep a level as required.

Inside each spec, expect is used to create expectations which must be satisfied in order for the test to pass.

The canonical example:

describe('Bowling', function() {
    describe('getScore()', function() {
        it('returns 0 for an all gutter game', function() {
            $bowling = new Bowling();

            for ($i = 0; $i < 10; ++$i) {
                $bowling->hit(0);
            }

            expect($bowling->getScore())->toBe(0);
        });
    });
});

Set Up and Tear Down

Often you will have code that you want to run before each spec or after each spec within a describe block. This can be achieved using beforeEach and afterEach blocks:

describe('My Test Suite', function() {
    beforeEach(function() {
        echo "This will run before each spec\n";
    });

    afterEach(function() {
        echo "This will run after each spec\n"
    });

    // ...
});

Hooks defined on an outer describe block will also run before/after each spec inside any nested describe blocks.

Variable Scoping

PHP's closures (anonymous functions) have an odd quirk, in that if you want to capture any variables from the outer scope within the closure, you have to explicitly tell PHP with the use keyword.

Given our extensive use of anonymous functions for defining suites and specs, this could get quite tedious:

describe('Bowling', function() {
    $bowling = null;

    beforeEach(function() use (&$bowling) {
        $bowling = new Bowling();
    });

    describe('getScore()', function() use (&$bowling) {
        it('returns 0 for an all gutter game', function() use (&$bowling) {
            for ($i = 0; $i < 10; ++$i) {
                $bowling->hit(0);
            }

            expect($bowling->getScore())->toBe(0);
        });
    });
});

However, as of PHP 5.4, it's possible to bind the '$this' variable inside a closure to an arbitrary value. tusk makes extensive use of this and things work as you would expect:

describe('Bowling', function() {
    beforeEach(function() {
        $this->bowling = new Bowling();
    });

    describe('getScore()', function() {
        it('returns 0 for an all gutter game', function() {
            for ($i = 0; $i < 10; ++$i) {
                $this->bowling->hit(0);
            }

            expect($this->bowling->getScore())->toBe(0);
        });
    });
});

Expectations and Matchers

Expectations provide a number of built-in matchers:

All expectations can be negated by changing to to notTo, e.g. toBe becomes notToBe and toEqual becomes notToEqual.

Defining Custom Matchers

Custom matchers can be defined by adding them to the internal ExpectationFactory class, which will then make them available on all expectations within your specs. To do this, you'll need to first retrieve the ExpectationFactory from the Pimple dependency injection container, and then call the addMatch method for each matcher you want to add:

<?php

use Tusk\Container;
use Tusk\Matcher;

$expectationFactory = Container::getInstance()['ExpectationFactory'];

$expectationFactory->addMatcher(
    'toBeDivisibleBy',
    new Matcher(
        function($value, $divisor) {
            return $value % $divisor === 0;
        },
        'to be divisible by {0}'
    )
);

The matcher function can take any number of parameters, though the first parameter will always be the value that was passed to the expect function when creating the expectation. The remaining arguments are provided on the matcher method itself.

The second parameter to the matcher object determines the message that will be displayed to the user when the matcher does not succeed. Any of the arguments passed to the matcher method can be inserted into this string using {0}, {1}, {2}, etc. (where the number is their zero-indexed position in the argument list).

License

tusk is released under the MIT License. See the LICENSE file for more details.


All versions of tusk with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
pimple/pimple Version ~2.0
symfony/console Version ~2.4
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 jlippitt/tusk contains the following files

Loading the files please wait ....