Skip to content

Commit 07afde5

Browse files
committed
MC-39606: Create automated test for: "Save the product with "Set new as from" attribute"
1 parent aac1d8c commit 07afde5

File tree

1 file changed

+7
-5
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend

1 file changed

+7
-5
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/StartdateTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Magento\Catalog\Model\Attribute\Backend;
1010

11-
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
1211
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
1312
use Magento\Catalog\Model\Product;
1413
use Magento\Eav\Model\Config;
@@ -18,10 +17,11 @@
1817
use PHPUnit\Framework\TestCase;
1918

2019
/**
21-
* Test for Special Start Date attribute
20+
* Test for Start Date attribute backend model
21+
*
22+
* @see \Magento\Catalog\Model\Attribute\Backend\Startdate
2223
*
2324
* @magentoAppArea adminhtml
24-
* @magentoAppIsolation enabled
2525
*/
2626
class StartdateTest extends TestCase
2727
{
@@ -45,7 +45,8 @@ protected function setUp(): void
4545
$this->productFactory = $this->objectManager->get(ProductInterfaceFactory::class);
4646
$this->startDate = $this->objectManager->get(Startdate::class);
4747
$attribute = $this->objectManager->get(Config::class)->getAttribute(Product::ENTITY, 'news_from_date');
48-
$attribute->setMaxValue(date('Y-m-d H:i:s', strtotime('-10 days')));
48+
//$attribute->setMaxValue(date('Y-m-d H:i:s', strtotime('-10 days')));
49+
$attribute->setMaxValue(new \DateTime('-10 days'));
4950
$this->startDate->setAttribute($attribute);
5051
}
5152

@@ -66,7 +67,8 @@ public function testBeforeSave(): void
6667
public function testValidate(): void
6768
{
6869
$product = $this->productFactory->create();
69-
$product->setNewsFromDate(date('d-m-Y'));
70+
//$product->setNewsFromDate(date('d-m-Y'));
71+
$product->setNewsFromDate(new \DateTime());
7072
$this->expectException(Exception::class);
7173
$msg = __('Make sure the To Date is later than or the same as the From Date.');
7274
$this->expectExceptionMessage((string)$msg);

0 commit comments

Comments
 (0)