Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
CarrierTest Class Reference
Inheritance diagram for CarrierTest:

Public Member Functions

 testGetOnlineCarrierCodes ($result, $carriers)
 
 getOnlineCarrierCodesDataProvider ()
 
 testGetCarrierConfigValue ()
 
 testIsCountryInEU ()
 

Protected Attributes

 $helper
 
 $scopeConfig
 

Detailed Description

Carrier helper test

Definition at line 11 of file CarrierTest.php.

Member Function Documentation

◆ getOnlineCarrierCodesDataProvider()

getOnlineCarrierCodesDataProvider ( )

Data provider

Returns
array

Definition at line 61 of file CarrierTest.php.

62  {
63  return [
64  [[], ['carrier1' => []]],
65  [[], ['carrier1' => ['is_online' => 0]]],
66  [
67  ['carrier1'],
68  ['carrier1' => ['is_online' => 1], 'carrier2' => ['is_online' => 0]]
69  ]
70  ];
71  }

◆ testGetCarrierConfigValue()

testGetCarrierConfigValue ( )

Definition at line 73 of file CarrierTest.php.

74  {
75  $carrierCode = 'carrier1';
76  $configPath = 'title';
77  $configValue = 'some title';
78  $this->scopeConfig->expects(
79  $this->once()
80  )->method(
81  'getValue'
82  )->with(
83  sprintf('carriers/%s/%s', $carrierCode, $configPath),
84  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
85  )->will(
86  $this->returnValue($configValue)
87  );
88  $this->assertEquals($configValue, $this->helper->getCarrierConfigValue($carrierCode, $configPath));
89  }

◆ testGetOnlineCarrierCodes()

testGetOnlineCarrierCodes (   $result,
  $carriers 
)
Parameters
array$result
array$carriers@dataProvider getOnlineCarrierCodesDataProvider

Definition at line 41 of file CarrierTest.php.

42  {
43  $this->scopeConfig->expects(
44  $this->once()
45  )->method(
46  'getValue'
47  )->with(
48  'carriers',
49  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
50  )->will(
51  $this->returnValue($carriers)
52  );
53  $this->assertEquals($result, $this->helper->getOnlineCarrierCodes());
54  }

◆ testIsCountryInEU()

testIsCountryInEU ( )

Definition at line 91 of file CarrierTest.php.

92  {
93  $this->scopeConfig->expects(
94  $this->exactly(2)
95  )->method(
96  'getValue'
97  )->with(
98  'general/country/eu_countries',
99  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
100  )->will(
101  $this->returnValue("GB")
102  );
103 
104  $this->assertEquals(true, $this->helper->isCountryInEU("GB"));
105  $this->assertEquals(false, $this->helper->isCountryInEU("US"));
106  }

Field Documentation

◆ $helper

$helper
protected

Definition at line 18 of file CarrierTest.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 23 of file CarrierTest.php.


The documentation for this class was generated from the following file: