]> git.mxchange.org Git - friendica.git/blob - tests/Util/RendererMockTrait.php
BBCode - fixed syntax error
[friendica.git] / tests / Util / RendererMockTrait.php
1 <?php
2 /**
3  * Created by PhpStorm.
4  * User: philipp
5  * Date: 01.11.18
6  * Time: 10:08
7  */
8
9 namespace Friendica\Test\Util;
10
11
12 use Mockery\MockInterface;
13
14 trait RendererMockTrait
15 {
16         /**
17          * @var MockInterface The Interface for mocking a renderer
18          */
19         private $rendererMock;
20
21         /**
22          * Mocking the method 'Renderer::getMarkupTemplate()'
23          *
24          * @param string $templateName The name of the template which should get
25          * @param string $return the return value of the mock (should be defined to have it later for followUp use)
26          * @param null|int $times How often the method will get used
27          */
28         public function mockGetMarkupTemplate($templateName, $return = '', $times = null)
29         {
30                 if (!isset($this->rendererMock)) {
31                         $this->rendererMock = \Mockery::mock('alias:Friendica\Core\Renderer');
32                 }
33
34                 $this->rendererMock
35                         ->shouldReceive('getMarkupTemplate')
36                         ->with($templateName)
37                         ->times($times)
38                         ->andReturn($return);
39         }
40
41         /**
42          * Mocking the method 'Renderer::replaceMacros()'
43          *
44          * @param string $template The template to use (normally, it is the mock result of 'mockGetMarkupTemplate()'
45          * @param array $args The arguments to pass to the macro
46          * @param string $return the return value of the mock
47          * @param null|int $times How often the method will get used
48          */
49         public function mockReplaceMacros($template, $args = [], $return = '', $times = null)
50         {
51                 if (!isset($this->rendererMock)) {
52                         $this->rendererMock = \Mockery::mock('alias:Friendica\Core\Renderer');
53                 }
54
55                 $this->rendererMock
56                         ->shouldReceive('replaceMacros')
57                         ->with($template, $args)
58                         ->times($times)
59                         ->andReturn($return);
60         }
61 }