public function testJSONDecoder() { $multi_curl = new MultiCurl(); $multi_curl->setHeader('X-DEBUG-TEST', 'json_response'); $multi_curl->setJsonDecoder(function ($response) { return 'foo'; }); $get_1 = $multi_curl->addGet(Test::TEST_URL); $get_1->complete(function ($instance) { PHPUnit_Framework_Assert::assertInstanceOf('Curl\\Curl', $instance); PHPUnit_Framework_Assert::assertEquals('foo', $instance->response); }); $get_2 = $multi_curl->addGet(Test::TEST_URL); $get_2->beforeSend(function ($instance) { $instance->setJsonDecoder(function ($response) { return 'bar'; }); }); $get_2->complete(function ($instance) { PHPUnit_Framework_Assert::assertInstanceOf('Curl\\Curl', $instance); PHPUnit_Framework_Assert::assertEquals('bar', $instance->response); }); $multi_curl->start(); $this->assertEquals('foo', $get_1->response); $this->assertEquals('bar', $get_2->response); }