public function testGigyaWillTriggerSubscriberOnlyWhenItIsAddedInARequest() { $handler = $this->setupHandler(); $client = new Gigya('key', 'secret', null, null, ['guzzle' => ['handler' => $handler]]); $client->accounts()->getAccountInfo(); $called = 0; $fn = function (callable $handler) use(&$called) { return function (RequestInterface $request, $options) use($handler, &$called) { $called++; return $handler($request, $options); }; }; $client->addHandler($fn); $client->accounts()->getAccountInfo(); $this->assertEquals(1, $called); $client->removeHandler($fn); $client->accounts()->getAccountInfo(); $this->assertEquals(1, $called); }