public function setUp() {
parent::setUp();
- $this->request = $this->createMock('\\OCP\\IRequest');
- $this->userManager = $this->createMock('\\OCP\\IUserManager');
- $this->config = $this->createMock('\\OCP\\IConfig');
- $this->session = $this->createMock('\\OCP\\ISession');
+ $this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock();
+ $this->userManager = $this->getMockBuilder('\\OCP\\IUserManager')->getMock();
+ $this->config = $this->getMockBuilder('\\OCP\\IConfig')->getMock();
+ $this->session = $this->getMockBuilder('\\OCP\\ISession')->getMock();
$this->userSession = $this->getMockBuilder('\\OC\\User\\Session')
->disableOriginalConstructor()
->getMock();
- $this->urlGenerator = $this->createMock('\\OCP\\IURLGenerator');
+ $this->urlGenerator = $this->getMockBuilder('\\OCP\\IURLGenerator')->getMock();
$this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
->disableOriginalConstructor()
->getMock();
->method('getCookie')
->with('oc_token')
->willReturn('MyLoginToken');
- $user = $this->createMock('\\OCP\\IUser');
+ $user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
$user
->expects($this->once())
->method('getUID')
->method('getSystemValue')
->with('lost_password_link')
->willReturn(false);
- $user = $this->createMock('\\OCP\\IUser');
+ $user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
$user
->expects($this->once())
->method('canChangePassword')
->method('getSystemValue')
->with('lost_password_link')
->willReturn(false);
- $user = $this->createMock('\\OCP\\IUser');
+ $user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
$user
->expects($this->once())
->method('canChangePassword')
public function testLoginWithValidCredentials() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
- $user = $this->createMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
$password = 'secret';
$indexPageUrl = \OC_Util::getDefaultPageUrl();
public function testLoginWithoutPassedCsrfCheckAndNotLoggedIn() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
- $user = $this->createMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('jane'));
public function testLoginWithoutPassedCsrfCheckAndLoggedIn() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
- $user = $this->createMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('jane'));
public function testLoginWithValidCredentialsAndRedirectUrl() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
- $user = $this->createMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('jane'));
public function testLoginWithTwoFactorEnforced() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
- $user = $this->createMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('john'));
public function testToNotLeakLoginName() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
- $user = $this->createMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('john'));