1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Micro framework package. |
7
|
|
|
* |
8
|
|
|
* (c) Stanislau Komar <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Micro\Plugin\Twig\Test\Unit; |
15
|
|
|
|
16
|
|
|
use Micro\Plugin\Twig\Business\Render\TwigRendererFactoryInterface; |
17
|
|
|
use Micro\Plugin\Twig\Business\Render\TwigRendererInterface; |
18
|
|
|
use Micro\Plugin\Twig\TwigFacade; |
19
|
|
|
use Micro\Plugin\Twig\TwigFacadeInterface; |
20
|
|
|
use PHPUnit\Framework\TestCase; |
21
|
|
|
|
22
|
|
|
class TwigFacadeTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
private TwigFacadeInterface $twigFacade; |
25
|
|
|
|
26
|
|
|
private TwigRendererFactoryInterface $twigRendererFactory; |
27
|
|
|
|
28
|
|
|
protected function setUp(): void |
29
|
|
|
{ |
30
|
|
|
$this->twigRendererFactory = $this->createMock(TwigRendererFactoryInterface::class); |
31
|
|
|
|
32
|
|
|
$this->twigFacade = new TwigFacade( |
33
|
|
|
$this->twigRendererFactory, |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testRender() |
38
|
|
|
{ |
39
|
|
|
$tplName = 'template.twig'; |
40
|
|
|
$exceptedResult = 'template-result'; |
41
|
|
|
$arguments = [ |
42
|
|
|
'a' => 'a', |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
$renderer = $this->createMock(TwigRendererInterface::class); |
46
|
|
|
$renderer |
47
|
|
|
->expects($this->once()) |
48
|
|
|
->method('render') |
49
|
|
|
->with($tplName, $arguments) |
50
|
|
|
->willReturn($exceptedResult); |
51
|
|
|
|
52
|
|
|
$this->twigRendererFactory |
53
|
|
|
->expects($this->once()) |
|
|
|
|
54
|
|
|
->method('create') |
55
|
|
|
->willReturn($renderer); |
56
|
|
|
|
57
|
|
|
$this->assertEquals($exceptedResult, |
58
|
|
|
$this->twigFacade->render($tplName, $arguments) |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.