Skip to content

Commit d856907

Browse files
committed
Fix phpunit warnings
1 parent e76db6a commit d856907

File tree

6 files changed

+17
-34
lines changed

6 files changed

+17
-34
lines changed

Tests/Command/ChangePasswordCommandTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ public function testExecuteInteractiveWithQuestionHelper()
4242
->setMethods(['ask'])
4343
->getMock();
4444

45-
$helper->expects($this->at(0))
45+
$helper->expects($this->exactly(2))
4646
->method('ask')
47-
->will($this->returnValue('user'));
48-
$helper->expects($this->at(1))
49-
->method('ask')
50-
->will($this->returnValue('pass'));
47+
->willReturnOnConsecutiveCalls('user', 'pass');
5148

5249
$application->getHelperSet()->set($helper, 'question');
5350

Tests/Command/CreateUserCommandTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,9 @@ public function testExecuteInteractiveWithQuestionHelper()
4343
->setMethods(['ask'])
4444
->getMock();
4545

46-
$helper->expects($this->at(0))
46+
$helper->expects($this->exactly(3))
4747
->method('ask')
48-
->will($this->returnValue('user'));
49-
50-
$helper->expects($this->at(1))
51-
->method('ask')
52-
->will($this->returnValue('email'));
53-
54-
$helper->expects($this->at(2))
55-
->method('ask')
56-
->will($this->returnValue('pass'));
48+
->willReturnOnConsecutiveCalls('user', 'email', 'pass');
5749

5850
$application->getHelperSet()->set($helper, 'question');
5951

Tests/Command/DeactivateUserCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function testExecuteInteractiveWithQuestionHelper()
4141
->setMethods(['ask'])
4242
->getMock();
4343

44-
$helper->expects($this->at(0))
44+
$helper->expects($this->once())
4545
->method('ask')
46-
->will($this->returnValue('user'));
46+
->willReturn('user');
4747

4848
$application->getHelperSet()->set($helper, 'question');
4949

Tests/Command/DemoteUserCommandTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ public function testExecuteInteractiveWithQuestionHelper()
4242
->setMethods(['ask'])
4343
->getMock();
4444

45-
$helper->expects($this->at(0))
45+
$helper->expects($this->exactly(2))
4646
->method('ask')
47-
->will($this->returnValue('user'));
48-
$helper->expects($this->at(1))
49-
->method('ask')
50-
->will($this->returnValue('role'));
47+
->willReturnOnConsecutiveCalls('user', 'role');
5148

5249
$application->getHelperSet()->set($helper, 'question');
5350

Tests/Command/PromoteUserCommandTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ public function testExecuteInteractiveWithQuestionHelper()
4242
->setMethods(['ask'])
4343
->getMock();
4444

45-
$helper->expects($this->at(0))
45+
$helper->expects($this->exactly(2))
4646
->method('ask')
47-
->will($this->returnValue('user'));
48-
$helper->expects($this->at(1))
49-
->method('ask')
50-
->will($this->returnValue('role'));
47+
->willReturnOnConsecutiveCalls('user', 'role');
5148

5249
$application->getHelperSet()->set($helper, 'question');
5350

Tests/Model/UserManagerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ public function testFindUserByUsernameOrEmailWithUsernameThatLooksLikeEmail()
144144
$usernameThatLooksLikeEmail = 'bob@example.com';
145145
$user = $this->getUser();
146146

147-
$this->manager->expects($this->at(0))
147+
$this->manager->expects($this->exactly(2))
148148
->method('findUserBy')
149-
->with($this->equalTo(['emailCanonical' => $usernameThatLooksLikeEmail]))
150-
->will($this->returnValue(null));
149+
->withConsecutive(
150+
[$this->equalTo(['emailCanonical' => $usernameThatLooksLikeEmail])],
151+
[$this->equalTo(['usernameCanonical' => $usernameThatLooksLikeEmail])]
152+
)
153+
->willReturnOnConsecutiveCalls(null, $user);
154+
151155
$this->fieldsUpdater->expects($this->once())
152156
->method('canonicalizeEmail')
153157
->with($usernameThatLooksLikeEmail)
154158
->willReturn($usernameThatLooksLikeEmail);
155159

156-
$this->manager->expects($this->at(1))
157-
->method('findUserBy')
158-
->with($this->equalTo(['usernameCanonical' => $usernameThatLooksLikeEmail]))
159-
->will($this->returnValue($user));
160160
$this->fieldsUpdater->expects($this->once())
161161
->method('canonicalizeUsername')
162162
->with($usernameThatLooksLikeEmail)

0 commit comments

Comments
 (0)