Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AlertsTest.php
Go to the documentation of this file.
1 <?php
7 
8 class AlertsTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $alerts;
14 
18  protected $scopeConfigMock;
19 
20  protected function setUp()
21  {
22  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
23  $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
24 
25  $this->alerts = $helper->getObject(
26  \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts::class,
27  ['scopeConfig' => $this->scopeConfigMock]
28  );
29  }
30 
38  public function testCanShowTab($priceAllow, $stockAllow, $canShowTab)
39  {
40  $valueMap = [
41  [
42  'catalog/productalert/allow_price',
44  null,
45  $priceAllow,
46  ],
47  [
48  'catalog/productalert/allow_stock',
50  null,
51  $stockAllow
52  ],
53  ];
54  $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValueMap($valueMap));
55  $this->assertEquals($canShowTab, $this->alerts->canShowTab());
56  }
57 
61  public function canShowTabDataProvider()
62  {
63  return [
64  'alert_price_and_stock_allow' => [true, true, true],
65  'alert_price_is_allowed_and_stock_is_unallowed' => [true, false, true],
66  'alert_price_is_unallowed_and_stock_is_allowed' => [false, true, true],
67  'alert_price_is_unallowed_and_stock_is_unallowed' => [false, false, false]
68  ];
69  }
70 }
$helper
Definition: iframe.phtml:13