Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Translate\InlineTest Class Reference
Inheritance diagram for Translate\InlineTest:

Public Member Functions

 testIsAllowed ()
 
 testProcessResponseBody ($originalText, $expectedText)
 
 processResponseBodyDataProvider ()
 

Static Public Member Functions

static setUpBeforeClass ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_model
 
 $_storeId = 'default'
 
 $state
 

Detailed Description

Definition at line 8 of file InlineTest.php.

Member Function Documentation

◆ processResponseBodyDataProvider()

processResponseBodyDataProvider ( )
Returns
array

Definition at line 114 of file InlineTest.php.

115  {
116  $originalText = file_get_contents(__DIR__ . '/_files/_inline_page_original.html');
117  $expectedText = file_get_contents(__DIR__ . '/_files/_inline_page_expected.html');
118 
120  \Magento\Framework\View\DesignInterface::class
121  )->getDesignTheme()->getPackageCode();
122  $expectedText = str_replace('{{design_package}}', $package, $expectedText);
123  return [
124  'plain text' => ['text with no translations and tags', 'text with no translations and tags'],
125  'html string' => [$originalText, $expectedText],
126  'html array' => [[$originalText], [$expectedText]]
127  ];
128  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ setUp()

setUp ( )
protected

Definition at line 36 of file InlineTest.php.

37  {
39  \Magento\Framework\Translate\Inline::class
40  );
42  \Magento\Framework\Translate\Inline\StateInterface::class
43  );
44  /* Called getConfig as workaround for setConfig bug */
46  \Magento\Store\Model\StoreManagerInterface::class
47  )->getStore(
48  $this->_storeId
49  )->getConfig(
50  'dev/translate_inline/active'
51  );
53  \Magento\Framework\App\Config\MutableScopeConfigInterface::class
54  )->setValue(
55  'dev/translate_inline/active',
56  true,
57  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
58  $this->_storeId
59  );
60  }

◆ setUpBeforeClass()

static setUpBeforeClass ( )
static

Definition at line 25 of file InlineTest.php.

26  {
28  ->setAreaCode('frontend');
30  \Magento\Framework\View\DesignInterface::class
31  )->setDesignTheme(
32  'Magento/blank'
33  );
34  }

◆ testIsAllowed()

testIsAllowed ( )

Definition at line 62 of file InlineTest.php.

63  {
64  $this->assertTrue($this->_model->isAllowed());
65  $this->assertTrue($this->_model->isAllowed($this->_storeId));
66  $this->assertTrue(
67  $this->_model->isAllowed(
68  \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
69  \Magento\Store\Model\StoreManagerInterface::class
70  )->getStore(
71  $this->_storeId
72  )
73  )
74  );
75  $this->state->suspend();
76  $this->assertFalse($this->_model->isAllowed());
77  $this->assertFalse($this->_model->isAllowed($this->_storeId));
78  $this->assertFalse(
79  $this->_model->isAllowed(
80  \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
81  \Magento\Store\Model\StoreManagerInterface::class
82  )->getStore(
83  $this->_storeId
84  )
85  )
86  );
87  }

◆ testProcessResponseBody()

testProcessResponseBody (   $originalText,
  $expectedText 
)
Parameters
string$originalText
string$expectedText@dataProvider processResponseBodyDataProvider

Definition at line 94 of file InlineTest.php.

95  {
96  $actualText = $originalText;
97  $this->_model->processResponseBody($actualText, false);
98  $this->markTestIncomplete('Bug MAGE-2494');
99 
100  $expected = new \DOMDocument();
101  $expected->preserveWhiteSpace = false;
102  $expected->loadHTML($expectedText);
103 
104  $actual = new \DOMDocument();
105  $actual->preserveWhiteSpace = false;
106  $actual->loadHTML($actualText);
107 
108  $this->assertEquals($expected, $actual);
109  }

Field Documentation

◆ $_model

$_model
protected

Definition at line 13 of file InlineTest.php.

◆ $_storeId

$_storeId = 'default'
protected

Definition at line 18 of file InlineTest.php.

◆ $state

$state
protected

Definition at line 23 of file InlineTest.php.


The documentation for this class was generated from the following file: