/**
  * Test buildCertificates().
  *
  * @param Certificate $certificate
  *
  * @dataProvider certificateProvider
  */
 public function testBuildCertificates(Certificate $certificate)
 {
     $this->_builder->setCertificates(array($certificate))->buildCertificates();
     if ($certificate->getDomain()->count() < 1) {
         $this->assertEmpty($certificate->getCertificateFilePath());
     } else {
         $this->assertNotEmpty($certificate->getCertificateFilePath());
     }
 }
 /**
  * Save certificates.
  * For Lighttpd, merge some files into others.
  *
  * @param Certificate $certificate
  */
 public function saveCertificate(Certificate $certificate)
 {
     $fs = new Filesystem();
     parent::saveCertificate($certificate);
     /**
      * Merge Key into Cert-File,
      * and merge Chain into CA-Cert file.
      */
     $keyfile = $certificate->getCertificateKeyFilePath();
     $chainfile = $certificate->getCertificateChainFilePath();
     $cafilepath = $certificate->getCACertificateFilePath();
     $certfilepath = $certificate->getCertificateFilePath();
     if (!empty($keyfile) && $fs->exists($certfilepath)) {
         file_put_contents($certfilepath, PHP_EOL . file_get_contents($keyfile), FILE_APPEND);
     }
     if (!empty($chainfile) && $fs->exists($cafilepath)) {
         file_put_contents($cafilepath, PHP_EOL . file_get_contents($chainfile), FILE_APPEND);
     }
 }