FrDeamon / EnseparHtml2pdfBundle

Html2pdf for Symfony 2 as a service.
MIT License
22 stars 22 forks source link

Feature/sf4 support #34

Closed olix21 closed 5 years ago

olix21 commented 5 years ago

Based on the work of @taluu.

This PR enables the Symfony >= 4.0 support

OwlyCode commented 5 years ago

Hello there, I was able to run the tests for older php versions when applying this to your PR :

diff --git Tests/Functional/FunctionalTest.php Tests/Functional/FunctionalTest.php
index f66f1df..89579c7 100644
--- Tests/Functional/FunctionalTest.php
+++ Tests/Functional/FunctionalTest.php
@@ -2,11 +2,15 @@

 namespace Ensepar\Html2pdfBundle\Tests\Functional;

+use Ensepar\Html2pdfBundle\Tests\Fixtures\AppKernel;
 use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

 class FunctionalTest extends KernelTestCase
 {
-    protected static $container;
+    public static function getKernelClass()
+    {
+        return 'Ensepar\Html2pdfBundle\Tests\Fixtures\AppKernel';
+    }

     /**
      * We make sure multiple calls are OK.
@@ -17,7 +21,7 @@ class FunctionalTest extends KernelTestCase
     {
         static::bootKernel();

-        $factory = static::$container->get('html2pdf_factory');
+        $factory = static::$kernel->getContainer()->get('html2pdf_factory');

         $pdf1 = $factory->create();
         $pdf1->writeHTML("<html><body><p>foo</p></body></html>");
diff --git phpunit.xml.dist phpunit.xml.dist
index 47abff4..4cff6c9 100644
--- phpunit.xml.dist
+++ phpunit.xml.dist
@@ -14,7 +14,7 @@

     <php>
         <env name="KERNEL_CLASS" value="Ensepar\Html2pdfBundle\Tests\Fixtures\AppKernel" />
-        <env name="KERNEL_DIR" value="Tests\Fixtures" />
+        <env name="KERNEL_DIR" value="Tests/Fixtures" />
     </php>

     <testsuites>
OwlyCode commented 5 years ago

LGTM! I'll merge this along #33 so both of you get credited for the work. Thank you for this!

OwlyCode commented 5 years ago

This PR got cherry picked into the master here : https://github.com/OwlyCode/EnseparHtml2pdfBundle/commit/8d8aeb419ef4d97e2a614a43770bf224c17704d9 (I had to do this so @Taluu's work would get into master too). Thank you for contributing and pushing for this subject to get done!

olix21 commented 5 years ago

Great! I close the PR