InlineTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Model\Translate;
  7. /**
  8. * @magentoAppArea adminhtml
  9. */
  10. class InlineTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Framework\Translate\InlineInterface
  14. */
  15. protected $_translateInline;
  16. protected function setUp()
  17. {
  18. $this->_translateInline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  19. \Magento\Framework\Translate\InlineInterface::class
  20. );
  21. }
  22. /**
  23. * @magentoAdminConfigFixture dev/translate_inline/active_admin 1
  24. * @covers \Magento\Framework\Translate\Inline::getAjaxUrl
  25. */
  26. public function testAjaxUrl()
  27. {
  28. $body = '<html><body>some body</body></html>';
  29. /** @var \Magento\Backend\Model\UrlInterface $url */
  30. $url = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\UrlInterface::class);
  31. $url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate');
  32. $this->_translateInline->processResponseBody($body, true);
  33. $expected = str_replace(
  34. [':', '/'],
  35. ['\u003A', '\u002F'],
  36. $url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate')
  37. );
  38. $this->assertContains($expected, $body);
  39. }
  40. }