File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
app/code/Magento/Catalog/Model
dev/tests/integration/testsuite/Magento/Catalog/Model Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1712,7 +1712,7 @@ public function isInStock()
17121712 * Get attribute text by its code
17131713 *
17141714 * @param string $attributeCode Code of the attribute
1715- * @return string
1715+ * @return string|array|null
17161716 */
17171717 public function getAttributeText ($ attributeCode )
17181718 {
Original file line number Diff line number Diff line change 55 */
66namespace Magento \Catalog \Model ;
77
8+ use Magento \Catalog \Api \ProductRepositoryInterface ;
89use Magento \Framework \App \Filesystem \DirectoryList ;
910
1011/**
@@ -25,11 +26,19 @@ class ProductGettersTest extends \PHPUnit\Framework\TestCase
2526 */
2627 protected $ _model ;
2728
29+ /**
30+ * @var ProductRepositoryInterface
31+ */
32+ private $ productRepository ;
33+
2834 protected function setUp ()
2935 {
3036 $ this ->_model = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
3137 \Magento \Catalog \Model \Product::class
3238 );
39+ $ this ->productRepository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
40+ ProductRepositoryInterface::class
41+ );
3342 }
3443
3544 public function testGetResourceCollection ()
@@ -198,6 +207,24 @@ public function testGetAttributeText()
198207 $ this ->assertEquals ('Enabled ' , $ this ->_model ->getAttributeText ('status ' ));
199208 }
200209
210+ /**
211+ * @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php
212+ */
213+ public function testGetAttributeTextArray ()
214+ {
215+ $ product = $ this ->productRepository ->get ('simple_ms_2 ' );
216+ $ product ->getAttributeText ('multiselect_attribute ' );
217+ $ expected = [
218+ 'Option 2 ' ,
219+ 'Option 3 ' ,
220+ 'Option 4 "!@#$%^&* '
221+ ];
222+ self ::assertEquals (
223+ $ expected ,
224+ $ product ->getAttributeText ('multiselect_attribute ' )
225+ );
226+ }
227+
201228 public function testGetCustomDesignDate ()
202229 {
203230 $ this ->assertEquals (['from ' => null , 'to ' => null ], $ this ->_model ->getCustomDesignDate ());
You can’t perform that action at this time.
0 commit comments