diff --git a/src/Alias.php b/src/Alias.php index 4902f80..cd0e852 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -53,6 +53,7 @@ class Alias } $this->addClass($this->root); + $this->detectFake(); $this->detectNamespace(); $this->detectClassType(); $this->detectExtendsNamespace(); @@ -167,6 +168,30 @@ class Alias return $this->methods; } + /** + * Detect class returned by ::fake() + */ + protected function detectFake() + { + $facade = $this->facade; + + if (!method_exists($facade, 'fake')) { + return; + } + + $real = $facade::getFacadeRoot(); + + try { + $facade::fake(); + $fake = $facade::getFacadeRoot(); + if ($fake !== $real) { + $this->addClass(get_class($fake)); + } + } finally { + $facade::swap($real); + } + } + /** * Detect the namespace */