Skip to content

Commit d30e5e2

Browse files
committed
refactor unit test
1 parent 4595009 commit d30e5e2

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

app/code/Magento/Customer/Test/Unit/Model/ForgotPasswordToken/GetCustomerByTokenTest.php

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,41 @@
2020
use PHPUnit\Framework\MockObject\MockObject;
2121
use PHPUnit\Framework\TestCase;
2222

23-
/**
24-
* Test GetCustomerByToken class
25-
*/
2623
class GetCustomerByTokenTest extends TestCase
2724
{
28-
protected const RESET_PASSWORD = 'resetPassword';
25+
private const RESET_PASSWORD = 'resetPassword';
2926

3027
/**
3128
* @var SearchCriteriaBuilder|MockObject
3229
*/
33-
protected $searchCriteriaBuilderMock;
30+
private $searchCriteriaBuilderMock;
3431

3532
/**
3633
* @var SearchCriteria|MockObject
3734
*/
38-
protected $searchCriteriaMock;
35+
private $searchCriteriaMock;
3936

4037
/**
4138
* @var CustomerRepositoryInterface|MockObject
4239
*/
43-
protected $customerRepositoryMock;
40+
private $customerRepositoryMock;
4441

4542
/**
4643
* @var CustomerSearchResultsInterface|MockObject
4744
*/
48-
protected $searchResultMock;
45+
private $searchResultMock;
4946

5047
/**
5148
* @var CustomerInterface|MockObject
5249
*/
53-
protected $customerMock;
50+
private $customerMock;
5451

5552
/**
5653
* @var GetCustomerByToken;
5754
*/
58-
protected $model;
55+
private $model;
5956

60-
/**
61-
* @inheritDoc
62-
*/
63-
public function setUp()
57+
protected function setUp()
6458
{
6559
$this->searchCriteriaBuilderMock = $this->createMock(SearchCriteriaBuilder::class);
6660
$this->searchCriteriaMock = $this->createMock(SearchCriteria::class);
@@ -86,15 +80,10 @@ public function setUp()
8680
->willReturn($this->searchResultMock);
8781
}
8882

89-
/**
90-
* @return void
91-
*/
92-
public function testExecute(): void
83+
public function testExecuteReturnWhenOneItemAvailable(): void
9384
{
9485
$totalCount = 1;
95-
$this->searchResultMock->expects($this->any())
96-
->method('getTotalCount')
97-
->willReturn($totalCount);
86+
$this->searchResultMock->method('getTotalCount')->willReturn($totalCount);
9887
$this->searchResultMock->expects($this->once())
9988
->method('getItems')
10089
->willReturn([$this->customerMock]);
@@ -105,15 +94,10 @@ public function testExecute(): void
10594
);
10695
}
10796

108-
/**
109-
* @return void
110-
*/
11197
public function testExecuteWithNoSuchEntityException(): void
11298
{
11399
$totalCount = 0;
114-
$this->searchResultMock->expects($this->any())
115-
->method('getTotalCount')
116-
->willReturn($totalCount);
100+
$this->searchResultMock->method('getTotalCount')->willReturn($totalCount);
117101
$this->expectExceptionObject(new NoSuchEntityException(
118102
new Phrase(
119103
'No such entity with rp_token = %value',
@@ -124,15 +108,10 @@ public function testExecuteWithNoSuchEntityException(): void
124108
$this->model->execute(self::RESET_PASSWORD);
125109
}
126110

127-
/**
128-
* @return void
129-
*/
130111
public function testExecuteWithExpireException(): void
131112
{
132113
$totalCount = 2;
133-
$this->searchResultMock->expects($this->any())
134-
->method('getTotalCount')
135-
->willReturn($totalCount);
114+
$this->searchResultMock->method('getTotalCount')->willReturn($totalCount);
136115

137116
$this->expectExceptionObject(new ExpiredException(
138117
new Phrase(

0 commit comments

Comments
 (0)