Use getMockBuilder instead of createMock

This commit is contained in:
Lukas Reschke 2016-08-16 21:36:59 +02:00
parent 6ed721dde3
commit 1f177aa105
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
1 changed files with 14 additions and 14 deletions

View 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'));