3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\Util;
24 use Friendica\Core\Renderer;
25 use Mockery\MockInterface;
27 trait RendererMockTrait
30 * @var MockInterface The Interface for mocking a renderer
32 private $rendererMock;
35 * Mocking the method 'Renderer::getMarkupTemplate()'
37 * @param string $templateName The name of the template which should get
38 * @param string $return the return value of the mock (should be defined to have it later for followUp use)
39 * @param null|int $times How often the method will get used
41 public function mockGetMarkupTemplate(string $templateName, string $return = '', int $times = null)
43 if (!isset($this->rendererMock)) {
44 $this->rendererMock = \Mockery::mock('alias:' . Renderer::class);
48 ->shouldReceive('getMarkupTemplate')
55 * Mocking the method 'Renderer::replaceMacros()'
57 * @param string $template The template to use (normally, it is the mock result of 'mockGetMarkupTemplate()'
58 * @param array|\Closure|null $args The arguments to pass to the macro
59 * @param string $return the return value of the mock
60 * @param null|int $times How often the method will get used
62 public function mockReplaceMacros(string $template, $args = null, string $return = '', int $times = null)
64 if (!isset($this->rendererMock)) {
65 $this->rendererMock = \Mockery::mock('alias:' . Renderer::class);
73 ->shouldReceive('replaceMacros')
74 ->with($template, $args)