Merge pull request #583 from inxilpro/support-fakes

Support for ::fake() calls
This commit is contained in:
Barry vd. Heuvel
2018-05-07 11:22:33 +02:00
committed by GitHub
+25
View File
@@ -59,6 +59,7 @@ class Alias
} }
$this->addClass($this->root); $this->addClass($this->root);
$this->detectFake();
$this->detectNamespace(); $this->detectNamespace();
$this->detectClassType(); $this->detectClassType();
$this->detectExtendsNamespace(); $this->detectExtendsNamespace();
@@ -179,6 +180,30 @@ class Alias
return $this->methods; 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 * Detect the namespace
*/ */