24 private $quoteSession;
29 private $groupManagement;
36 $this->quoteSession = $this->getMockBuilder(Quote::class)
37 ->disableOriginalConstructor()
38 ->setMethods([
'getQuoteId',
'getQuote'])
40 $this->groupManagement = $this->getMockBuilder(GroupManagementInterface::class)
41 ->disableOriginalConstructor()
42 ->getMockForAbstractClass();
44 $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
45 $this->retriever =
$helper->getObject(
46 \
Magento\Sales\Model\CustomerGroupRetriever::class,
48 'quoteSession' => $this->quoteSession,
49 'groupManagement' => $this->groupManagement
59 $this->quoteSession->expects($this->atLeastOnce())->method(
'getQuoteId')->willReturn(1);
61 ->disableOriginalConstructor()
63 $this->quoteSession->expects($this->atLeastOnce())->method(
'getQuote')->willReturn(
$quote);
64 $quote->expects($this->once())->method(
'getCustomerGroupId')->willReturn(2);
66 $this->assertEquals(2, $this->retriever->getCustomerGroupId());
74 $this->quoteSession->expects($this->atLeastOnce())->method(
'getQuoteId')->willReturn(0);
75 $this->quoteSession->expects($this->never())->method(
'getQuote');
77 ->disableOriginalConstructor()
78 ->getMockForAbstractClass();
79 $this->groupManagement->expects($this->once())->method(
'getNotLoggedInGroup')->willReturn(
$group);
80 $group->expects($this->once())->method(
'getId')->willReturn(2);
82 $this->assertEquals(2, $this->retriever->getCustomerGroupId());
testGetCustomerGroupIdQuote()
testGetCustomerGroupIdDefault()