Ejemplo n.º 1
0
 public function testCredentials()
 {
     $proxy = new CurlProxy();
     $this->assertFalse($proxy->hasCredentials());
     $credentials = new BasicCredentials();
     $credentials->setUserName('foo');
     $credentials->setPassword('bar');
     $proxy->setCredentials($credentials);
     $this->assertInstanceOf(BasicCredentials::class, $proxy->getCredentials());
     $this->assertSame('foo:bar', $proxy->getFormattedCredentials());
     $this->assertSame('foo', $proxy->getCredentials()->getUserName());
     $this->assertSame('bar', $proxy->getCredentials()->getPassword());
     $this->assertSame([CURLOPT_PROXYUSERNAME => 'foo', CURLOPT_PROXYPASSWORD => 'bar'], $proxy->getOptions());
 }
Ejemplo n.º 2
0
 /**
  * @param BasicCredentials $credentials
  *
  * @return $this
  */
 public function setCredentials(BasicCredentials $credentials)
 {
     $this->getCurl()->setOption(CURLOPT_USERPWD, $credentials->getUserName() . ':' . $credentials->getPassword());
     return $this;
 }
Ejemplo n.º 3
0
 public function testSimple3()
 {
     $credentials = new BasicCredentials('foo', 'bar');
     $this->assertSame('foo', $credentials->getUserName());
     $this->assertSame('bar', $credentials->getPassword());
 }