InteractsWithApp.php 880 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace think\tests;
  3. use Mockery as m;
  4. use Mockery\MockInterface;
  5. use think\App;
  6. use think\Config;
  7. use think\Container;
  8. trait InteractsWithApp
  9. {
  10. /** @var App|MockInterface */
  11. protected $app;
  12. /** @var Config|MockInterface */
  13. protected $config;
  14. protected function prepareApp()
  15. {
  16. $this->app = m::mock(App::class)->makePartial();
  17. Container::setInstance($this->app);
  18. $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app);
  19. $this->app->shouldReceive('isDebug')->andReturnTrue();
  20. $this->config = m::mock(Config::class)->makePartial();
  21. $this->config->shouldReceive('get')->with('app.show_error_msg')->andReturnTrue();
  22. $this->app->shouldReceive('get')->with('config')->andReturn($this->config);
  23. $this->app->shouldReceive('runningInConsole')->andReturn(false);
  24. }
  25. }