Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4073af8

Browse files
committed
Fixed the tests and use stable version of php-cache
1 parent 4384689 commit 4073af8

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
"php-http/mock-client": "^1.0",
3434
"nyholm/psr7": "^0.2.2",
3535
"nyholm/nsa": "^1.1",
36-
"cache/simple-cache-bridge": "^0.1.1",
37-
"cache/array-adapter": "^0.5.0",
38-
"cache/void-adapter": "^0.4.1"
36+
"cache/simple-cache-bridge": "^1.0",
37+
"cache/array-adapter": "^1.0",
38+
"cache/void-adapter": "^1.0"
3939
},
4040
"suggest": {
4141
"ext-geoip": "Enabling the geoip extension allows you to use the MaxMindProvider.",
@@ -55,6 +55,7 @@
5555
"test": "vendor/bin/phpunit"
5656
},
5757
"minimum-stability": "dev",
58+
"prefer-dist": true,
5859
"extra": {
5960
"branch-alias": {
6061
"dev-master": "4.0-dev"

src/Plugin/Tests/Plugin/CachePluginTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testPluginMiss()
2424
{
2525
$ttl = 4711;
2626
$query = GeocodeQuery::create('foo');
27-
$queryString = $query->__toString();
27+
$queryString = sha1($query->__toString());
2828
$cache = $this->getMockBuilder(VoidCachePool::class)
2929
->disableOriginalConstructor()
3030
->setMethods(['get', 'set'])
@@ -53,7 +53,7 @@ public function testPluginMiss()
5353
public function testPluginHit()
5454
{
5555
$query = GeocodeQuery::create('foo');
56-
$queryString = $query->__toString();
56+
$queryString = sha1($query->__toString());
5757
$cache = $this->getMockBuilder(VoidCachePool::class)
5858
->disableOriginalConstructor()
5959
->setMethods(['get', 'set'])

src/Plugin/Tests/PluginProviderTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,12 @@ public function testLoopException()
115115
{
116116
$this->expectException(LoopException::class);
117117
$geocodeQuery = GeocodeQuery::create('foo');
118-
$collection = new AddressCollection([]);
119118

120119
$provider = $this->getMockBuilder(Provider::class)
121120
->disableOriginalConstructor()
122121
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
123122
->getMock();
124-
$provider->expects($this->once())
125-
->method('geocodeQuery')
126-
->with($geocodeQuery)
127-
->willReturn($collection);
123+
$provider->expects($this->never())->method('geocodeQuery');
128124
$provider->expects($this->never())->method('reverseQuery');
129125
$provider->expects($this->never())->method('getName');
130126

@@ -133,13 +129,23 @@ public function testLoopException()
133129
->setMethods(['handleQuery'])
134130
->getMock();
135131
$pluginA->expects($this->any())
132+
->method('handleQuery')
133+
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
134+
->willReturnCallback(function (Query $query, callable $next, callable $first) {
135+
return $next($query);
136+
});
137+
$pluginB = $this->getMockBuilder(Plugin::class)
138+
->disableOriginalConstructor()
139+
->setMethods(['handleQuery'])
140+
->getMock();
141+
$pluginB->expects($this->any())
136142
->method('handleQuery')
137143
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
138144
->willReturnCallback(function (Query $query, callable $next, callable $first) {
139145
return $first($query);
140146
});
141147

142-
$pluginProvider = new PluginProvider($provider, [$pluginA]);
148+
$pluginProvider = new PluginProvider($provider, [$pluginA, $pluginB]);
143149
$pluginProvider->geocodeQuery($geocodeQuery);
144150
}
145151
}

src/Plugin/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "^6.1",
24-
"cache/void-adapter": "^0.4.1"
24+
"cache/void-adapter": "^1.0"
2525
},
2626
"autoload": {
2727
"psr-4": { "Geocoder\\Plugin\\": "" },

0 commit comments

Comments
 (0)