/** * * @group pdf-model */ public function test_generate_pdf_parameters() { global $gfpdf; /* * Set up first data batch */ $template = isset($gfpdf->configuration[5]['template']) ? $gfpdf->configuration[5]['template'] : ''; $arg = GFPDF_Core_Model::generate_pdf_parameters(5, $this->form_id[0], 453, $template); /* * Run tests */ $this->assertEquals('My Filename.pdf', $arg['pdfname']); $this->assertEquals('test-template.php', $arg['template']); $this->assertEquals('A5', $arg['pdf_size']); $this->assertEquals('landscape', $arg['orientation']); $this->assertEquals(false, $arg['security']); $this->assertEquals(3, sizeof($arg['pdf_privileges'])); $this->assertEquals('test123', $arg['pdf_password']); $this->assertEquals('masterpass123', $arg['pdf_master_password']); $this->assertEquals(true, $arg['rtl']); $this->assertEquals(true, $arg['premium']); $this->assertEquals(300, $arg['dpi']); $this->assertEquals(true, $arg['pdfa1b']); $this->assertEquals(true, $arg['pdfx1a']); /* * Set up second data branch */ $template = isset($gfpdf->configuration[6]['template']) ? $gfpdf->configuration[6]['template'] : ''; $arg = GFPDF_Core_Model::generate_pdf_parameters(6, $this->form_id[0], 453, $template); /* * Run tests */ $this->assertEquals('form-1-entry-453.pdf', $arg['pdfname']); $this->assertEquals('default-template.php', $arg['template']); $this->assertEquals('A4', $arg['pdf_size']); $this->assertEquals('portrait', $arg['orientation']); $this->assertEquals(false, $arg['security']); $this->assertEquals(0, sizeof($arg['pdf_privileges'])); $this->assertEquals('', $arg['pdf_password']); $this->assertEquals('', $arg['pdf_master_password']); $this->assertEquals(false, $arg['rtl']); $this->assertEquals(false, $arg['premium']); $this->assertEquals('', $arg['dpi']); $this->assertEquals(false, $arg['pdfa1b']); $this->assertEquals(false, $arg['pdfx1a']); /* * Set up third data branch test */ global $gf_pdf_default_configuration; /* * Reset the default config values and recalculate them */ $gf_pdf_default_configuration = array('template' => 'default-template-no-style.php', 'pdf_size' => 'A6', 'orientation' => 'landscape', 'premium' => true, 'dpi' => 300); $this->setupConfiguration(); $template = isset($gfpdf->configuration[6]['template']) ? $gfpdf->configuration[6]['template'] : ''; $arg = GFPDF_Core_Model::generate_pdf_parameters(6, $this->form_id[0], 1, $template); /* * Run our tests */ $this->AssertEquals('form-1-entry-1.pdf', $arg['pdfname']); $this->AssertEquals('default-template-no-style.php', $arg['template']); $this->AssertEquals('A6', $arg['pdf_size']); $this->AssertEquals('landscape', $arg['orientation']); $this->AssertEquals(false, $arg['security']); $this->AssertEquals(0, sizeof($arg['pdf_privileges'])); $this->AssertEquals('', $arg['pdf_password']); $this->AssertEquals('', $arg['pdf_master_password']); $this->AssertEquals(false, $arg['rtl']); $this->AssertEquals(true, $arg['premium']); $this->AssertEquals(300, $arg['dpi']); $this->AssertEquals(false, $arg['pdfa1b']); $this->AssertEquals(false, $arg['pdfx1a']); }