Skip to content

Commit

Permalink
magento#10045 Sitemap add item refactoring - fix coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkwiecinski committed Jul 19, 2017
1 parent becd97c commit d990c95
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(
public function getItems($storeId)
{
$collection = $this->categoryFactory->create()->getCollection($storeId);
$items = array_map(function($item) use ($storeId) {
$items = array_map(function ($item) use ($storeId) {
return $this->itemFactory->create([
'url' => $item->getUrl(),
'updatedAt' => $item->getUpdatedAt(),
Expand Down Expand Up @@ -106,4 +106,4 @@ private function getCategoryChangeFrequency($storeId)
$storeId
);
}
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Sitemap/Model/CmsPageSitemapItemResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(
public function getItems($storeId)
{
$collection = $this->cmsPageFactory->create()->getCollection($storeId);
$items = array_map(function($item) use ($storeId) {
$items = array_map(function ($item) use ($storeId) {
return $this->itemFactory->create([
'url' => $item->getUrl(),
'updatedAt' => $item->getUpdatedAt(),
Expand Down Expand Up @@ -107,4 +107,4 @@ private function getPageChangeFrequency($storeId)
$storeId
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ public function getItems($storeId)

return $items;
}
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Sitemap/Model/ProductSitemapItemResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(
public function getItems($storeId)
{
$collection = $this->productFactory->create()->getCollection($storeId);
$items = array_map(function($item) use ($storeId) {
$items = array_map(function ($item) use ($storeId) {
return $this->itemFactory->create([
'url' => $item->getUrl(),
'updatedAt' => $item->getUpdatedAt(),
Expand Down Expand Up @@ -105,4 +105,4 @@ private function getProductChangeFrequency($storeId)
$storeId
);
}
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Sitemap/Model/SitemapItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ public function getUpdatedAt()
{
return $this->updatedAt;
}
}
}
5 changes: 3 additions & 2 deletions app/code/Magento/Sitemap/Model/SitemapItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
*
* @api
*/
interface SitemapItemInterface {
interface SitemapItemInterface
{

/**
* Get url
Expand Down Expand Up @@ -47,4 +48,4 @@ public function getImages();
* @return string|null
*/
public function getUpdatedAt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ interface SitemapItemResolverInterface
* @return SitemapItemInterface[]
*/
public function getItems($storeId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ private function getCategoryCollectionMock($returnValue)

return $sitemapCmsPageMock;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testGetItems(array $pages = [])
$resolver = new CmsPageSitemapItemResolver($storeConfigMock, $cmsPageFactoryMock, $itemFactoryMock);
$items = $resolver->getItems(1);
self::assertTrue(count($items) == count($pages));
foreach($pages as $index => $page) {;
foreach ($pages as $index => $page) {
self::assertSame($page->getUpdatedAt(), $items[$index]->getUpdatedAt());
self::assertSame('daily', $items[$index]->getChangeFrequency());
self::assertSame('1.0', $items[$index]->getPriority());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testGetItems($itemResolverData, $expectedItems)
{
$mockResolvers = [];

foreach($itemResolverData as $data) {
foreach ($itemResolverData as $data) {
$mockResolver = $this->getMockForAbstractClass(SitemapItemResolverInterface::class);
$mockResolver->expects(self::once())
->method('getItems')
Expand All @@ -48,12 +48,12 @@ public function sitemapItemsProvider()
{
$testCases = [];

for($i = 1; $i < 5; $i++) {
for ($i = 1; $i < 5; $i++) {
$itemProviders = [];
$expectedItems = [];
for($i = 1; $i < $maxProviders = random_int(1, 5); $i++) {
for ($i = 1; $i < $maxProviders = random_int(1, 5); $i++) {
$items = [];
for($i = 1; $i < $maxItems = random_int(2, 5); $i++) {
for ($i = 1; $i < $maxItems = random_int(2, 5); $i++) {
$sitemapItem = $this->getMockForAbstractClass(SitemapItemInterface::class);
$items[] = $sitemapItem;
$expectedItems[] = $sitemapItem;
Expand All @@ -66,4 +66,4 @@ public function sitemapItemsProvider()

return $testCases;
}
}
}

0 comments on commit d990c95

Please sign in to comment.