3 namespace Friendica\Test\Util;
6 use Friendica\BaseObject;
7 use Friendica\Core\Config\ConfigCache;
8 use Friendica\Render\FriendicaSmartyEngine;
9 use Mockery\MockInterface;
10 use org\bovigo\vfs\vfsStreamDirectory;
13 * Trait to Mock the global App instance
20 * @var MockInterface|App The mocked Friendica\App
27 * @param vfsStreamDirectory $root The root directory
28 * @param MockInterface|ConfigCache $config The config cache
30 public function mockApp($root, $config)
32 $this->mockConfigGet('system', 'theme', 'testtheme');
34 // Mocking App and most used functions
35 $this->app = \Mockery::mock(App::class);
37 ->shouldReceive('getBasePath')
38 ->andReturn($root->url());
41 ->shouldReceive('get')
42 ->with('database', 'hostname')
43 ->andReturn(getenv('MYSQL_HOST'));
45 ->shouldReceive('get')
46 ->with('database', 'username')
47 ->andReturn(getenv('MYSQL_USERNAME'));
49 ->shouldReceive('get')
50 ->with('database', 'password')
51 ->andReturn(getenv('MYSQL_PASSWORD'));
53 ->shouldReceive('get')
54 ->with('database', 'database')
55 ->andReturn(getenv('MYSQL_DATABASE'));
57 ->shouldReceive('getConfig')
61 ->shouldReceive('getTemplateEngine')
62 ->andReturn(new FriendicaSmartyEngine());
64 ->shouldReceive('getCurrentTheme')
65 ->andReturn('Smarty3');
67 ->shouldReceive('saveTimestamp')
70 ->shouldReceive('getBaseUrl')
71 ->andReturn('http://friendica.local');
73 BaseObject::setApp($this->app);