Skip to content

Commit 1ad364e

Browse files
committed
Simplify phpunit's ->will($this->returnValue()) with ->willReturn()
1 parent 6d2aaf2 commit 1ad364e

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

src/Common/Tests/TimedGeocoderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testGeocode(): void
4747
{
4848
$this->delegate->expects($this->once())
4949
->method('geocodeQuery')
50-
->will($this->returnValue(new AddressCollection([])));
50+
->willReturn(new AddressCollection([]));
5151

5252
$this->geocoder->geocode('foo');
5353

@@ -74,7 +74,7 @@ public function testReverse(): void
7474
{
7575
$this->delegate->expects($this->once())
7676
->method('reverseQuery')
77-
->will($this->returnValue(new AddressCollection([])));
77+
->willReturn(new AddressCollection([]));
7878

7979
$this->geocoder->reverse(0, 0);
8080

src/Provider/Chain/Tests/ChainTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testReverse(): void
5353
$result = new AddressCollection(['foo' => 'bar']);
5454
$mockTwo->expects($this->once())
5555
->method('reverseQuery')
56-
->will($this->returnValue($result));
56+
->willReturn($result);
5757

5858
$chain = new Chain([$mockOne, $mockTwo]);
5959

@@ -75,7 +75,7 @@ public function testGeocode(): void
7575
$mockTwo->expects($this->once())
7676
->method('geocodeQuery')
7777
->with($query)
78-
->will($this->returnValue($result));
78+
->willReturn($result);
7979

8080
$chain = new Chain([$mockOne, $mockTwo]);
8181

src/Provider/GeoIP2/Tests/GeoIP2AdapterTest.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ public function testIpAddressIsPassedCorrectToReader(string $geoIp2Model): void
8686
->expects($this->once())
8787
->method($geoIp2Model)
8888
->with('127.0.0.1')
89-
->will($this->returnValue(
90-
$this->getGeoIP2ModelMock($geoIp2Model)
91-
));
89+
->willReturn($this->getGeoIP2ModelMock($geoIp2Model));
9290

9391
$adapter = new GeoIP2Adapter($geoIp2Provider, $geoIp2Model);
9492
$adapter->getContent('file://geoip?127.0.0.1');
@@ -110,7 +108,7 @@ public function testReaderResponseIsJsonEncoded(): void
110108
$geoIp2Provider
111109
->expects($this->any())
112110
->method('city')
113-
->will($this->returnValue($cityModel));
111+
->willReturn($cityModel);
114112

115113
$adapter = new GeoIP2Adapter($geoIp2Provider);
116114

@@ -145,23 +143,21 @@ protected function getGeoIP2ModelMock($geoIP2Model)
145143
$mock
146144
->expects($this->any())
147145
->method('jsonSerialize')
148-
->will($this->returnValue(
149-
[
150-
'city' => [
151-
'geoname_id' => 2911298,
152-
'names' => [
153-
'de' => 'Hamburg',
154-
'en' => 'Hamburg',
155-
'es' => 'Hamburgo',
156-
'fr' => 'Hambourg',
157-
'ja' => 'ハンブルク',
158-
'pt-BR' => 'Hamburgo',
159-
'ru' => 'Гамбург',
160-
'zh-CN' => '汉堡市',
161-
],
146+
->willReturn([
147+
'city' => [
148+
'geoname_id' => 2911298,
149+
'names' => [
150+
'de' => 'Hamburg',
151+
'en' => 'Hamburg',
152+
'es' => 'Hamburgo',
153+
'fr' => 'Hambourg',
154+
'ja' => 'ハンブルク',
155+
'pt-BR' => 'Hamburgo',
156+
'ru' => 'Гамбург',
157+
'zh-CN' => '汉堡市',
162158
],
163-
]
164-
));
159+
],
160+
]);
165161

166162
return $mock;
167163
}

0 commit comments

Comments
 (0)