- Notifications
You must be signed in to change notification settings - Fork 9.4k
[Fedex] covered Model/Source/Generic.php by unit test #26549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-engcom-team merged 5 commits into magento:2.4-develop from srsathish92:2.4-unit-test/fedex-model-source-generic Feb 8, 2020
Merged
Changes from 3 commits
Commits
Show all changes
5 commits Select commit Hold shift + click to select a range
5b9b163 [Fedex] covered model source generic by unit test & removed deprecate…
srsathish92 680021b Static test fix
srsathish92 0340713 Static test fix
srsathish92 eb97904 array_map updated instead of foreach
srsathish92 74b1d8b Static test fix
srsathish92 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
94 changes: 94 additions & 0 deletions 94 app/code/Magento/Fedex/Test/Unit/Model/Source/GenericTest.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,94 @@ | ||
| <?php | ||
| | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| | ||
| declare(strict_types=1); | ||
| | ||
| namespace Magento\Fedex\Test\Unit\Model\Source; | ||
| | ||
| use Magento\Fedex\Model\Source\Generic; | ||
| use PHPUnit\Framework\TestCase; | ||
| use PHPUnit\Framework\MockObject\MockObject; | ||
| use Magento\Fedex\Model\Carrier; | ||
| use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; | ||
| | ||
| /** | ||
| * Unit test for Magento\Fedex\Test\Unit\Model\Source\Generic | ||
| */ | ||
| class GenericTest extends TestCase | ||
| { | ||
| /** | ||
| * @var Generic | ||
| */ | ||
| private $model; | ||
| | ||
| /** | ||
| * @var Carrier|MockObject | ||
| */ | ||
| private $shippingFedexMock; | ||
| | ||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| protected function setUp(): void | ||
| { | ||
| $this->shippingFedexMock = $this->createMock(Carrier::class); | ||
| | ||
| $objectManager = new ObjectManagerHelper($this); | ||
| $this->model = $objectManager->getObject( | ||
| Generic::class, | ||
| [ | ||
| 'shippingFedex' => $this->shippingFedexMock | ||
| ] | ||
| ); | ||
| } | ||
| | ||
| /** | ||
| * Test toOptionArray | ||
| * | ||
| * @param string $code | ||
| * @param array|false $methods | ||
| * @param array $result | ||
| * @return void | ||
| * @dataProvider toOptionArrayDataProvider | ||
| */ | ||
| public function testToOptionArray($code, $methods, $result): void | ||
| { | ||
| $this->model->code = $code; | ||
| $this->shippingFedexMock->expects($this->once()) | ||
| ->method('getCode') | ||
| ->willReturn($methods); | ||
| | ||
| $this->assertEquals($result, $this->model->toOptionArray()); | ||
| } | ||
| | ||
| /** | ||
| * Data provider for testToOptionArray() | ||
| * | ||
| * @return array | ||
| */ | ||
| public function toOptionArrayDataProvider(): array | ||
| { | ||
| return [ | ||
| [ | ||
| 'method', | ||
| [ | ||
| 'FEDEX_GROUND' => __('Ground'), | ||
| 'FIRST_OVERNIGHT' => __('First Overnight') | ||
| ], | ||
| [ | ||
| ['value' => 'FEDEX_GROUND', 'label' => __('Ground')], | ||
| ['value' => 'FIRST_OVERNIGHT', 'label' => __('First Overnight')] | ||
| ] | ||
| ], | ||
| [ | ||
| '', | ||
| false, | ||
| [] | ||
| ] | ||
| ]; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.