From 006eb30d1a5c803bb47baa07f048d13571990ec2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 26 Jan 2012 13:53:45 +0100 Subject: [PATCH] Fix Printer unit tests --- .../Phrasea/Controller/Prod/Printer.php | 2 +- lib/Alchemy/Phrasea/Out/Module/PDF.php | 2 +- .../Phrasea/Controller/Prod/PrinterTest.php | 36 +++++++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php index faf4f46f6f..d4579575c5 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php @@ -48,7 +48,7 @@ class Printer implements ControllerProviderInterface $controllers->post('/print.pdf', function(Application $app) { - $printer = new RecordHelper\Printer($app['Core']); + $printer = new RecordHelper\Printer($app['Core'], $app['request']); $request = $app['request']; diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index 76ecb7bc6d..5e84e26027 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -270,7 +270,7 @@ class PDF $y = $this->pdf->GetY(); - $t = phrasea::bas_names($rec->get_base_id()); + $t = \phrasea::bas_names($rec->get_base_id()); $this->pdf->SetFont(PhraseaPDF::FONT, '', 10); $this->pdf->SetFillColor(220, 220, 220); $this->pdf->SetLeftMargin($lmargin); diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php index ae47110ae7..e97c65f366 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/PrinterTest.php @@ -45,8 +45,8 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteSlash() { $records = array( - self::$record_1->get_serialize_key(), - self::$record_2->get_serialize_key() + self::$record_1->get_serialize_key(), + self::$record_2->get_serialize_key() ); $lst = implode(';', $records); @@ -60,27 +60,35 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRoutePrintPdf() { - - $this->markTestSkipped("Undefined variable: k_path_url \n /Users/nicolasl/workspace/phraseanet/lib/vendor/tcpdf/config/tcpdf_config.php:75"); - $records = array( - self::$record_1->get_serialize_key(), - self::$record_2->get_serialize_key() + self::$record_1->get_serialize_key(), + self::$record_2->get_serialize_key() ); $lst = implode(';', $records); - $crawler = $this->client->request('POST', '/printer/print.pdf', array( - 'lst' => $lst, - 'lay' => \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEW - ) + $layouts = array( + \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEW, + \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTION, + \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTIONTDM, + \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILLIST, + \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILGRID ); - $response = $this->client->getResponse(); + foreach ($layouts as $layout) + { + $crawler = $this->client->request('POST', '/printer/print.pdf', array( + 'lst' => $lst, + 'lay' => $layout + ) + ); - $this->assertEquals("application/pdf", $response->headers->get("content-type")); + $response = $this->client->getResponse(); - $this->assertTrue($response->isOk()); + $this->assertEquals("application/pdf", $response->headers->get("content-type")); + + $this->assertTrue($response->isOk()); + } } }