Kahlan

✔️ PHP Test Framework for Freedom, Truth, and Justice
Alternatives To Kahlan
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Kahlan1,1382632018 days ago123June 18, 20228mitPHP
:heavy_check_mark: PHP Test Framework for Freedom, Truth, and Justice
Shellspec828
25 days ago74mitShell
A full-featured BDD unit testing framework for bash, ksh, zsh, dash and all POSIX shells
Public735
3 days ago141
Repository for Wallaby.js questions and issues
List Of Testing Tools And Frameworks For .net412
3 months agomitC#
✅ List of Automated Testing (TDD/BDD/ATDD/SBE) Tools and Frameworks for .NET
Rick And Morty Info398
2 years ago3mit
Made with Clean architecture + TDD + GraphQL + flutter_bloc + CodeCov + GitHooks + GitHub Actions (CI/CD) and finally with 💙
Stormpot2682382 years ago12June 07, 20206apache-2.0Java
A fast object pool for the JVM
Python Mocket254234a month ago86May 17, 2022bsd-3-clausePython
a socket mock framework - for all kinds of socket animals, web-clients included
Alsatian2491361752 years ago60January 10, 2020100mitTypeScript
TypeScript testing framework with test cases
Bashcov130
33 months ago25March 27, 201814mitRuby
Code coverage tool for Bash
Ddd Tdd Rich Domain Model Dojo Kata70
3 years agoapache-2.0C#
DDD patterns implemented following TDD
Alternatives To Kahlan
Select To Compare


Alternative Project Comparisons
Readme

Kahlan


Build Status License

Latest Stable Version Total Downloads Code Coverage

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

IRC

chat.freenode.net (server) #kahlan (channel)

Documentation

See the full documentation here

Requirements

  • PHP 7.1+
  • Composer
  • phpdbg or Xdebug (only required for code coverage analysis)

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:

dot_reporter

Example of verbose reporting:

verbose_reporter

Example of code coverage on a specific scope:

code_coverage

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)
Popular Code Coverage Projects
Popular Test Driven Development Projects
Popular Software Quality Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Php
Coverage
Tdd
Stub
Bdd
Test Framework
Xdebug
Monkey Patching