public function testBasicHttpAuthSuccess() { $username1 = 'myusername'; $password1 = 'mypassword'; $username2 = 'myotherusername'; $password2 = 'myotherpassword'; $multi_curl = new MultiCurl(); $multi_curl->setHeader('X-DEBUG-TEST', 'http_basic_auth'); $multi_curl->setBasicAuthentication($username1, $password1); $get_1 = $multi_curl->addGet(Test::TEST_URL); $get_1->complete(function ($instance) use($username1, $password1) { PHPUnit_Framework_Assert::assertInstanceOf('Curl\\Curl', $instance); PHPUnit_Framework_Assert::assertEquals($username1, $instance->response->username); PHPUnit_Framework_Assert::assertEquals($password1, $instance->response->password); }); $get_2 = $multi_curl->addGet(Test::TEST_URL); $get_2->beforeSend(function ($instance) use($username2, $password2) { $instance->setBasicAuthentication($username2, $password2); }); $get_2->complete(function ($instance) use($username2, $password2) { PHPUnit_Framework_Assert::assertInstanceOf('Curl\\Curl', $instance); PHPUnit_Framework_Assert::assertEquals($username2, $instance->response->username); PHPUnit_Framework_Assert::assertEquals($password2, $instance->response->password); }); $multi_curl->start(); $this->assertEquals(CURLAUTH_BASIC, $multi_curl->getOpt(CURLOPT_HTTPAUTH)); $this->assertEquals(CURLAUTH_BASIC, $get_1->getOpt(CURLOPT_HTTPAUTH)); $this->assertEquals($username1, $get_1->response->username); $this->assertEquals($password1, $get_1->response->password); $this->assertEquals(CURLAUTH_BASIC, $get_2->getOpt(CURLOPT_HTTPAUTH)); $this->assertEquals($username2, $get_2->response->username); $this->assertEquals($password2, $get_2->response->password); }