public function test onCertificateRequested persists the certificate()
 {
     $dummyConfiguration = $this->prophesize(DomainConfiguration::class)->reveal();
     $dummyCertificate = $this->prophesize(Certificate::class)->reveal();
     $dummyDomainKeyPair = $this->prophesize(KeyPair::class)->reveal();
     $event = new CertificateEvent($dummyConfiguration, $dummyCertificate, $dummyDomainKeyPair);
     $this->mockRepository->persistCertificate($dummyConfiguration, $dummyCertificate, $dummyDomainKeyPair)->shouldBeCalled();
     $this->service->onCertificateRequested($event);
 }
 public function test persistCertificate persists the certificate file()
 {
     $dummyDomain = uniqid();
     $dummyCsr = $this->prophesize(CSR::class)->reveal();
     $dummyCertificate = $this->prophesize(Certificate::class)->reveal();
     $dummyDomainKeyPair = $this->prophesize(KeyPair::class)->reveal();
     $dummyCertificateFileName = uniqid();
     $dummyExtraFileName = uniqid();
     $dummyCertificateFileContent = uniqid();
     $dummyExtaFileContent = uniqid();
     $configuration = new DomainConfiguration($dummyDomain, $dummyCsr);
     $mockStorage = $this->prophesize(CertificateStorage::class);
     $this->mockStorageFactory->createCertificateStorage($dummyDomain)->willReturn($mockStorage->reveal());
     $mockStorage->backup()->shouldBeCalled();
     $this->mockCertificateFormatter->getName()->willReturn($dummyCertificateFileName);
     $this->mockCertificateFormatter->format($dummyCertificate, $dummyDomainKeyPair)->willReturn($dummyCertificateFileContent);
     $this->mockExtraFormatter->getName()->willReturn($dummyExtraFileName);
     $this->mockExtraFormatter->format($dummyCertificate, $dummyDomainKeyPair)->willReturn($dummyExtaFileContent);
     $mockStorage->saveCertificateFile($dummyCertificateFileName, $dummyCertificateFileContent)->shouldBeCalled();
     $mockStorage->saveCertificateFile($dummyExtraFileName, $dummyExtaFileContent)->shouldBeCalled();
     $this->service->persistCertificate($configuration, $dummyCertificate, $dummyDomainKeyPair);
 }
 /**
  * Triggered when a certificate is requested.
  *
  * @param CertificateEvent $event
  */
 public function onCertificateRequested(CertificateEvent $event)
 {
     $this->certificateRepository->persistCertificate($event->getDomainConfiguration(), $event->getCertificate(), $event->getDomainKeyPair());
 }