3 namespace Friendica\Test\Util;
6 use Friendica\BaseObject;
7 use Friendica\Render\FriendicaSmartyEngine;
8 use Mockery\MockInterface;
9 use org\bovigo\vfs\vfsStreamDirectory;
12 * Trait to Mock the global App instance
19 * @var MockInterface|App The mocked Friendica\App
26 * @param vfsStreamDirectory $root The root directory
28 public function mockApp($root)
30 $this->mockConfigGet('system', 'theme', 'testtheme');
32 // Mocking App and most used functions
33 $this->app = \Mockery::mock(App::class);
35 ->shouldReceive('getBasePath')
36 ->andReturn($root->url());
39 ->shouldReceive('getConfigValue')
40 ->with('database', 'hostname')
41 ->andReturn(getenv('MYSQL_HOST'));
43 ->shouldReceive('getConfigValue')
44 ->with('database', 'username')
45 ->andReturn(getenv('MYSQL_USERNAME'));
47 ->shouldReceive('getConfigValue')
48 ->with('database', 'password')
49 ->andReturn(getenv('MYSQL_PASSWORD'));
51 ->shouldReceive('getConfigValue')
52 ->with('database', 'database')
53 ->andReturn(getenv('MYSQL_DATABASE'));
55 ->shouldReceive('getTemplateEngine')
56 ->andReturn(new FriendicaSmartyEngine());
58 ->shouldReceive('getCurrentTheme')
59 ->andReturn('Smarty3');
61 ->shouldReceive('saveTimestamp')
64 ->shouldReceive('getBaseUrl')
65 ->andReturn('http://friendica.local');
67 BaseObject::setApp($this->app);