public function onError(ErrorEvent $event, $name) { if ($event->getResponse()->getStatusCode() == 401) { $params = ['userName' => $this->credentials->getUsername(), 'password' => $this->credentials->getPassword(), 'createPersistentCookie' => 'false']; $this->commandClient->getCookie($params, ['http' => ['cookies' => true]]); $newResponse = $event->getClient()->send($event->getRequest()); // Intercept the original transaction with the new response $event->intercept($newResponse); } }
public function testHasGetters() { $creds = new Credentials('foo', 'baz', 'tok', 'foo-baz', '1.0.0'); $this->assertEquals('foo', $creds->getUsername()); $this->assertEquals('baz', $creds->getPassword()); $this->assertEquals('tok', $creds->getSubscriptionToken()); $this->assertEquals('foo-baz', $creds->getVendor()); $this->assertEquals('1.0.0', $creds->getVersion()); $this->assertEquals(['Username' => 'foo', 'Password' => 'baz', 'SubscriptionToken' => 'tok', 'Vendor' => 'foo-baz', 'Version' => '1.0.0'], $creds->toArray()); }