Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ protected function detectFake()
if ($fake !== $real) {
$this->addClass(get_class($fake));
}
} catch (Throwable $throwable) {
// Ignore error
} finally {
$facade::swap($real);
}
Expand Down
39 changes: 39 additions & 0 deletions tests/AliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Facade;

/**
* @internal
Expand Down Expand Up @@ -66,6 +67,22 @@ function () {
$this->assertNotNull($this->getAliasMacro($alias, EloquentBuilder::class, $macro));
}

/**
* @covers ::detectFake
*/
public function testNoExceptionOnRequiredFakeParameters(): void
{
// Mock
$alias = new AliasMock();

// Prepare
$alias->setFacade(MockFacade::class);
$this->expectNotToPerformAssertions();

// Test
$alias->detectFake();
}

/**
* @covers ::detectTemplateNames
*/
Expand Down Expand Up @@ -118,4 +135,26 @@ public function detectMethods()
{
parent::detectMethods();
}

public function detectFake()
{
parent::detectFake();
}

public function setFacade(string $facade)
{
$this->facade = $facade;
}
}

class MockFacade extends Facade
{
protected static function getFacadeAccessor()
{
return '';
}

public static function fake(string $test1, $test2 = null)
{
}
}