Skip to content

Commit 85f36cd

Browse files
author
tkotosz
committed
add failing test for json-encoded attribute backend
1 parent f18377b commit 85f36cd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/JsonEncodedTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ public function testBeforeSave()
8282
$this->assertEquals(json_encode([1, 2, 3]), $product->getData('json_encoded'));
8383
}
8484

85+
/**
86+
* Test before save handler with already encoded attribute value
87+
*/
88+
public function testBeforeSaveWithAlreadyEncodedValue()
89+
{
90+
$product = new \Magento\Framework\DataObject(
91+
[
92+
'json_encoded' => [1, 2, 3]
93+
]
94+
);
95+
96+
// save twice
97+
$this->model->beforeSave($product);
98+
$this->model->beforeSave($product);
99+
100+
// check it is encoded only once
101+
$this->assertEquals(json_encode([1, 2, 3]), $product->getData('json_encoded'));
102+
}
103+
85104
/**
86105
* Test after load handler
87106
*/

0 commit comments

Comments
 (0)