Esempio n. 1
0
 /**
  * The JIT find file patcher.
  *
  * @param  object $loader The autloader instance.
  * @param  string $class  The fully-namespaced class name.
  * @param  string $file   The correponding finded file path.
  * @return string         The patched file path.
  */
 public function findFile($loader, $class, $file)
 {
     if ($file) {
         return $file;
     }
     $allowed = empty($this->_namespaces);
     foreach ($this->_namespaces as $ns) {
         if (strpos($class, $ns) === 0) {
             $allowed = true;
         }
     }
     if (!DummyClassPlugin::enabled() || !$allowed) {
         return $file;
     }
     $classpath = strtr($class, '\\', DS);
     return $loader->cache('/dummies/' . $classpath . '.php', static::generate(compact('class')));
 }
Esempio n. 2
0
        });
        it("throws an IncompleteException when creating an unexisting class", function () {
            $closure = function () {
                $mock = new Abcde();
                $mock->helloWorld();
            };
            expect($closure)->toThrow(new IncompleteException());
        });
        it("allows magic call static on live mock", function () {
            expect(function () {
                Abcde::helloWorld();
            })->toThrow(new IncompleteException());
        });
    });
    describe("::enable()", function () {
        it("enables dummies", function () {
            DummyClass::disable();
            expect(DummyClass::enabled())->toBe(false);
            DummyClass::enable();
            expect(DummyClass::enabled())->toBe(true);
        });
    });
    describe("::disable()", function () {
        it("disables dummies", function () {
            DummyClass::enable();
            expect(DummyClass::enabled())->toBe(true);
            DummyClass::disable();
            expect(DummyClass::enabled())->toBe(false);
        });
    });
});