This repository was archived by the owner on May 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Add topic description feature #30
Open
phoenix128
wants to merge
1
commit into
magento:2.3-develop
Choose a base branch
from
magespecialist:issue-13-define-user-friendly-topic-names
base: 2.3-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/code/Magento/AsynchronousOperations/Model/TopicDescriptionPool.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\AsynchronousOperations\Model; | ||
|
||
/** | ||
* Bulk operations description pool | ||
*/ | ||
class TopicDescriptionPool | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $descriptions; | ||
|
||
/** | ||
* BulkDescriptionPool constructor | ||
* | ||
* @param array $descriptions | ||
*/ | ||
public function __construct( | ||
$descriptions = [] | ||
) { | ||
$this->descriptions = $descriptions; | ||
} | ||
|
||
/** | ||
* Get description for a given topic name | ||
* | ||
* @param string $topicName | ||
* @return string|null | ||
*/ | ||
public function getDescription($topicName) | ||
{ | ||
if (isset($this->descriptions[$topicName])) { | ||
return $this->descriptions[$topicName]; | ||
} | ||
|
||
return null; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/code/Magento/AsynchronousOperations/Test/Unit/Model/TopicDescriptionPoolTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\AsynchronousOperations\Test\Unit\Model; | ||
|
||
use Magento\AsynchronousOperations\Model\TopicDescriptionPool; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
|
||
/** | ||
* Class StatusMapperTest | ||
*/ | ||
class TopicDescriptionPoolTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var \Magento\AsynchronousOperations\Model\TopicDescriptionPool | ||
*/ | ||
private $topicDescriptionPool; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $testTopics = [ | ||
'async.V1.test.topic1' => 'Test topic 1', | ||
'async.V1.test.topic2' => 'Test topic 2', | ||
'async.V1.test.topic3' => 'Test topic 3', | ||
]; | ||
|
||
protected function setUp() | ||
{ | ||
$this->topicDescriptionPool = (new ObjectManager($this))->getObject( | ||
TopicDescriptionPool::class, | ||
[ | ||
'descriptions' => $this->testTopics | ||
] | ||
); | ||
} | ||
|
||
public function testGetDescriptionOnExistingValues() | ||
{ | ||
foreach ($this->testTopics as $topic => $description) { | ||
self::assertEquals($description, $this->topicDescriptionPool->getDescription($topic)); | ||
} | ||
} | ||
|
||
public function testGetDescriptionOnNonExistingValue() | ||
{ | ||
self::assertNull($this->topicDescriptionPool->getDescription('non.existing.topic')); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really have a strong reason to change method arguments list or we may delay them till the moment when we will have some code that passes this argument?