Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractAdapterTest.php
Go to the documentation of this file.
1 <?php
7 
8 class AbstractAdapterTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_adapterMock;
14 
19 
20  protected function setUp()
21  {
22  $this->_adapterMock = $this->getMockForAbstractClass(
23  \Magento\Setup\Module\I18n\Parser\Adapter\AbstractAdapter::class,
24  [],
25  '',
26  false,
27  true,
28  true,
29  ['_parse']
30  );
31  $this->_adapterReflection = new \ReflectionMethod(
32  \Magento\Setup\Module\I18n\Parser\Adapter\AbstractAdapter::class,
33  '_addPhrase'
34  );
35  $this->_adapterReflection->setAccessible(true);
36  }
37 
38  public function testParse()
39  {
40  $this->_adapterMock->expects($this->once())->method('_parse');
41 
42  $this->_adapterMock->parse('file1');
43  }
44 
45  public function getPhrases()
46  {
47  $this->assertInternalType('array', $this->_adapterMock->getPhrases());
48  }
49 
50  public function testAddPhrase()
51  {
52  $phrase = 'test phrase';
53  $line = 2;
54  $expected = [
55  [
56  'phrase' => $phrase,
57  'file' => null,
58  'line' => $line,
59  'quote' => ''
60  ]
61  ];
62  $this->_adapterReflection->invoke($this->_adapterMock, $phrase, $line);
63  $actual = $this->_adapterMock->getPhrases();
64  $this->assertEquals($expected, $actual);
65 
66  $this->_adapterReflection->invoke($this->_adapterMock, '', '');
67  $actual = $this->_adapterMock->getPhrases();
68  $this->assertEquals($expected, $actual);
69  }
70 }