Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SortbyTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class SortbyTest extends \PHPUnit\Framework\TestCase
11 {
15  private $model;
16 
17  public function testGetAllOptions()
18  {
19  $validResult = [['label' => __('Position'), 'value' => 'position'], ['label' => __('fl'), 'value' => 'fc']];
20  $this->assertEquals($validResult, $this->model->getAllOptions());
21  }
22 
23  protected function setUp()
24  {
25  $helper = new ObjectManager($this);
26  $this->model = $helper->getObject(
27  \Magento\Catalog\Model\Category\Attribute\Source\Sortby::class,
28  [
29  'catalogConfig' => $this->getMockedConfig()
30  ]
31  );
32  }
33 
37  private function getMockedConfig()
38  {
39  $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Config::class);
40  $mockBuilder->disableOriginalConstructor();
41  $mock = $mockBuilder->getMock();
42 
43  $mock->expects($this->any())
44  ->method('getAttributesUsedForSortBy')
45  ->will($this->returnValue([['frontend_label' => 'fl', 'attribute_code' => 'fc']]));
46 
47  return $mock;
48  }
49 }
$helper
Definition: iframe.phtml:13
__()
Definition: __.php:13