kahlan / kahlan
The PHP Test Framework for Freedom, Truth and Justice.
Installs: 879 717
Dependents: 289
Suggesters: 0
Security: 0
Stars: 1 143
Watchers: 30
Forks: 68
Open Issues: 7
Requires
- php: >=7.2
Requires (Dev)
- rector/rector: ^1.0.5
- squizlabs/php_codesniffer: 3.7.2
- dev-master
- 5.2.7
- 5.2.6
- 5.2.5
- 5.2.4
- 5.2.3
- 5.2.2
- 5.2.1
- 5.2.0
- 5.1.3
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.7.7
- 4.7.6
- 4.7.5
- 4.7.4
- 4.7.3
- 4.7.2
- 4.7.1
- 4.7
- 4.6.4
- 4.6.3
- 4.6.2
- 4.6.1
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.8
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.5.8
- 2.5.7
- 2.5.6
- 2.5.5
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dev
- dev-bump-rector-105
- dev-deprecated-5.0
This package is auto-updated.
Last update: 2024-09-30 16:04:50 UTC
README
Kahlan is a full-featured Unit & BDD test framework a la RSpec/JSpec which uses a describe-it
syntax and moves testing in PHP one step forward.
Kahlan lets you stub or monkey patch your code directly like in Ruby or JavaScript without any required PECL-extensions.
Videos
- Warren Seymour presentation at Unified Diff (2015)
- Grafikart presentation in French (2016, Kahlan 2.X)
IRC
chat.freenode.net (server) #kahlan (channel)
Documentation
See the full documentation here
Requirements
Main Features
- RSpec/JSpec syntax
- Code Coverage metrics (xdebug or phpdbg required)
- Handy stubbing system (mockery or prophecy are no longer needed)
- Set stubs on your class methods directly (i.e allows dynamic mocking)
- Ability to Monkey Patch your code (i.e. allows replacement of core functions/classes on the fly)
- Check called methods on your classes/instances
- Built-in Reporters (Terminal or HTML reporting through istanbul or lcov)
- Built-in Exporters (Coveralls, Code Climate, Scrutinizer, Clover)
- Extensible, customizable workflow
Syntax
<?php describe("Example", function() { it("makes an expectation", function() { expect(true)->toBe(true); }); it("expects methods to be called", function() { $user = new User(); expect($user)->toReceive('save')->with(['validates' => false]); $user->save(['validates' => false]); }); it("stubs a function", function() { allow('time')->toBeCalled()->andReturn(123); $user = new User(); expect($user->save())->toBe(true) expect($user->created)->toBe(123); }); it("stubs a class", function() { allow('PDO')->toReceive('prepare', 'fetchAll')->andReturn([['name' => 'bob']]); $user = new User(); expect($user->all())->toBe([['name' => 'bob']]); }); });
Screenshots
Example of default reporting:
Example of verbose reporting:
Example of code coverage on a specific scope:
Installation
via Composer
$ composer require --dev kahlan/kahlan
Note:
Kahlan uses the Semantic Versioning and maintains a CHANGELOG
to help you easily understand what's happening.
via Git clone
git clone git://github.com/kahlan/kahlan.git
cd kahlan
composer install
bin/kahlan # to run specs or,
bin/kahlan --coverage=4 # to run specs with coverage info for namespaces, classes & methods (require xdebug)