Skip to content

Commit

Permalink
Merge bb31219 into 4fad70f
Browse files Browse the repository at this point in the history
  • Loading branch information
jails committed Oct 2, 2016
2 parents 4fad70f + bb31219 commit 87298ab
Show file tree
Hide file tree
Showing 234 changed files with 11,972 additions and 10,952 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@ composer.phar
vendor
codeclimate.json
coveralls.json
clover.xml
23 changes: 15 additions & 8 deletions .travis.yml
@@ -1,30 +1,37 @@
sudo: false
sudo: required
dist: xenial
group: edge
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

matrix:
fast_finish: true
allow_failures:
- php: hhvm

before_script:
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
- composer self-update
- composer install --no-interaction
- if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then echo 'xdebug.enable = On' >> /etc/hhvm/php.ini; fi
#- if [[ $TRAVIS_PHP_VERSION =~ ^7 ]]; then pecl install xdebug; fi
- if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then echo 'hhvm.php7.all = 1' >> /etc/hhvm/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION =~ ^7 ]]; then git clone git://github.com/xdebug/xdebug.git && cd xdebug && phpize && ./configure --enable-xdebug && make && make install && echo "zend_extension = xdebug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini && cd ..; fi

script: bin/kahlan --config=kahlan-config.travis.php --clover=clover.xml
script:
- vendor/bin/phpcs
- bin/kahlan --config=kahlan-config.travis.php --clover=clover.xml

after_success:
- "if [ $(phpenv version-name) = '5.6' ]; then curl -X POST -d @codeclimate.json -H 'Content-Type:application/json' https://codeclimate.com/test_reports --verbose; fi"
- "if [ $(phpenv version-name) = '5.6' ]; then curl -F 'json_file=@coveralls.json' https://coveralls.io/api/v1/jobs --verbose; fi"
- "if [ $(phpenv version-name) = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar; fi"
- "if [ $(phpenv version-name) = '5.6' ]; then php ocular.phar code-coverage:upload --format=php-clover 'clover.xml'; fi"
- "if [ $(phpenv version-name) = '7.0' ]; then curl -X POST -d @codeclimate.json -H 'Content-Type:application/json' https://codeclimate.com/test_reports --verbose; fi"
- "if [ $(phpenv version-name) = '7.0' ]; then curl -F 'json_file=@coveralls.json' https://coveralls.io/api/v1/jobs --verbose; fi"
- "if [ $(phpenv version-name) = '7.0' ]; then wget https://scrutinizer-ci.com/ocular.phar; fi"
- "if [ $(phpenv version-name) = '7.0' ]; then php ocular.phar code-coverage:upload --format=php-clover 'clover.xml'; fi"

env:
global:
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,27 @@

## Last changes

## 3.0.0 (2016-09-01)

* **Add:** Add `allow()` DSL.
* **Add:** Add `toBeCalled()` matcher.
* **Add:** `toReceive` can expect a chain of stubbed methods to be called.
* **Add:** Monkey patching can patch all instances of a class to be a specific instance.
* **Add:** Argument requirements can be applied on a chain of methods using `where()`.
* **Add:** It's now possible to mark specs as pending by adding no expectation inside or mark them as excluded when using the `xit`, `xcontext`, `xdescribe` syntax.
* **Change:** Refactor the reporting to provide more meaningful messages on failure.
* **Bugfix:** Fixes an issue with `toReceive()/toBeCalled` and stubs where past called methods were taken into account.
* **BC break:** `Stub::on()` is now deprecated use `allow()` instead.
* **BC break:** `Monkey::patch()` is now deprecated use `allow()` instead.
* **BC break:** Rename `'params'` option to `'args'` in `Double::instance()`.
* **BC break:** Rename `Stub::create()` to `Double::instance()`.
* **BC break:** Rename `Stub::classname()` to `Double::classname()`.
* **BC break:** Rename `before()` and `after()` to `beforeAll()` and `afterAll()`.
* **BC break:** Rename `Args` to `CommandLine` (i.e. `$this->args()` become `$this->commandLine()` in `kahlan-config.php`)
* **BC break:** Remove `toReceiveNext` matchers in flavor of `->ordered` attribute to be more close to Rspec way.
* **BC break:** Refactor the reporting API.
* **BC break:** Cached files are no more compatible, cached files needs to be purged.

## 2.5.8 (2016-09-29)

