]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use getMockBuilder instead of createMock 894/head
authorLukas Reschke <lukas@statuscode.ch>
Tue, 16 Aug 2016 19:36:59 +0000 (21:36 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Tue, 16 Aug 2016 19:36:59 +0000 (21:36 +0200)
tests/Core/Controller/LoginControllerTest.php

index 0f3945efd48f1fc059d79005ea7937572fd88398..8eaa7c9843b652f6ce123ace98b0f4c09a440cbf 100644 (file)
@@ -57,14 +57,14 @@ class LoginControllerTest extends TestCase {
 
        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();
@@ -110,7 +110,7 @@ class LoginControllerTest extends TestCase {
                        ->method('getCookie')
                        ->with('oc_token')
                        ->willReturn('MyLoginToken');
-               $user = $this->createMock('\\OCP\\IUser');
+               $user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
                $user
                        ->expects($this->once())
                        ->method('getUID')
@@ -218,7 +218,7 @@ class LoginControllerTest extends TestCase {
                        ->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')
@@ -257,7 +257,7 @@ class LoginControllerTest extends TestCase {
                        ->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')
@@ -329,7 +329,7 @@ class LoginControllerTest extends TestCase {
 
        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();
 
@@ -370,7 +370,7 @@ class LoginControllerTest extends TestCase {
 
        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'));
@@ -405,7 +405,7 @@ class LoginControllerTest extends TestCase {
 
        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'));
@@ -445,7 +445,7 @@ class LoginControllerTest extends TestCase {
 
        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'));
@@ -492,7 +492,7 @@ class LoginControllerTest extends TestCase {
        
        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'));
@@ -543,7 +543,7 @@ class LoginControllerTest extends TestCase {
 
        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'));