Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
EmulateQuoteObserverTest Class Reference
Inheritance diagram for EmulateQuoteObserverTest:

Public Member Functions

 setUp ()
 
 testEmulateQuote ()
 

Protected Attributes

 $customerRepository
 
 $_persistentSessionHelper
 
 $_objectManager
 
 $_observer
 
 $_customerSession
 
 $_checkoutSession
 

Detailed Description

@magentoDataFixture Magento/Persistent/_files/persistent.php

Definition at line 12 of file EmulateQuoteObserverTest.php.

Member Function Documentation

◆ setUp()

setUp ( )

Definition at line 44 of file EmulateQuoteObserverTest.php.

45  {
47 
48  $this->_customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class);
49 
50  $this->customerRepository = $this->_objectManager->create(
51  \Magento\Customer\Api\CustomerRepositoryInterface::class
52  );
53 
54  $this->_checkoutSession = $this->getMockBuilder(
55  \Magento\Checkout\Model\Session::class
56  )->disableOriginalConstructor()->setMethods([])->getMock();
57 
58  $this->_persistentSessionHelper = $this->_objectManager->create(\Magento\Persistent\Helper\Session::class);
59 
60  $this->_observer = $this->_objectManager->create(
61  \Magento\Persistent\Observer\EmulateQuoteObserver::class,
62  [
63  'customerRepository' => $this->customerRepository,
64  'checkoutSession' => $this->_checkoutSession,
65  'persistentSession' => $this->_persistentSessionHelper
66  ]
67  );
68  }

◆ testEmulateQuote()

testEmulateQuote ( )

@magentoConfigFixture current_store persistent/options/enabled 1 @magentoConfigFixture current_store persistent/options/remember_enabled 1 @magentoConfigFixture current_store persistent/options/remember_default 1 @magentoAppArea frontend @magentoConfigFixture current_store persistent/options/shopping_cart 1 @magentoConfigFixture current_store persistent/options/logout_clear 0

Definition at line 78 of file EmulateQuoteObserverTest.php.

79  {
80  $requestMock = $this->getMockBuilder(
81  \Magento\Framework\App\Request\Http::class
82  )->disableOriginalConstructor()->setMethods(
83  []
84  )->getMock();
85  $requestMock->expects($this->once())->method('getFullActionName')->will($this->returnValue('valid_action'));
86  $event = new \Magento\Framework\Event(['request' => $requestMock]);
87  $observer = new \Magento\Framework\Event\Observer();
88  $observer->setEvent($event);
89 
90  $this->_customerSession->loginById(1);
91 
92  $customer = $this->customerRepository->getById(
93  $this->_persistentSessionHelper->getSession()->getCustomerId()
94  );
95  $this->_checkoutSession->expects($this->once())->method('setCustomerData')->with($customer);
96  $this->_customerSession->logout();
97 
98  $this->_observer->execute($observer);
99  }
$customer
Definition: customers.php:11

Field Documentation

◆ $_checkoutSession

$_checkoutSession
protected

Definition at line 42 of file EmulateQuoteObserverTest.php.

◆ $_customerSession

$_customerSession
protected

Definition at line 37 of file EmulateQuoteObserverTest.php.

◆ $_objectManager

$_objectManager
protected

Definition at line 27 of file EmulateQuoteObserverTest.php.

◆ $_observer

$_observer
protected

Definition at line 32 of file EmulateQuoteObserverTest.php.

◆ $_persistentSessionHelper

$_persistentSessionHelper
protected

Definition at line 22 of file EmulateQuoteObserverTest.php.

◆ $customerRepository

$customerRepository
protected

Definition at line 17 of file EmulateQuoteObserverTest.php.


The documentation for this class was generated from the following file: