Skip to content

Commit

Permalink
Source Entity expansion with Pickup Location attributes #2182.
Browse files Browse the repository at this point in the history
Improved tests coverage
  • Loading branch information
novikor committed May 18, 2019
1 parent c537d6a commit d619398
Showing 1 changed file with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ protected function setUp()
public function testGetListOfSourcesWithPickupLocationExtensionAfterSave()
{
$pickupLocationConfig = [
'default' => false,
'eu-1' => true,
'eu-2' => true,
'eu-3' => false,
'eu-disabled' => false,
'us-1' => true,
'default' => ['active' => false, 'name' => 'default', 'desc' => 'default'],
'eu-1' => ['active' => true, 'name' => '', 'desc' => ''],
'eu-2' => ['active' => true, 'name' => 'zzz', 'desc' => ''],
'eu-3' => ['active' => false, 'name' => '', 'desc' => 'zzz1'],
'eu-disabled' => ['active' => false, 'name' => '', 'desc' => ''],
'us-1' => ['active' => true, 'name' => '666', 'desc' => ''],
];

$searchResult = $this->sourceRepository->getList();

/** @var SourceInterface $item */
foreach ($searchResult->getItems() as $item) {
$item->getExtensionAttributes()->setIsPickupLocationActive(
$pickupLocationConfig[$item->getSourceCode()]
);
$item->getExtensionAttributes()
->setIsPickupLocationActive($pickupLocationConfig[$item->getSourceCode()]['active'])
->setFrontendDescription($pickupLocationConfig[$item->getSourceCode()]['desc'])
->setFrontendName($pickupLocationConfig[$item->getSourceCode()]['name']);
$this->sourceRepository->save($item);
}

Expand All @@ -57,7 +58,10 @@ public function testGetListOfSourcesWithPickupLocationExtensionAfterSave()
$pickupLocationsStatus = [];

foreach ($searchResult->getItems() as $item) {
$pickupLocationsStatus[$item->getSourceCode()] = $item->getExtensionAttributes()->getIsPickupLocationActive();
$extension = $item->getExtensionAttributes();
$pickupLocationsStatus[$item->getSourceCode()]['active'] = $extension->getIsPickupLocationActive();
$pickupLocationsStatus[$item->getSourceCode()]['name'] = $extension->getFrontendName();
$pickupLocationsStatus[$item->getSourceCode()]['desc'] = $extension->getFrontendDescription();
}

$this->assertEquals($pickupLocationConfig, $pickupLocationsStatus);
Expand All @@ -71,10 +75,15 @@ public function testGetSourceWithPickupLocationExtensionAfterSave()
$sourceCode = 'source-code-1';

$source = $this->sourceRepository->get($sourceCode);
$source->getExtensionAttributes()->setIsPickupLocationActive(true);
$source->getExtensionAttributes()
->setIsPickupLocationActive(true)
->setFrontendName('zzz')
->setFrontendDescription('666');
$this->sourceRepository->save($source);

$source = $this->sourceRepository->get($sourceCode);
$this->assertEquals(true, $source->getExtensionAttributes()->getIsPickupLocationActive());
$this->assertEquals('zzz', $source->getExtensionAttributes()->getFrontendName());
$this->assertEquals('666', $source->getExtensionAttributes()->getFrontendDescription());
}
}

0 comments on commit d619398

Please sign in to comment.