Exemplo n.º 1
0
    /**
     * Echoes the help message.
     */
    protected function _help()
    {
        $terminal = $this->_terminal();
        if (!$this->args()->get('no-header')) {
            $terminal->write($terminal->kahlan() . "\n\n");
            $terminal->write($terminal->kahlanBaseline(), 'd');
            $terminal->write("\n\n");
        }
        $help = <<<EOD

Usage: kahlan [options]

Configuration Options:

  --config=<file>                     The PHP configuration file to use (default: `'kahlan-config.php'`).
  --src=<path>                        Paths of source directories (default: `['src']`).
  --spec=<path>                       Paths of specification directories (default: `['spec']`).
  --pattern=<pattern>                 A shell wildcard pattern (default: `'*Spec.php'`).

Reporter Options:

  --reporter=<name>[:<output_file>]   The name of the text reporter to use, the buit-in text reporters
                                      are `'dot'`, `'bar'`, `'json'`, `'tap'` & `'verbose'` (default: `'dot'`).
                                      You can optionally redirect the reporter output to a file by using the
                                      colon syntax (muliple --reporter options are also supported).

Code Coverage Options:

  --coverage=<integer|string>         Generate code coverage report. The value specify the level of
                                      detail for the code coverage report (0-4). If a namespace, class, or
                                      method definition is provided, it will generate a detailed code
                                      coverage of this specific scope (default `''`).
  --clover=<file>                     Export code coverage report into a Clover XML format.
  --istanbul=<file>                   Export code coverage report into an istanbul compatible JSON format.
  --lcov=<file>                       Export code coverage report into a lcov compatible text format.

Test Execution Options:

  --ff=<integer>                      Fast fail option. `0` mean unlimited (default: `0`).
  --no-colors=<boolean>               To turn off colors. (default: `false`).
  --no-header=<boolean>               To turn off header. (default: `false`).
  --include=<string>                  Paths to include for patching. (default: `['*']`).
  --exclude=<string>                  Paths to exclude from patching. (default: `[]`).
  --persistent=<boolean>              Cache patched files (default: `true`).
  --cc=<boolean>                      Clear cache before spec run. (default: `false`).
  --autoclear                         Classes to autoclear after each spec (default: [
                                          `'Kahlan\\Plugin\\Monkey'`,
                                          `'Kahlan\\Plugin\\Call'`,
                                          `'Kahlan\\Plugin\\Stub'`,
                                          `'Kahlan\\Plugin\\Quit'`
                                      ])

Miscellaneous Options:

  --help                 Prints this usage information.
  --version              Prints Kahlan version

Note: The `[]` notation in default values mean that the related option can accepts an array of values.
To add additionnal values, just repeat the same option many times in the command line.


EOD;
        $terminal->write($help);
        QuitStatement::quit();
    }
Exemplo n.º 2
0
     */
    afterAll(function () {
        Interceptor::load($this->previous);
    });
    describe("::enable()", function () {
        it("enables quit statements", function () {
            Quit::disable();
            expect(Quit::enabled())->toBe(false);
            Quit::enable();
            expect(Quit::enabled())->toBe(true);
        });
    });
    describe("::disable()", function () {
        it("disables quit statements", function () {
            Quit::enable();
            expect(Quit::enabled())->toBe(true);
            Quit::disable();
            expect(Quit::enabled())->toBe(false);
        });
    });
    describe("::disable()", function () {
        it("throws an exception when an exit statement occurs if not allowed", function () {
            Quit::disable();
            $closure = function () {
                $foo = new Foo();
                $foo->exitStatement(-1);
            };
            expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));
        });
    });
});
Exemplo n.º 3
0
 public function dieStatement()
 {
     \kahlan\plugin\Quit::quit();
 }