Skip to content

Commit 8e641cf

Browse files
committed
Merge remote-tracking branch 'origin/MC-40148' into 2.4-develop-sidecar-pr11
2 parents 25b568d + 1746104 commit 8e641cf

File tree

1 file changed

+62
-0
lines changed
  • dev/tests/integration/testsuite/Magento/CatalogInventory/Model/System/Config/Backend

1 file changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogInventory\Model\System\Config\Backend;
9+
10+
use Magento\CatalogInventory\Model\Configuration;
11+
use Magento\Config\Model\Config\BackendFactory;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\ObjectManagerInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Checks that the qty increments config backend model is working correctly
19+
*
20+
* @see \Magento\CatalogInventory\Model\System\Config\Backend\Qtyincrements
21+
*
22+
* @magentoAppArea adminhtml
23+
*/
24+
class QtyincrementsTest extends TestCase
25+
{
26+
/** @var ObjectManagerInterface */
27+
private $objectManager;
28+
29+
/** @var Qtyincrements */
30+
private $qtyIncrements;
31+
32+
/** @var BackendFactory */
33+
private $backendFactory;
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
protected function setUp(): void
39+
{
40+
$this->objectManager = Bootstrap::getObjectManager();
41+
$this->backendFactory = $this->objectManager->get(BackendFactory::class);
42+
$this->qtyIncrements = $this->backendFactory->create(Qtyincrements::class, [
43+
'data' => [
44+
'path' => Configuration::XML_PATH_QTY_INCREMENTS,
45+
],
46+
]);
47+
}
48+
49+
/**
50+
* @return void
51+
*/
52+
public function testAfterSaveWithDecimals(): void
53+
{
54+
$this->expectException(LocalizedException::class);
55+
$this->expectExceptionMessage(
56+
(string)__("Quantity increments can't use decimals. Enter a new increment and try again.")
57+
);
58+
$value = 10.5;
59+
$this->qtyIncrements->setValue((string)$value);
60+
$this->qtyIncrements->beforeSave();
61+
}
62+
}

0 commit comments

Comments
 (0)