File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
app/code/Magento/Customer Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -373,4 +373,19 @@ public function isVatAttributeVisible()
373
373
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
374
374
);
375
375
}
376
+
377
+ /**
378
+ * Retrieve attribute visibility
379
+ *
380
+ * @param string $code
381
+ * @return bool
382
+ */
383
+ public function isAttributeVisible ($ code )
384
+ {
385
+ $ attributeMetadata = $ this ->_addressMetadataService ->getAttributeMetadata ($ code );
386
+ if ($ attributeMetadata ) {
387
+ return $ attributeMetadata ->isVisible ();
388
+ }
389
+ return false ;
390
+ }
376
391
}
Original file line number Diff line number Diff line change @@ -372,4 +372,34 @@ public function getFormatDataProvider()
372
372
['invalid_code ' , '' ]
373
373
];
374
374
}
375
+
376
+ /**
377
+ * @param string $attributeCode
378
+ * @param bool $isMetadataExists
379
+ * @dataProvider isAttributeVisibleDataProvider
380
+ */
381
+ public function testIsAttributeVisible ($ attributeCode , $ isMetadataExists )
382
+ {
383
+ $ attributeMetadata = null ;
384
+ if ($ isMetadataExists ) {
385
+ $ attributeMetadata = $ this ->getMockBuilder (\Magento \Customer \Api \Data \AttributeMetadataInterface::class)
386
+ ->getMockForAbstractClass ();
387
+ $ attributeMetadata ->expects ($ this ->once ())
388
+ ->method ('isVisible ' )
389
+ ->willReturn (true );
390
+ }
391
+ $ this ->addressMetadataService ->expects ($ this ->once ())
392
+ ->method ('getAttributeMetadata ' )
393
+ ->with ($ attributeCode )
394
+ ->willReturn ($ attributeMetadata );
395
+ $ this ->assertEquals ($ isMetadataExists , $ this ->helper ->isAttributeVisible ($ attributeCode ));
396
+ }
397
+
398
+ public function isAttributeVisibleDataProvider ()
399
+ {
400
+ return [
401
+ ['fax ' , true ],
402
+ ['invalid_code ' , false ]
403
+ ];
404
+ }
375
405
}
You can’t perform that action at this time.
0 commit comments