3 namespace Friendica\Test\Util;
5 use Friendica\Core\Renderer;
6 use Mockery\MockInterface;
8 trait RendererMockTrait
11 * @var MockInterface The Interface for mocking a renderer
13 private $rendererMock;
16 * Mocking the method 'Renderer::getMarkupTemplate()'
18 * @param string $templateName The name of the template which should get
19 * @param string $return the return value of the mock (should be defined to have it later for followUp use)
20 * @param null|int $times How often the method will get used
22 public function mockGetMarkupTemplate($templateName, $return = '', $times = null)
24 if (!isset($this->rendererMock)) {
25 $this->rendererMock = \Mockery::mock('alias:' . Renderer::class);
29 ->shouldReceive('getMarkupTemplate')
36 * Mocking the method 'Renderer::replaceMacros()'
38 * @param string $template The template to use (normally, it is the mock result of 'mockGetMarkupTemplate()'
39 * @param array|\Closure|null $args The arguments to pass to the macro
40 * @param string $return the return value of the mock
41 * @param null|int $times How often the method will get used
43 public function mockReplaceMacros($template, $args = null, $return = '', $times = null)
45 if (!isset($this->rendererMock)) {
46 $this->rendererMock = \Mockery::mock('alias:' . Renderer::class);
54 ->shouldReceive('replaceMacros')
55 ->with($template, $args)