Пример #1
0
 public function testLogin()
 {
     $customerId = 1;
     $username = '******';
     $password = '******';
     $customerDataMock = $this->prepareLoginDataMock($customerId);
     $this->customerAccountServiceMock->expects($this->once())->method('authenticate')->with($this->equalTo($username), $this->equalTo($password))->will($this->returnValue($customerDataMock));
     $this->assertTrue($this->_model->login($username, $password));
 }
Пример #2
0
 /**
  * @param bool $expectedResult
  * @param bool $isCustomerIdValid
  * @param bool $isCustomerEmulated
  * @dataProvider getIsLoggedInDataProvider
  */
 public function testIsLoggedIn($expectedResult, $isCustomerIdValid, $isCustomerEmulated)
 {
     $customerId = 1;
     $this->_storageMock->expects($this->any())->method('getData')->with('customer_id')->will($this->returnValue($customerId));
     if ($isCustomerIdValid) {
         $this->customerAccountServiceMock->expects($this->once())->method('getCustomer')->with($customerId);
     } else {
         $this->customerAccountServiceMock->expects($this->once())->method('getCustomer')->with($customerId)->will($this->throwException(new \Exception('Customer ID is invalid.')));
     }
     $this->_storageMock->expects($this->any())->method('getIsCustomerEmulated')->will($this->returnValue($isCustomerEmulated));
     $this->assertEquals($expectedResult, $this->_model->isLoggedIn());
 }