/**
  * @param string               $msg
  * @param SignatureWriter|null $signature
  */
 protected function addSignatureToUrl(&$msg, SignatureWriter $signature = null)
 {
     /** @var $key XMLSecurityKey */
     $key = $signature ? $signature->getXmlSecurityKey() : null;
     if (null != $key) {
         $msg .= '&SigAlg=' . urlencode($key->type);
         $signature = $key->signData($msg);
         $msg .= '&Signature=' . urlencode(base64_encode($signature));
     }
 }
 public function test_returns_set_key()
 {
     $writer = new SignatureWriter();
     $writer->setXmlSecurityKey($key = TestHelper::getXmlSecurityKeyMock($this));
     $this->assertSame($key, $writer->getXmlSecurityKey());
 }