Skip to content

Commit e543d0a

Browse files
committed
Replace dataProvider with separate methods
1 parent 52a66ac commit e543d0a

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

app/code/Magento/Reports/Test/Unit/Observer/EventSaverTest.php

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -116,41 +116,30 @@ public function testSaveWithSubject()
116116
}
117117

118118
/**
119-
* Test save with no subject ID provided
120-
*
121-
* @param bool $isLoggedIn
122-
* @dataProvider dataProviderTestSaveWithoutSubject
119+
* Test save with no subject ID provided and customer is logged in
123120
*/
124-
public function testSaveWithoutSubject(bool $isLoggedIn)
121+
public function testSaveWithoutSubjectWhenLoggedIn()
125122
{
126-
if ($isLoggedIn) {
127-
$this->customerSessionMock->expects($this->once())
128-
->method('isLoggedIn')
129-
->willReturn(true);
130-
$this->customerSessionMock->expects($this->once())
131-
->method('getCustomerId')
132-
->willReturn(1);
133-
} else {
134-
$this->customerSessionMock->expects($this->once())
135-
->method('isLoggedIn')
136-
->willReturn(false);
137-
$this->customerVisitorMock->expects($this->once())
138-
->method('getId')
139-
->willReturn(2);
140-
}
123+
$this->customerSessionMock->expects($this->once())
124+
->method('isLoggedIn')
125+
->willReturn(true);
126+
$this->customerSessionMock->expects($this->once())
127+
->method('getCustomerId')
128+
->willReturn(1);
141129
$this->eventSaver->save(1, 1, null);
142130
}
143131

144132
/**
145-
* Data provider for a case without subjectId provided
146-
*
147-
* @return array
133+
* Test save with no subject ID provided and customer is not logged in
148134
*/
149-
public function dataProviderTestSaveWithoutSubject()
135+
public function testSaveWithoutSubjectForGuest()
150136
{
151-
return [
152-
[true],
153-
[false]
154-
];
137+
$this->customerSessionMock->expects($this->once())
138+
->method('isLoggedIn')
139+
->willReturn(false);
140+
$this->customerVisitorMock->expects($this->once())
141+
->method('getId')
142+
->willReturn(2);
143+
$this->eventSaver->save(1, 1, null);
155144
}
156145
}

0 commit comments

Comments
 (0)