![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-sales/Test/Unit/Block/Adminhtml/Order/View/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\View; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Sales\Block\Adminhtml\Order\View\History; use Magento\Sales\Helper\Admin; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class HistoryTest extends TestCase { /** * @var Admin|MockObject */ protected $adminHelperMock; /** * @var History */ protected $viewHistory; protected function setUp(): void { $this->adminHelperMock = $this->getMockBuilder(Admin::class) ->disableOriginalConstructor() ->getMock(); $this->viewHistory = (new ObjectManager($this))->getObject( History::class, [ 'adminHelper' => $this->adminHelperMock ] ); } /** * @param string $data * @param string $expected * @param null|array $allowedTags * @dataProvider escapeHtmlDataProvider */ public function testEscapeHtml($data, $expected, $allowedTags = null) { $this->adminHelperMock ->expects($this->any()) ->method('escapeHtmlWithLinks') ->willReturn($expected); $actual = $this->viewHistory->escapeHtml($data, $allowedTags); $this->assertEquals($expected, $actual); } /** * @return array */ public function escapeHtmlDataProvider() { return [ [ '<a>some text in tags</a>', '<a>some text in tags</a>', 'allowedTags' => null ], [ 'Transaction ID: "<a target="_blank" href="https://www.paypal.com/?id=XX123XX">XX123XX</a>"', 'Transaction ID: "<a target="_blank" href="https://www.paypal.com/?id=XX123XX">XX123XX</a>"', 'allowedTags' => ['b', 'br', 'strong', 'i', 'u', 'a'] ], [ '<a>some text in tags</a>', '<a>some text in tags</a>', 'allowedTags' => ['a'] ] ]; } }