File tree Expand file tree Collapse file tree 4 files changed +125
-21
lines changed
Expand file tree Collapse file tree 4 files changed +125
-21
lines changed Original file line number Diff line number Diff line change 8383});
8484
8585$ app ['get_pull_messages ' ] = $ app ->protect (function ($ clearMessages = false ) {
86- $ memcache = new Memcached ;
87- if ($ pullMessages = $ memcache ->get ('pull-messages ' )) {
86+ if ($ pullMessages = $ app ['memcache ' ]->get ('pull-messages ' )) {
8887 if ($ clearMessages ) {
89- $ memcache ->set ('pull-messages ' , []);
88+ $ app [ ' memcache ' ] ->set ('pull-messages ' , []);
9089 }
9190 return $ pullMessages ;
9291 }
9392 return [];
9493});
9594
9695$ app ['save_pull_message ' ] = $ app ->protect (function ($ message ) use ($ app ) {
97- $ memcache = new Memcached ;
9896 $ messages = $ app ['get_pull_messages ' ]();
9997 $ messages [] = $ message ;
100- $ memcache ->set ('pull-messages ' , $ messages );
98+ $ app [ ' memcache ' ] ->set ('pull-messages ' , $ messages );
10199});
102100
101+ $ app ['memcache ' ] = function () {
102+ return new Memcached ;
103+ };
104+
103105return $ app ;
Original file line number Diff line number Diff line change 88 },
99 "require-dev" : {
1010 "google/cloud-tools" : " <=1.0" ,
11+ "gecko-packages/gecko-memcache-mock" : " ^2.0" ,
1112 "paragonie/random_compat" : " ^2.0" ,
1213 "symfony/browser-kit" : " ~2.7" ,
1314 "symfony/css-selector" : " ~2.0" ,
1415 "symfony/dom-crawler" : " ~2.0" ,
15- "symfony/yaml" : " ^3.1"
16+ "symfony/yaml" : " ^3.1" ,
17+ "phpunit/phpunit" : " ~4.1"
1618 }
1719}
Original file line number Diff line number Diff line change 1919
2020use Silex \WebTestCase ;
2121use Symfony \Component \HttpKernel \Client ;
22+ use GeckoPackages \MemcacheMock \MemcachedMock ;
2223
2324class appTest extends WebTestCase
2425{
@@ -32,6 +33,8 @@ public function createApplication()
3233 $ app ['project_id ' ] = 'cloud-samples-tests-php ' ;
3334 $ app ['topic ' ] = getenv ('GOOGLE_PUBSUB_TOPIC ' );
3435 $ app ['subscription ' ] = getenv ('GOOGLE_PUBSUB_SUBSCRIPTION ' );
36+ $ app ['memcache ' ] = new MemcachedMock ;
37+ $ app ['memcache ' ]->addServer ("localhost " , 11211 );
3538
3639 // this will be set by travis, but may not be set locally
3740 if (!$ credentials = getenv ('GOOGLE_APPLICATION_CREDENTIALS ' )) {
You can’t perform that action at this time.
0 commit comments