Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AdapterTest.php
Go to the documentation of this file.
1 <?php
7 
8 class AdapterTest extends \PHPUnit\Framework\TestCase
9 {
18  public function testTranslate($method, $strToTranslate, $translatedStr)
19  {
20  $translatorMock = $this->getMockBuilder('stdClass')->setMethods(['translate'])->getMock();
21  $translatorMock->expects(
22  $this->once()
23  )->method(
24  'translate'
25  )->with(
26  $strToTranslate
27  )->will(
28  $this->returnValue($translatedStr)
29  );
30  $translator = new \Magento\Framework\Translate\Adapter(
31  ['translator' => [$translatorMock, 'translate']]
32  );
33 
34  $this->assertEquals($translatedStr, $translator->{$method}($strToTranslate));
35  }
36 
40  public function translateDataProvider()
41  {
42  return [['translate', 'Translate me!', 'Translated string']];
43  }
44 
48  public function testTranslateNoProxy()
49  {
50  $translator = new \Magento\Framework\Translate\Adapter();
51  $this->assertEquals('test string', $translator->translate('test string'));
52  }
53 
57  public function testUnderscoresTranslation()
58  {
59  $this->markTestIncomplete('MAGETWO-1012: i18n Improvements - Localization/Translations');
60  }
61 }
$method
Definition: info.phtml:13
testTranslate($method, $strToTranslate, $translatedStr)
Definition: AdapterTest.php:18