Example #1
0
 public function testSetCustomerAsLoggedIn()
 {
     $customer = $this->getMock('Magento\\Customer\\Model\\Customer', [], [], '', false);
     $customerDto = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $customer->expects($this->any())->method('getDataModel')->will($this->returnValue($customerDto));
     $this->_eventManagerMock->expects($this->at(0))->method('dispatch')->with('customer_login', ['customer' => $customer]);
     $this->_eventManagerMock->expects($this->at(1))->method('dispatch')->with('customer_data_object_login', ['customer' => $customerDto]);
     $_SESSION = [];
     $this->_model->setCustomerAsLoggedIn($customer);
     $this->assertSame($customer, $this->_model->getCustomer());
 }
 public function loginByCustomer(\Magento\Customer\Model\Customer $customer)
 {
     if ($customer->getConfirmation()) {
         $customer->setConfirmation(null);
         $customer->save();
     }
     $this->_customerSession->setCustomerAsLoggedIn($customer);
 }