|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\PageBuilder\Test\Unit\Plugin\Filter; |
| 9 | + |
| 10 | +use Magento\PageBuilder\Model\Filter\Template as TemplateFilter; |
| 11 | +use Magento\Framework\Filter\Template as FrameworkTemplateFilter; |
| 12 | +use Magento\PageBuilder\Plugin\Filter\TemplatePlugin; |
| 13 | +use PHPUnit\Framework\MockObject\MockObject; |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | + |
| 16 | +/** |
| 17 | + * Test for page builder template filter plugin |
| 18 | + */ |
| 19 | +class TemplatePluginTest extends TestCase |
| 20 | +{ |
| 21 | + /** |
| 22 | + * @var FrameworkTemplateFilter|MockObject |
| 23 | + */ |
| 24 | + private $frameworkTemplateFilter; |
| 25 | + |
| 26 | + /** |
| 27 | + * @var TemplateFilter|MockObject |
| 28 | + */ |
| 29 | + private $templateFilter; |
| 30 | + |
| 31 | + /** |
| 32 | + * @var TemplatePlugin |
| 33 | + */ |
| 34 | + private $templatePlugin; |
| 35 | + |
| 36 | + /** |
| 37 | + * @inheritDoc |
| 38 | + */ |
| 39 | + protected function setUp(): void |
| 40 | + { |
| 41 | + parent::setUp(); |
| 42 | + $this->frameworkTemplateFilter = $this->createMock(FrameworkTemplateFilter::class); |
| 43 | + $this->templateFilter = $this->createMock(TemplateFilter::class); |
| 44 | + $this->templatePlugin = new TemplatePlugin($this->templateFilter); |
| 45 | + } |
| 46 | + |
| 47 | + public function testAfterFilter(): void |
| 48 | + { |
| 49 | + $result = null; |
| 50 | + $this->templateFilter->expects($this->once()) |
| 51 | + ->method('filter') |
| 52 | + ->with('') |
| 53 | + ->willReturn(''); |
| 54 | + $this->assertSame('', $this->templatePlugin->afterFilter($this->frameworkTemplateFilter, $result)); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @return array |
| 59 | + */ |
| 60 | + public function afterLoginDataProvider(): array |
| 61 | + { |
| 62 | + return [ |
| 63 | + [false], |
| 64 | + [true], |
| 65 | + ]; |
| 66 | + } |
| 67 | +} |
0 commit comments