public function test createCertificateStorage returns an instance of CertificateStorage()
 {
     $domain = uniqid();
     $result = $this->service->createCertificateStorage($domain);
     $this->assertInstanceOf(CertificateStorage::class, $result);
     $reflection = new \ReflectionObject($result);
     $storagePathProperty = $reflection->getProperty('storagePath');
     $storagePathProperty->setAccessible(true);
     $this->assertSame($this->dummyStoragePath . '/' . $domain, $storagePathProperty->getValue($result));
 }
 public function test loadCertificate use parsers to parse certificate file content()
 {
     $dummyDomain = uniqid();
     $dummyCsr = $this->prophesize(CSR::class)->reveal();
     $dummyCertificate = $this->prophesize(Certificate::class)->reveal();
     $dummyDomainKeyPair = $this->prophesize(KeyPair::class)->reveal();
     $dummyCertificateFileContent = uniqid();
     $dummyCertificateMetadata = new CertificateMetadata($dummyDomain, uniqid(), (bool) rand(0, 1), uniqid(), [uniqid()]);
     $dummyCertificateFileName = uniqid();
     $configuration = new DomainConfiguration($dummyDomain, $dummyCsr);
     $mockStorage = $this->prophesize(CertificateStorage::class);
     $this->mockStorageFactory->createCertificateStorage($dummyDomain)->willReturn($mockStorage->reveal());
     $this->mockCertificateFormatter->getName()->willReturn($dummyCertificateFileName);
     $this->mockCertificateParser->parse($dummyCertificateFileContent)->shouldBeCalled()->willReturn($dummyCertificateMetadata);
     $mockStorage->loadCertificateFile($dummyCertificateFileName)->shouldBeCalled()->willReturn($dummyCertificateFileContent);
     $result = $this->service->loadCertificate($configuration, $dummyCertificate, $dummyDomainKeyPair);
     $this->assertSame(var_export($dummyCertificateMetadata, true), var_export($result, true));
 }
 /**
  * Return certificate's data.
  *
  * @param DomainConfiguration $configuration
  *
  * @return CertificateMetadata
  */
 public function loadCertificate(DomainConfiguration $configuration)
 {
     $storage = $this->storageFactory->createCertificateStorage($configuration->getDomain());
     return $this->certificateParser->parse($storage->loadCertificateFile($this->certificateFormatter->getName()));
 }