Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataTest.php
Go to the documentation of this file.
1 <?php
7 
8 class DataTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_helper;
14 
19 
20  protected function setUp()
21  {
22  $this->_frontResolverMock = $this->createMock(\Magento\Backend\App\Area\FrontNameResolver::class);
23  $this->_helper = new \Magento\Backend\Helper\Data(
24  $this->createMock(\Magento\Framework\App\Helper\Context::class),
25  $this->createMock(\Magento\Framework\App\Route\Config::class),
26  $this->createMock(\Magento\Framework\Locale\ResolverInterface::class),
27  $this->createMock(\Magento\Backend\Model\Url::class),
28  $this->createMock(\Magento\Backend\Model\Auth::class),
29  $this->_frontResolverMock,
30  $this->createMock(\Magento\Framework\Math\Random::class),
31  $this->createMock(\Magento\Framework\App\RequestInterface::class)
32  );
33  }
34 
36  {
37  $this->_frontResolverMock->expects(
38  $this->once()
39  )->method(
40  'getFrontName'
41  )->will(
42  $this->returnValue('custom_backend')
43  );
44 
45  $this->assertEquals('custom_backend', $this->_helper->getAreaFrontName());
46  }
47 
54  public function testPrepareFilterStringValues(array $inputString, array $expected)
55  {
56  $inputString = base64_encode(http_build_query($inputString));
57 
58  $actual = $this->_helper->prepareFilterString($inputString);
59 
60  $this->assertEquals($expected, $actual);
61  }
62 
67  {
68  return [
69  'both_spaces_value' => [
70  ['field' => ' value '],
71  ['field' => 'value'],
72  ]
73  ];
74  }
75 }
testPrepareFilterStringValues(array $inputString, array $expected)
Definition: DataTest.php:54