@@ -441,33 +441,39 @@ public function testReindexFlatDisabled(
441
441
442
442
public function testGetCustomAttributes ()
443
443
{
444
- $ nameAttributeCode = 'name ' ;
445
- $ descriptionAttributeCode = 'description ' ;
444
+ $ interfaceAttributeCode = 'name ' ;
445
+ $ customAttributeCode = 'description ' ;
446
+ $ initialCustomAttributeValue = 'initial description ' ;
447
+ $ newCustomAttributeValue = 'new description ' ;
448
+
446
449
$ this ->getCustomAttributeCodes ->expects ($ this ->exactly (3 ))
447
450
->method ('execute ' )
448
- ->willReturn ([$ descriptionAttributeCode ]);
449
- $ this ->category ->setData ($ nameAttributeCode , "sub " );
451
+ ->willReturn ([$ customAttributeCode ]);
452
+ $ this ->category ->setData ($ interfaceAttributeCode , "sub " );
450
453
451
454
//The description attribute is not set, expect empty custom attribute array
452
455
$ this ->assertEquals ([], $ this ->category ->getCustomAttributes ());
453
456
454
457
//Set the description attribute;
455
- $ this ->category ->setData ($ descriptionAttributeCode , " description " );
458
+ $ this ->category ->setData ($ customAttributeCode , $ initialCustomAttributeValue );
456
459
$ attributeValue = new \Magento \Framework \Api \AttributeValue ();
457
460
$ attributeValue2 = new \Magento \Framework \Api \AttributeValue ();
458
461
$ this ->attributeValueFactory ->expects ($ this ->exactly (2 ))->method ('create ' )
459
462
->willReturnOnConsecutiveCalls ($ attributeValue , $ attributeValue2 );
460
463
$ this ->assertEquals (1 , count ($ this ->category ->getCustomAttributes ()));
461
- $ this ->assertNotNull ($ this ->category ->getCustomAttribute ($ descriptionAttributeCode ));
462
- $ this ->assertEquals ("description " , $ this ->category ->getCustomAttribute ($ descriptionAttributeCode )->getValue ());
464
+ $ this ->assertNotNull ($ this ->category ->getCustomAttribute ($ customAttributeCode ));
465
+ $ this ->assertEquals (
466
+ $ initialCustomAttributeValue ,
467
+ $ this ->category ->getCustomAttribute ($ customAttributeCode )->getValue ()
468
+ );
463
469
464
470
//Change the attribute value, should reflect in getCustomAttribute
465
- $ this ->category ->setData ($ descriptionAttributeCode , " new description " );
471
+ $ this ->category ->setData ($ customAttributeCode , $ newCustomAttributeValue );
466
472
$ this ->assertEquals (1 , count ($ this ->category ->getCustomAttributes ()));
467
- $ this ->assertNotNull ($ this ->category ->getCustomAttribute ($ descriptionAttributeCode ));
473
+ $ this ->assertNotNull ($ this ->category ->getCustomAttribute ($ customAttributeCode ));
468
474
$ this ->assertEquals (
469
- " new description " ,
470
- $ this ->category ->getCustomAttribute ($ descriptionAttributeCode )->getValue ()
475
+ $ newCustomAttributeValue ,
476
+ $ this ->category ->getCustomAttribute ($ customAttributeCode )->getValue ()
471
477
);
472
478
}
473
479
0 commit comments