* **Bugfix:** Ignore `declare()` statement from coverable statements.
Expand Down
45 changes: 32 additions & 13 deletions README.md
Expand Up @@ -11,13 +11,12 @@

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 embraces the [KISS principle](http://en.wikipedia.org/wiki/KISS_principle) and makes Unit & BDD testing fun again!
**Kahlan allows to stub or monkey patch your code directly like in Ruby or JavaScript without any required PECL-extentions.**

**Killer feature:** Kahlan allows to stub or monkey patch your code directly like in Ruby or JavaScript without any required PECL-extentions.

## Video
## Videos

* <a href="http://vimeo.com/116949820" target="_blank">Warren Seymour presentation at Unified Diff (2015)</a>
* <a href="https://www.grafikart.fr/tutoriels/php/tdd-kahlan-805" target="_blank">Grafikart presentation in French (2016)</a>

## IRC

Expand All @@ -26,42 +25,62 @@ Kahlan embraces the [KISS principle](http://en.wikipedia.org/wiki/KISS_principle

## Documentation

See the whole [documentation here](http://kahlan.readthedocs.org/en/latest) (documentation for Kahlan <= 1.3.0 [can still be found here](docs/deprecated))
See the whole [documentation here](https://kahlan.github.io/docs)

## Requirements

* PHP 5.5+
* Composer
* [Xdebug](http://xdebug.org/) (if you want to perform code coverage analysis)
* [phpdbg](http://php.net/manual/en/debugger-about.php) or [Xdebug](http://xdebug.org/) (required for code coverage analysis only)

## Main Features

* Simple API
* RSpec/JSpec syntax
* Code Coverage metrics ([xdebug](http://xdebug.org) or [phpdbg](http://phpdbg.com/docs) required)
* Handy stubbing system ([mockery](https://github.com/padraic/mockery) or [prophecy](https://github.com/phpspec/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 class/instances
* Check called methods on your classes/instances
* Built-in Reporters (Terminal or HTML reporting through [istanbul](https://gotwarlost.github.io/istanbul/) or [lcov](http://ltp.sourceforge.net/coverage/lcov.php))
* Built-in Exporters (Coveralls, Code Climate, Scrutinizer, Clover)
* Extensible, customizable workflow
* Small code base (~10 times smaller than PHPUnit)

## Syntax

```php
<?php

describe("Example", function() {

it("passes if true === true", function() {
it("makes an expectation", function() {

expect(true)->toBe(true);

});

it("expects methods to be called", function() {

expect($user)->toReceive('save')->with(['validates' => false]);

$user = new User();
$user->validates(['validates' => false]);

});

it("stubs a function", function() {

expect(true)->toBe(true);
allow('time')->toBeCalled()->andReturn(123);
$user = new User();
expect($user->save())->toBe(true)
expect($user->created)->toBe(123);

});

it("passes if false !== true", function() {
it("stubs a class", function() {

expect(false)->not->toBe(true);
allow('PDO')->toReceive('prepare', 'fetchAll')->andReturn([['name' => 'bob']]);
$user = new User();
expect($user->all())->toBe([['name' => 'bob']]);

});

Expand Down
10 changes: 8 additions & 2 deletions composer.json
@@ -1,6 +1,6 @@
{
"name": "kahlan/kahlan",
"description": "Behavior-Driven Development (BDD) library.",
"description": "The PHP Test Framework for Freedom, Truth and Justice.",
"keywords": ["Testing", "Unit Test", "Behavior-Driven Development", "TDD", "BDD", "Monkey Patching", "Stub", "Mock"],
"license": "MIT",
"authors": [
Expand All @@ -11,11 +11,17 @@
"require": {
"php": ">=5.4"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.7"
},
"autoload": {
"psr-4": {
"Kahlan\\": "src/"
},
"files": ["src/init.php"]
"files": [
"src/init.php",
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
44 changes: 0 additions & 44 deletions docs/README.md

This file was deleted.

Binary file removed docs/assets/phpunit_4.4_code_coverage.png
Binary file not shown.
102 changes: 0 additions & 102 deletions docs/config-file.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/deprecated/README.md

This file was deleted.

Binary file removed docs/deprecated/assets/code_coverage.png
Binary file not shown.
Binary file removed docs/deprecated/assets/custom_reporter.png
Binary file not shown.
Binary file removed docs/deprecated/assets/dot_reporter.png
Binary file not shown.
Binary file removed docs/deprecated/assets/phpunit_4.4_code_coverage.png
Binary file not shown.
Binary file removed docs/deprecated/assets/verbose_reporter.png
Binary file not shown.
Binary file removed docs/deprecated/assets/warning.png
Binary file not shown.

0 comments on commit 87298ab

Please sign in to comment.