forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Artem Kirkor
committed
Jul 5, 2022
1 parent
abcc674
commit 73bb8f6
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
app/code/Magento/QuoteGraphQl/Test/Unit/Model/Resolver/DiscountsTest.php
This file contains 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,90 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\QuoteGraphQl\Test\Unit\Model\Resolver; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\GraphQl\Model\Query\Context; | ||
use Magento\QuoteGraphQl\Model\Resolver\Discounts; | ||
use PHPUnit\Framework\TestCase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
/** | ||
* @see Discounts | ||
*/ | ||
class DiscountsTest extends TestCase | ||
{ | ||
/** | ||
* @var Discounts | ||
*/ | ||
private Discounts $discounts; | ||
|
||
/** | ||
* @var Field|MockObject | ||
*/ | ||
private Field $fieldMock; | ||
|
||
/** | ||
* @var ResolveInfo|MockObject | ||
*/ | ||
private ResolveInfo $resolveInfoMock; | ||
|
||
/** | ||
* @var Context|MockObject | ||
*/ | ||
private Context $contextMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->fieldMock = $this->createMock(Field::class); | ||
$this->resolveInfoMock = $this->createMock(ResolveInfo::class); | ||
$this->contextMock = $this->createMock(Context::class); | ||
$this->discounts = new Discounts(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function dataProviderDiscounts(): array | ||
{ | ||
return [[[ | ||
'discount' => [ | ||
'label' => ['Discount'], | ||
'amount' => [ | ||
'value' => 100, | ||
'currency' => 'USD' | ||
] | ||
] | ||
]]]; | ||
} | ||
|
||
/** | ||
* @dataProvider dataProviderDiscounts | ||
*/ | ||
public function testResolve(array $discount): void | ||
{ | ||
$expected = [ | ||
[ | ||
'label' => __('Discount'), | ||
'amount' => [ | ||
'value' => 100, | ||
'currency' => 'USD' | ||
] | ||
] | ||
]; | ||
|
||
$result = $this->discounts->resolve( | ||
$this->fieldMock, | ||
$this->contextMock, | ||
$this->resolveInfoMock, | ||
$discount | ||
); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
} |