Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 03e4e3a

Browse files
author
Stanislav Idolov
authored
ENGCOM-807: Refactor: Unit test naming #14006
2 parents af9e6cf + a055e38 commit 03e4e3a

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -441,33 +441,39 @@ public function testReindexFlatDisabled(
441441

442442
public function testGetCustomAttributes()
443443
{
444-
$nameAttributeCode = 'name';
445-
$descriptionAttributeCode = 'description';
444+
$interfaceAttributeCode = 'name';
445+
$customAttributeCode = 'description';
446+
$initialCustomAttributeValue = 'initial description';
447+
$newCustomAttributeValue = 'new description';
448+
446449
$this->getCustomAttributeCodes->expects($this->exactly(3))
447450
->method('execute')
448-
->willReturn([$descriptionAttributeCode]);
449-
$this->category->setData($nameAttributeCode, "sub");
451+
->willReturn([$customAttributeCode]);
452+
$this->category->setData($interfaceAttributeCode, "sub");
450453

451454
//The description attribute is not set, expect empty custom attribute array
452455
$this->assertEquals([], $this->category->getCustomAttributes());
453456

454457
//Set the description attribute;
455-
$this->category->setData($descriptionAttributeCode, "description");
458+
$this->category->setData($customAttributeCode, $initialCustomAttributeValue);
456459
$attributeValue = new \Magento\Framework\Api\AttributeValue();
457460
$attributeValue2 = new \Magento\Framework\Api\AttributeValue();
458461
$this->attributeValueFactory->expects($this->exactly(2))->method('create')
459462
->willReturnOnConsecutiveCalls($attributeValue, $attributeValue2);
460463
$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+
);
463469

464470
//Change the attribute value, should reflect in getCustomAttribute
465-
$this->category->setData($descriptionAttributeCode, "new description");
471+
$this->category->setData($customAttributeCode, $newCustomAttributeValue);
466472
$this->assertEquals(1, count($this->category->getCustomAttributes()));
467-
$this->assertNotNull($this->category->getCustomAttribute($descriptionAttributeCode));
473+
$this->assertNotNull($this->category->getCustomAttribute($customAttributeCode));
468474
$this->assertEquals(
469-
"new description",
470-
$this->category->getCustomAttribute($descriptionAttributeCode)->getValue()
475+
$newCustomAttributeValue,
476+
$this->category->getCustomAttribute($customAttributeCode)->getValue()
471477
);
472478
}
473479

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,31 +1278,40 @@ public function testGetMediaGalleryImagesMerging()
12781278

12791279
public function testGetCustomAttributes()
12801280
{
1281-
$priceCode = 'price';
1282-
$colorAttributeCode = 'color';
1281+
$interfaceAttributeCode = 'price';
1282+
$customAttributeCode = 'color';
1283+
$initialCustomAttributeValue = 'red';
1284+
$newCustomAttributeValue = 'blue';
1285+
12831286
$this->getCustomAttributeCodes->expects($this->exactly(3))
12841287
->method('execute')
1285-
->willReturn([$colorAttributeCode]);
1286-
$this->model->setData($priceCode, 10);
1288+
->willReturn([$customAttributeCode]);
1289+
$this->model->setData($interfaceAttributeCode, 10);
12871290

12881291
//The color attribute is not set, expect empty custom attribute array
12891292
$this->assertEquals([], $this->model->getCustomAttributes());
12901293

12911294
//Set the color attribute;
1292-
$this->model->setData($colorAttributeCode, "red");
1295+
$this->model->setData($customAttributeCode, $initialCustomAttributeValue);
12931296
$attributeValue = new \Magento\Framework\Api\AttributeValue();
12941297
$attributeValue2 = new \Magento\Framework\Api\AttributeValue();
12951298
$this->attributeValueFactory->expects($this->exactly(2))->method('create')
12961299
->willReturnOnConsecutiveCalls($attributeValue, $attributeValue2);
12971300
$this->assertEquals(1, count($this->model->getCustomAttributes()));
1298-
$this->assertNotNull($this->model->getCustomAttribute($colorAttributeCode));
1299-
$this->assertEquals("red", $this->model->getCustomAttribute($colorAttributeCode)->getValue());
1301+
$this->assertNotNull($this->model->getCustomAttribute($customAttributeCode));
1302+
$this->assertEquals(
1303+
$initialCustomAttributeValue,
1304+
$this->model->getCustomAttribute($customAttributeCode)->getValue()
1305+
);
13001306

13011307
//Change the attribute value, should reflect in getCustomAttribute
1302-
$this->model->setData($colorAttributeCode, "blue");
1308+
$this->model->setData($customAttributeCode, $newCustomAttributeValue);
13031309
$this->assertEquals(1, count($this->model->getCustomAttributes()));
1304-
$this->assertNotNull($this->model->getCustomAttribute($colorAttributeCode));
1305-
$this->assertEquals("blue", $this->model->getCustomAttribute($colorAttributeCode)->getValue());
1310+
$this->assertNotNull($this->model->getCustomAttribute($customAttributeCode));
1311+
$this->assertEquals(
1312+
$newCustomAttributeValue,
1313+
$this->model->getCustomAttribute($customAttributeCode)->getValue()
1314+
);
13061315
}
13071316

13081317
/**

0 commit comments

Comments
 (0)