-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added return type for model ast visitors. (#6544)
- Loading branch information
1 parent
e1bd657
commit 096913c
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace HyperfTest\Scout\Stub; | ||
|
||
use Hyperf\Context\ApplicationContext; | ||
use Hyperf\Database\Model\Register; | ||
use Hyperf\Scout\ModelObserver; | ||
use Mockery; | ||
use Psr\Container\ContainerInterface; | ||
use ReflectionClass; | ||
|
||
class ContainerStub | ||
{ | ||
public static function unsetContainer(): void | ||
{ | ||
$ref = new ReflectionClass(ApplicationContext::class); | ||
$c = $ref->getProperty('container'); | ||
$c->setValue(null); | ||
} | ||
|
||
public static function mockContainer() | ||
{ | ||
$container = Mockery::mock(ContainerInterface::class); | ||
$container->shouldReceive('get')->with(ModelObserver::class)->andReturn(new ModelObserver()); | ||
|
||
ApplicationContext::setContainer($container); | ||
|
||
Register::unsetEventDispatcher(); | ||
} | ||
} |