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 // simply returning the input when using L10n::t()
31 $l10nMock = \Mockery::mock('alias:Friendica\Core\L10n');
32 $l10nMock->shouldReceive('t')
33 ->andReturnUsing(function ($arg) { return $arg; });
35 $this->mockConfigGet('system', 'theme', 'testtheme');
37 // Mocking App and most used functions
38 $this->app = \Mockery::mock(App::class);
40 ->shouldReceive('getBasePath')
41 ->andReturn($root->url());
44 ->shouldReceive('getConfigValue')
45 ->with('database', 'hostname')
46 ->andReturn(getenv('MYSQL_HOST'));
48 ->shouldReceive('getConfigValue')
49 ->with('database', 'username')
50 ->andReturn(getenv('MYSQL_USERNAME'));
52 ->shouldReceive('getConfigValue')
53 ->with('database', 'password')
54 ->andReturn(getenv('MYSQL_PASSWORD'));
56 ->shouldReceive('getConfigValue')
57 ->with('database', 'database')
58 ->andReturn(getenv('MYSQL_DATABASE'));
60 ->shouldReceive('getTemplateEngine')
61 ->andReturn(new FriendicaSmartyEngine());
63 ->shouldReceive('getCurrentTheme')
64 ->andReturn('Smarty3');
66 ->shouldReceive('getTemplateLeftDelimiter')
70 ->shouldReceive('getTemplateRightDelimiter')
74 ->shouldReceive('saveTimestamp')
77 ->shouldReceive('getBaseUrl')
78 ->andReturn('http://friendica.local');
81 // Necessary for macro engine with template files
82 $themeMock = \Mockery::mock('alias:Friendica\Core\Theme');
84 ->shouldReceive('install')
88 BaseObject::setApp($this->app);