private function checkDeserializaton(\DOMElement $root, $entityID, $locationLogout, $locationLogin, X509Certificate $certificate)
 {
     $ed = new EntityDescriptor();
     $ed->loadFromXml($root);
     $this->assertEquals($entityID, $ed->getEntityID());
     $items = $ed->getItems();
     $this->assertEquals(2, count($items));
     $this->assertTrue($items[0] instanceof SpSsoDescriptor);
     $arrSP = $ed->getItemsByType('SpSsoDescriptor');
     $this->assertNotEmpty($arrSP);
     /** @var $sp SpSsoDescriptor */
     $sp = $arrSP[0];
     $this->assertNotNull($sp);
     $this->assertTrue($sp instanceof SpSsoDescriptor);
     $keys = $sp->getKeyDescriptors();
     $this->assertEquals(2, count($keys));
     $this->assertEquals(KeyDescriptor::USE_SIGNING, $keys[0]->getUse());
     $this->assertEquals($certificate->getData(), $keys[0]->getCertificate()->getData());
     $this->assertEquals(KeyDescriptor::USE_ENCRYPTION, $keys[1]->getUse());
     $this->assertEquals($certificate->getData(), $keys[1]->getCertificate()->getData());
     $this->assertEquals(Protocol::SAML2, $sp->getProtocolSupportEnumeration());
     $items = $sp->getServices();
     $this->assertEquals(3, count($items), print_r($items, true));
     $arrLogout = $sp->findSingleLogoutServices();
     $this->assertNotEmpty($arrLogout);
     $logout = $arrLogout[0];
     $this->assertNotNull($logout);
     $this->assertEquals(Bindings::SAML2_HTTP_REDIRECT, $logout->getBinding());
     $this->assertEquals($locationLogout, $logout->getLocation());
     $arr = $sp->findAssertionConsumerServices();
     $this->assertEquals(2, count($arr));
     $arr = $sp->findAssertionConsumerServices(Bindings::SAML2_HTTP_POST);
     $this->assertNotEmpty($arr);
     $as1 = $arr[0];
     $this->assertNotNull($as1);
     $this->assertEquals(Bindings::SAML2_HTTP_POST, $as1->getBinding());
     $this->assertEquals($locationLogin, $as1->getLocation());
     $this->assertEquals(0, $as1->getIndex());
     $arr = $sp->findAssertionConsumerServices(Bindings::SAML2_HTTP_ARTIFACT);
     $this->assertNotEmpty($arr);
     $as2 = $arr[0];
     $this->assertNotNull($as2);
     $this->assertEquals(Bindings::SAML2_HTTP_ARTIFACT, $as2->getBinding());
     $this->assertEquals($locationLogin, $as2->getLocation());
     $this->assertEquals(1, $as2->getIndex());
 }