$interceptor = Interceptor::patch(['cachePath' => $this->cachePath]); $new = new Interceptor(['originalLoader' => $interceptor->originalLoader(), 'cachePath' => $this->cachePath]); Interceptor::load($new); expect(Interceptor::instance())->toBe($new); expect(Interceptor::instance())->not->toBe($interceptor); }); }); describe("::instance()", function () { it("returns the interceptor autoloader", function () { $interceptor = Interceptor::patch(['cachePath' => $this->cachePath]); expect($interceptor)->toBeAnInstanceOf("Lead\\Jit\\Interceptor"); }); }); describe("::composer()", function () { it("returns the composer autoloader", function () { $composer = Interceptor::composer()[0]; expect($composer)->toBeAnInstanceOf("Composer\\Autoload\\ClassLoader"); }); }); describe("->__construct()", function () { it("clear caches if `'clearCache'` is `true`", function () { touch($this->cachePath . DS . 'CachedFile.php'); $this->interceptor = Interceptor::patch(['cachePath' => $this->cachePath, 'clearCache' => true]); expect(file_exists($this->cachePath . DS . 'CachedFile.php'))->toBe(false); }); it("initializes watched files if passed to the constructor", function () { $this->temp = Dir::tempnam(null, 'cache'); touch($this->temp . DS . 'watched1.php'); touch($this->temp . DS . 'watched2.php'); $watched = [$this->temp . DS . 'watched1.php', $this->temp . DS . 'watched2.php']; $this->interceptor = Interceptor::patch(['cachePath' => $this->cachePath, 'watch' => $watched]);