File tree Expand file tree Collapse file tree 5 files changed +31
-12
lines changed
Test/Unit/Model/ResourceModel/Quote/Item Expand file tree Collapse file tree 5 files changed +31
-12
lines changed Original file line number Diff line number Diff line change 11
11
12
12
/**
13
13
* Class Config
14
+ * Toggles Inventory check via Config option
14
15
* @package Magento\Quote\Model
15
16
*/
16
17
class Config
17
18
{
18
- const XML_PATH_DISABLED = 'cataloginventory/item_options/disabled ' ;
19
+ const XML_PATH_INVENTORY_CHECK_ENABLED = 'cataloginventory/options/enable_inventory_check ' ;
19
20
20
21
/** @var ScopeConfigInterface */
21
22
private $ config ;
@@ -33,8 +34,8 @@ public function __construct(ScopeConfigInterface $config)
33
34
* Check if Inventory check is disabled
34
35
* @return bool
35
36
*/
36
- public function isDisabled (): bool
37
+ public function isEnabled (): bool
37
38
{
38
- return (bool )$ this ->config ->getValue (self ::XML_PATH_DISABLED );
39
+ return (bool )$ this ->config ->getValue (self ::XML_PATH_INVENTORY_CHECK_ENABLED );
39
40
}
40
41
}
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ protected function _assignProducts(): self
291
291
}
292
292
if (!$ item ->isDeleted ()) {
293
293
$ item ->setQtyOptions ($ qtyOptions )->setProduct ($ product );
294
- if (! $ this ->config ->isDisabled ()) {
294
+ if ($ this ->config ->isEnabled ()) {
295
295
$ item ->checkData ();
296
296
}
297
297
}
Original file line number Diff line number Diff line change @@ -33,12 +33,30 @@ protected function setUp(): void
33
33
$ this ->config = new Config ($ this ->configMock );
34
34
}
35
35
36
+ /**
37
+ * @return void
38
+ */
39
+ public function testIsEnabled ()
40
+ {
41
+ $ this ->assertEquals (true , $ this ->config ->isEnabled ());
42
+ }
43
+
36
44
/**
37
45
* @return void
38
46
*/
39
47
public function testIsDisabled ()
40
48
{
41
- $ this ->configMock ->expects ($ this ->once ())->method ('getValue ' );
42
- $ this ->config ->isDisabled ();
49
+ $ this ->setUpForDisabled ();
50
+ $ this ->assertEquals (false , $ this ->config ->isEnabled ());
51
+ }
52
+
53
+ /**
54
+ * @return void
55
+ */
56
+ private function setUpForDisabled ()
57
+ {
58
+ $ this ->configMock = $ this ->getMockForAbstractClass (ScopeConfigInterface::class);
59
+ $ this ->configMock ->method ('getValue ' )->willReturn ('0 ' );
60
+ $ this ->config = new Config ($ this ->configMock );
43
61
}
44
62
}
Original file line number Diff line number Diff line change 9
9
<system >
10
10
<section id =" cataloginventory" >
11
11
<tab >catalog</tab >
12
- <group id =" item_options " translate = " label comment " type = " text " sortOrder = " 10 " showInDefault = " 1 " showInWebsite = " 1 " showInStore = " 1 " >
13
- <field id =" disabled " translate =" label" type =" select" sortOrder =" 15 " showInDefault =" 1" canRestore =" 1" >
14
- <label >Inventory check is Disabled </label >
12
+ <group id =" options " >
13
+ <field id =" enable_inventory_check " translate =" label" type =" select" sortOrder =" 60 " showInDefault =" 1" canRestore =" 1" >
14
+ <label > Enable Inventory Check On Cart Load </label >
15
15
<source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
16
16
</field >
17
17
</group >
Original file line number Diff line number Diff line change 8
8
<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:module:Magento_Store:etc/config.xsd" >
9
9
<default >
10
10
<cataloginventory >
11
- <item_options >
12
- <disabled >0</disabled >
13
- </item_options >
11
+ <options >
12
+ <enable_inventory_check >0</enable_inventory_check >
13
+ </options >
14
14
</cataloginventory >
15
15
</default >
16
16
</config >
You can’t perform that action at this time.
0 commit comments