{"id":13519352,"url":"https://github.com/kahlan/kahlan","last_synced_at":"2025-12-18T12:07:08.448Z","repository":{"id":10128267,"uuid":"12199480","full_name":"kahlan/kahlan","owner":"kahlan","description":":heavy_check_mark: PHP Test Framework for Freedom, Truth, and Justice","archived":false,"fork":false,"pushed_at":"2025-02-22T16:05:43.000Z","size":3788,"stargazers_count":1146,"open_issues_count":6,"forks_count":68,"subscribers_count":28,"default_branch":"dev","last_synced_at":"2025-04-28T00:34:43.319Z","etag":null,"topics":["bdd","coverage","monkey-patching","php","spec","tdd","test"],"latest_commit_sha":null,"homepage":"https://kahlan.github.io/docs/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kahlan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-08-18T18:12:58.000Z","updated_at":"2025-04-14T17:47:08.000Z","dependencies_parsed_at":"2023-12-05T09:27:28.619Z","dependency_job_id":"f352cbd6-cc68-40ad-bc12-1325fc283ba9","html_url":"https://github.com/kahlan/kahlan","commit_stats":{"total_commits":967,"total_committers":37,"mean_commits":"26.135135135135137","dds":"0.19855222337125134","last_synced_commit":"076da1c9747da903a510ec80e44f15536d23bacb"},"previous_names":["crysalead/kahlan"],"tags_count":133,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlan%2Fkahlan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlan%2Fkahlan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlan%2Fkahlan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlan%2Fkahlan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kahlan","download_url":"https://codeload.github.com/kahlan/kahlan/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251559719,"owners_count":21609062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdd","coverage","monkey-patching","php","spec","tdd","test"],"created_at":"2024-08-01T05:01:57.729Z","updated_at":"2025-12-18T12:07:03.059Z","avatar_url":"https://github.com/kahlan.png","language":"PHP","funding_links":[],"categories":["PHP","Table of Contents","Tools","目录"],"sub_categories":["Testing","PHP","测试 Testing","Globalization"],"readme":"![Kahlan](docs/assets/logo.png \"Kahlan\")\n\u003chr/\u003e\n\n![Build Status](https://github.com/kahlan/kahlan/workflows/Build/badge.svg) [![License](https://poser.pugx.org/kahlan/kahlan/license.svg)](https://packagist.org/packages/kahlan/kahlan)\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/kahlan/kahlan.svg)](https://packagist.org/packages/kahlan/kahlan)\n[![Total Downloads](https://img.shields.io/packagist/dt/kahlan/kahlan.svg)](https://packagist.org/packages/kahlan/kahlan)\n[![Code Coverage](https://codecov.io/gh/kahlan/kahlan/branch/dev/graph/badge.svg)](https://app.codecov.io/gh/kahlan/kahlan/)\n\nKahlan is a full-featured Unit \u0026 BDD test framework a la RSpec/JSpec which uses a `describe-it` syntax and moves testing in PHP one step forward.\n\n**Kahlan lets you stub or monkey patch your code directly like in Ruby or JavaScript without any required PECL-extensions.**\n\n## Videos\n\n* \u003ca href=\"http://vimeo.com/116949820\" target=\"_blank\"\u003eWarren Seymour presentation at Unified Diff (2015)\u003c/a\u003e\n* \u003ca href=\"https://www.grafikart.fr/tutoriels/php/tdd-kahlan-805\" target=\"_blank\"\u003eGrafikart presentation in French (2016, Kahlan 2.X)\u003c/a\u003e\n\n## IRC\n\n**chat.freenode.net** (server)\n**#kahlan** (channel)\n\n## Documentation\n\nSee the [full documentation here](https://kahlan.github.io/docs)\n\n## Requirements\n\n * PHP 7.4+\n * Composer\n * [phpdbg](http://php.net/manual/en/debugger-about.php) or [Xdebug](http://xdebug.org/) (only required for code coverage analysis)\n\n## Main Features\n\n* RSpec/JSpec syntax\n* Code Coverage metrics ([xdebug](http://xdebug.org) or [phpdbg](http://phpdbg.com/docs) required)\n* Handy stubbing system ([mockery](https://github.com/padraic/mockery) or [prophecy](https://github.com/phpspec/prophecy) are no longer needed)\n* Set stubs on your class methods directly (i.e allows dynamic mocking)\n* Ability to Monkey Patch your code (i.e. allows replacement of core functions/classes on the fly)\n* Check called methods on your classes/instances\n* Built-in Reporters (Terminal or HTML reporting through [istanbul](https://gotwarlost.github.io/istanbul/) or [lcov](http://ltp.sourceforge.net/coverage/lcov.php))\n* Built-in Exporters (Coveralls, Code Climate, Scrutinizer, Clover)\n* Extensible, customizable workflow\n\n## Syntax\n\n```php\n\u003c?php\n\ndescribe(\"Example\", function() {\n\n    it(\"makes an expectation\", function() {\n\n         expect(true)-\u003etoBe(true);\n\n    });\n\n    it(\"expects methods to be called\", function() {\n\n        $user = new User();\n        expect($user)-\u003etoReceive('save')-\u003ewith(['validates' =\u003e false]);\n        $user-\u003esave(['validates' =\u003e false]);\n\n    });\n\n    it(\"stubs a function\", function() {\n\n        allow('time')-\u003etoBeCalled()-\u003eandReturn(123);\n        $user = new User();\n        expect($user-\u003esave())-\u003etoBe(true)\n        expect($user-\u003ecreated)-\u003etoBe(123);\n\n    });\n\n    it(\"stubs a class\", function() {\n\n        allow('PDO')-\u003etoReceive('prepare', 'fetchAll')-\u003eandReturn([['name' =\u003e 'bob']]);\n        $user = new User();\n        expect($user-\u003eall())-\u003etoBe([['name' =\u003e 'bob']]);\n\n    });\n\n});\n\n```\n\n## Screenshots\n\n### Example of default reporting:\n![dot_reporter](docs/assets/dot_reporter.png)\n\n### Example of verbose reporting:\n![verbose_reporter](docs/assets/verbose_reporter.png)\n\n### Example of code coverage on a specific scope:\n![code_coverage](docs/assets/code_coverage.png)\n\n## Installation\n\n### via Composer\n\n```bash\n$ composer require --dev kahlan/kahlan\n```\n\nNote:\nKahlan uses the [Semantic Versioning](http://semver.org/) and maintains a `CHANGELOG` to help you easily understand what's happening.\n\n### via Git clone\n\n```\ngit clone git://github.com/kahlan/kahlan.git\ncd kahlan\ncomposer install\nbin/kahlan              # to run specs or,\nbin/kahlan --coverage=4 # to run specs with coverage info for namespaces, classes \u0026 methods (require xdebug)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkahlan%2Fkahlan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkahlan%2Fkahlan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkahlan%2Fkahlan/lists"}