

GitHub - kahlan/kahlan: PHP Test Framework for Freedom, Truth, and Justice
source link: https://github.com/kahlan/kahlan
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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
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)
</article
Recommend
-
38
Join GitHub today GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
-
30
README.org dungeon-mode - synchronous and asynchronous world sharing and change resolution SYNOPSYS An hack-and-slash style mult-player dungeon crawl ble...
-
5
January 5, 2021 Company Advancing developer freedom: GitHub is fully available in Iran ...
-
4
John Vallis On His Podcast, Truth, Freedom And Bitcoin 2021 – HodlalertJohn Vallis On His Podcast, Truth, Freedom And Bitcoin 2021 Bitco...
-
5
This is all very much a work in progress! More to come! ( We're working on it though! Stay tuned!) Installation Open an Anaconda Prompt (in Windows, or any terminal on Mac/Linux) and enter the following comands...
-
14
Vitest A blazing fast unit test framework powered by Vite. Get involved!
-
7
README.md ##FreeDMO Endless freedom for D.MO...
-
8
Software Freedom Conservancy: Give Up GitHub: The Time Has Come! [Posted June 30, 2022 by jake] The Software Freedom Conservancy (SFC) has...
-
5
Home ...
-
11
aire-test Aire Testing Framework is a powerful and convenient framework for testing Vaadin components and interactions. Aire Test builds off of the fantastic Karibu in-mem...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK