<?php
namespace Kahlan\Spec\Suite\Plugin;
use Kahlan\Jit\Interceptor;
use Kahlan\QuitException;
use Kahlan\Plugin\Quit;
use Kahlan\Jit\Patcher\Quit as QuitPatcher;
use Kahlan\Spec\Fixture\Plugin\Quit\Foo;
describe("Quit", function () {
/**
* Save current & reinitialize the Interceptor class.
*/
beforeAll(function () {
$this->previous = Interceptor::instance();
Interceptor::unpatch();
$cachePath = rtrim(sys_get_temp_dir(), DS) . DS . 'kahlan';
$include = ['Kahlan\\Spec\\'];
$interceptor = Interceptor::patch(compact('include', 'cachePath'));
$interceptor->patchers()->add('quit', new QuitPatcher());
});
/**
* Restore Interceptor class.
*/
afterAll(function () {
Interceptor::load($this->previous);
});
describe("::enable()", function () {
it("enables quit statements", function () {
Quit::disable();
expect(Quit::enabled())->toBe(false);