123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- *
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Customer\Test\Unit\Model\Config\Source;
- use Magento\Customer\Api\GroupManagementInterface;
- use Magento\Customer\Model\Config\Source\Group;
- use Magento\Customer\Model\Customer\Attribute\Source\GroupSourceLoggedInOnlyInterface;
- use Magento\Framework\Convert\DataObject;
- use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
- class GroupTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var GroupSourceLoggedInOnlyInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- private $groupSource;
- /**
- * @var Group
- */
- protected $model;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $groupServiceMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $converterMock;
- protected function setUp()
- {
- $this->groupServiceMock = $this->createMock(GroupManagementInterface::class);
- $this->converterMock = $this->createMock(DataObject::class);
- $this->groupSource = $this->getMockBuilder(GroupSourceLoggedInOnlyInterface::class)
- ->getMockForAbstractClass();
- $this->model = (new ObjectManager($this))->getObject(
- Group::class,
- [
- 'groupManagement' => $this->groupServiceMock,
- 'converter' => $this->converterMock,
- 'groupSourceForLoggedInCustomers' => $this->groupSource,
- ]
- );
- }
- public function testToOptionArray()
- {
- $expectedValue = ['General', 'Retail'];
- $this->groupServiceMock->expects($this->never())->method('getLoggedInGroups');
- $this->converterMock->expects($this->never())->method('toOptionArray');
- $this->groupSource->expects($this->once())
- ->method('toOptionArray')
- ->willReturn($expectedValue);
- array_unshift($expectedValue, ['value' => '', 'label' => __('-- Please Select --')]);
- $this->assertEquals($expectedValue, $this->model->toOptionArray());
- }
- }
|