示例#1
0
 public function testProcessResponseBodyStringProcessingAttributesCorrectly()
 {
     $testContent = file_get_contents(__DIR__ . '/_files/datatranslate_fixture.html');
     $processedAttributes = ["data-translate=\"[{'shown':'* Required Fields','translated':'* Required Fields'," . "'original':'* Required Fields','location':'Tag attribute (ALT, TITLE, etc.)'}]\"", "data-translate=\"[{'shown':'Email','translated':'Email','original':'Email'," . "'location':'Tag attribute (ALT, TITLE, etc.)'}]\"", "data-translate=\"[{'shown':'Password','translated':'Password','original':'Password'," . "'location':'Tag attribute (ALT, TITLE, etc.)'}]\""];
     $this->translateInlineMock->expects($this->any())->method('getAdditionalHtmlAttribute')->willReturn(null);
     $processedContent = $this->model->processResponseBodyString($testContent);
     foreach ($processedAttributes as $attribute) {
         $this->assertContains($attribute, $processedContent, "data-translate attribute not processed correctly");
     }
 }
示例#2
0
 /**
  * @dataProvider processAjaxPostDataProvider
  */
 public function testProcessAjaxPost($originalText, $translatedText, $isPerStore = null)
 {
     $inputArray = array(array('original' => $originalText, 'custom' => $translatedText));
     if ($isPerStore !== null) {
         $inputArray[0]['perstore'] = $isPerStore;
     }
     $this->_inlineParser->processAjaxPost($inputArray);
     $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Translation\\Model\\String');
     $model->load($originalText);
     try {
         $this->assertEquals($translatedText, $model->getTranslate());
         $model->delete();
     } catch (\Exception $e) {
         $model->delete();
         \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Logger')->logException($e);
     }
 }