2017 © Pedro Peláez
 

library kahlan-isolator-plugin

Plugin for Kahlan unit-testing framework which allows to extract functions from PHP files.

image

lamp-of-god/kahlan-isolator-plugin

Plugin for Kahlan unit-testing framework which allows to extract functions from PHP files.

  • Monday, October 9, 2017
  • by SeRRgIO323
  • Repository
  • 1 Watchers
  • 0 Stars
  • 347 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 73 % Grown

The README.md

What is it?

This plugin allows to 'require' functions from PHP files and skip other code., (*1)

What for?

If you work with old legacy code, there are some situations when unit-testing is impossible, for example, when file contains not only functions but also side code. This plugin allows you to test isolated functions from files., (*2)

Example of case

For example, you have controller:, (*3)

<?php

if (!authorized()) {
    die('error');
}

do_something();

function to_test() 
{
    return 42;
}

It is impossible to test function to_test. You can't just require file because there is side-code that can break test or can do some unwanted stuff. But if function to_test isolated by itself, it will be good to test it., (*4)

Usage

With this plugin you can test such functions: you just use plugin and require file with it:, (*5)

use Kahlan\Plugin\Isolator;

Isolator::isolate(dirname(__DIR__).'/../controller.php');

describe('to_test()', function() {
    it('returns 42', function() {
        expect(to_test())->toBe(42);
    });
});

After isolation controller file will contain only functions (and use statements) without other code:, (*6)

<?php
function to_test() 
{
    return 42;
}

So now it is testable., (*7)

The Versions

09/10 2017

dev-master

9999999-dev

Plugin for Kahlan unit-testing framework which allows to extract functions from PHP files.

  Sources   Download

MIT

The Requires

 

by SeRRg

tdd testing unit test kahlan

09/10 2017

v0.3.0

0.3.0.0

Plugin for Kahlan unit-testing framework which allows to extract functions from PHP files.

  Sources   Download

MIT

The Requires

 

by SeRRg

tdd testing unit test kahlan

20/09 2017

v0.2.0

0.2.0.0

Plugin for Kahlan unit-testing framework which allows to extract functions from PHP files.

  Sources   Download

MIT

The Requires

 

by SeRRg

tdd testing unit test kahlan

11/09 2017

v0.1.0

0.1.0.0

Plugin for Kahlan unit-testing framework which allows to extract functions from PHP files.

  Sources   Download

MIT

The Requires

 

by SeRRg

tdd testing unit test