|
| 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 | +class QtyincrementsTest extends TestCase |
| 21 | +{ |
| 22 | + /** @var ObjectManagerInterface */ |
| 23 | + private $objectManager; |
| 24 | + |
| 25 | + /** @var Qtyincrements */ |
| 26 | + private $qtyIncrements; |
| 27 | + |
| 28 | + /** @var BackendFactory */ |
| 29 | + private $backendFactory; |
| 30 | + |
| 31 | + /** |
| 32 | + * @inheritdoc |
| 33 | + */ |
| 34 | + protected function setUp(): void |
| 35 | + { |
| 36 | + $this->objectManager = Bootstrap::getObjectManager(); |
| 37 | + $this->backendFactory = $this->objectManager->create(BackendFactory::class); |
| 38 | + $this->qtyIncrements = $this->backendFactory->create(Qtyincrements::class, [ |
| 39 | + 'data' => [ |
| 40 | + 'path' => Configuration::XML_PATH_QTY_INCREMENTS, |
| 41 | + ] |
| 42 | + ]); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @return void |
| 47 | + */ |
| 48 | + public function testAfterSaveWithDecimals(): void |
| 49 | + { |
| 50 | + $this->expectException(LocalizedException::class); |
| 51 | + $this->expectExceptionMessage((string)__("Quantity increments can't use decimals. Enter a new increment and try again.")); |
| 52 | + $value = 10.5; |
| 53 | + $this->qtyIncrements->setValue((string)$value); |
| 54 | + $this->qtyIncrements->beforeSave(); |
| 55 | + } |
| 56 | +} |
0 commit comments