18 private $groupRepositoryMock;
23 private $searchCriteriaBuilderMock;
28 private $objectConverterMock;
32 $this->groupRepositoryMock = $this->createMock(\
Magento\Customer\Api\GroupRepositoryInterface::class);
33 $this->searchCriteriaBuilderMock = $this->createMock(\
Magento\Framework\Api\SearchCriteriaBuilder::class);
34 $this->objectConverterMock = $this->createMock(\
Magento\Framework\Convert\DataObject::class);
35 $this->model = new \Magento\CatalogRule\Model\Rule\CustomerGroupsOptionsProvider(
36 $this->groupRepositoryMock,
37 $this->searchCriteriaBuilderMock,
38 $this->objectConverterMock
44 $customerGroups = [
'group1',
'group2'];
47 [
'label' =>
'label',
'value' =>
'value']
50 $searchCriteriaMock = $this->createMock(\
Magento\Framework\Api\SearchCriteria::class);
51 $searchResultMock = $this->createMock(\
Magento\Customer\Api\Data\GroupSearchResultsInterface::class);
52 $this->searchCriteriaBuilderMock->expects($this->once())->method(
'create')->willReturn($searchCriteriaMock);
54 $this->groupRepositoryMock->expects($this->once())
56 ->with($searchCriteriaMock)
57 ->willReturn($searchResultMock);
59 $searchResultMock->expects($this->once())->method(
'getItems')->willReturn($customerGroups);
60 $this->objectConverterMock->expects($this->once())
61 ->method(
'toOptionArray')
62 ->with($customerGroups,
'id',
'code')
65 $this->assertEquals(
$options, $this->model->toOptionArray());