Support for ::fake() calls

This commit is contained in:
Chris Morrell
2017-10-13 11:41:30 -04:00
parent 28f0ac3781
commit d45b02efb1
+25
View File
@@ -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
*/