47 $this->searchCriteriaBuilderMock = $this->createMock(\
Magento\Framework\Api\SearchCriteriaBuilder::class);
48 $this->storeMock = $this->createMock(\
Magento\Store\Model\System\Store::class);
49 $this->groupRepositoryMock = $this->createMock(\
Magento\Customer\Api\GroupRepositoryInterface::class);
50 $this->dataObjectMock = $this->createMock(\
Magento\Framework\Convert\DataObject::class);
51 $searchCriteriaMock = $this->createMock(\
Magento\Framework\Api\SearchCriteriaInterface::class);
52 $groupSearchResultsMock = $this->createMock(\
Magento\Customer\Api\Data\GroupSearchResultsInterface::class);
53 $groupsMock = $this->createMock(\
Magento\Customer\Api\Data\GroupInterface::class);
55 $this->searchCriteriaBuilderMock->expects($this->once())->method(
'create')->willReturn($searchCriteriaMock);
56 $this->groupRepositoryMock->expects($this->once())->method(
'getList')->with($searchCriteriaMock)
57 ->willReturn($groupSearchResultsMock);
58 $groupSearchResultsMock->expects($this->once())->method(
'getItems')->willReturn([$groupsMock]);
59 $this->storeMock->expects($this->once())->method(
'getWebsiteValuesForForm')->willReturn([]);
60 $this->dataObjectMock->expects($this->once())->method(
'toOptionArray')->with([$groupsMock],
'id',
'code')
62 $this->ruleFactoryMock = $this->createPartialMock(\
Magento\SalesRule\Model\RuleFactory::class, [
'create']);
64 \
Magento\SalesRule\Model\Rule\Metadata\ValueProvider::class,
66 'store' => $this->storeMock,
67 'groupRepository' => $this->groupRepositoryMock,
68 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock,
69 'objectConverter' => $this->dataObjectMock,
70 'salesRuleFactory' => $this->ruleFactoryMock,
75 public function testGetMetadataValues()
77 $expectedData = include
__DIR__ .
'/_files/MetaData.php';
80 $ruleMock = $this->createMock(\
Magento\SalesRule\Model\Rule::class);
81 $this->ruleFactoryMock->expects($this->once())
83 ->willReturn($ruleMock);
84 $ruleMock->expects($this->once())
85 ->method(
'getCouponTypes')
88 'key1' =>
'couponType1',
89 'key2' =>
'couponType2',
92 $ruleMock->expects($this->once())
93 ->method(
'getStoreLabels')
99 $test = $this->model->getMetadataValues($ruleMock);
100 $this->assertEquals($expectedData, $test);
defined('TESTS_BP')||define('TESTS_BP' __DIR__