Update feature branch with develop

This commit is contained in:
Julio Cesar Laura Avendaño
2022-06-29 14:12:47 +00:00
31 changed files with 2314 additions and 290 deletions

View File

@@ -369,6 +369,8 @@ class ProcessesTest extends TestCase
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
'OUT_DOC_OPEN_TYPE' => 1,
'__OUT_DOC_ID_UPDATE__' => false,
'OUT_DOC_FOOTER' => null,
'OUT_DOC_HEADER' => null
],
[
'OUT_DOC_UID' => G::generateUniqueID(),
@@ -398,6 +400,8 @@ class ProcessesTest extends TestCase
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
'OUT_DOC_OPEN_TYPE' => 1,
'__OUT_DOC_ID_UPDATE__' => false,
'OUT_DOC_FOOTER' => null,
'OUT_DOC_HEADER' => null
]
];
$this->sortArrayByColumn($expected, 'OUT_DOC_UID');

View File

@@ -288,33 +288,35 @@ class EmailServerTest extends TestCase
public function it_should_test_the_send_test_mail_method()
{
$string = ini_get("sendmail_path");
if (!is_executable($string)) {
$this->markTestIncomplete($string . " not found");
//in current versions this value has extra parameters and must be cleaned
$result = explode(" ", $string);
$path = $result[0];
if (is_executable($path)) {
// The data that will be sent to the method
$data = [
"FROM_EMAIL" => "admin@processmaker.com",
"FROM_NAME" => "Administrator",
"MESS_ENGINE" => "MAIL",
"MESS_SERVER" => "localhost",
"MESS_PORT" => 25,
"MESS_ACCOUNT" => "admin@processmaker.com",
"MESS_PASSWORD" => "",
"TO" => "admin@processmaker.com",
"MESS_RAUTH" => true
];
// Create the EmailServer object
$emailServer = new EmailServer();
// Call the sendTestMail method
$result = $emailServer->sendTestMail($data);
// Assert the status is true
$this->assertTrue($result['status']);
// Assert the success is true
$this->assertTrue($result['success']);
// Assert the message of the result
$this->assertEquals('**ID_MAIL_TEST_SUCCESS**', $result['msg']);
}
// The data that will be sent to the method
$data = [
"FROM_EMAIL" => "admin@processmaker.com",
"FROM_NAME" => "Administrator",
"MESS_ENGINE" => "MAIL",
"MESS_SERVER" => "localhost",
"MESS_PORT" => 25,
"MESS_ACCOUNT" => "admin@processmaker.com",
"MESS_PASSWORD" => "",
"TO" => "admin@processmaker.com",
"MESS_RAUTH" => true
];
// Create the EmailServer object
$emailServer = new EmailServer();
// Call the sendTestMail method
$result = $emailServer->sendTestMail($data);
// Assert the status is true
$this->assertTrue($result['status']);
// Assert the success is true
$this->assertTrue($result['success']);
// Assert the message of the result
$this->assertEquals('**ID_MAIL_TEST_SUCCESS**', $result['msg']);
}
/**

View File

@@ -13,6 +13,7 @@ use ProcessMaker\GmailOAuth\GmailOAuth;
use ProcessMaker\Model\User;
use RBAC;
use Tests\TestCase;
use BadMethodCallException;
class GmailOAuthTest extends TestCase
{
@@ -251,7 +252,6 @@ class GmailOAuthTest extends TestCase
*/
public function it_should_send_an_email_test_with_PHPMailerOAuth()
{
$this->markTestIncomplete('Please solve the error related to Exception');
$faker = $this->faker;
$gmailOauth = new GmailOAuth();
@@ -276,8 +276,11 @@ class GmailOAuthTest extends TestCase
$gmailOauth->setSenderEmail($faker->email);
$gmailOauth->setMailTo($faker->email);
$gmailOauth->setSendTestMail(1);
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
$this->assertTrue($result instanceof PHPMailerOAuth);
//We cannot get a valid 'refresh token', therefore we wait for an exception
//when trying to send a email.
$this->expectException(BadMethodCallException::class);
$gmailOauth->sendTestMailWithPHPMailerOAuth();
}
/**

View File

@@ -0,0 +1,317 @@
<?php
namespace ProcessMaker\PDF;
use Faker\Factory;
use Tests\TestCase;
/**
* @covers ProcessMaker\PDF\BasicStruct
* @test
*/
class BasicStructTest extends TestCase
{
/**
* Mock for trait test.
* @var object
*/
private $mock;
/**
* Object faker.
* @var object
*/
private $faker;
/**
* setUp method.
*/
public function setUp()
{
parent::setUp();
$this->faker = Factory::create();
$this->mock = $this->getMockForTrait('ProcessMaker\PDF\BasicStruct');
}
/**
* tearDown method.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* This test the getLogo method.
* @covers ProcessMaker\PDF\BasicStruct::getLogo()
* @test
*/
public function it_should_test_the_method_getLogo()
{
$this->assertTrue(is_string($this->mock->getLogo()));
}
/**
* This test the getLogoWidth method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoWidth()
* @test
*/
public function it_should_test_the_method_getLogoWidth()
{
$this->assertTrue(is_float($this->mock->getLogoWidth()));
}
/**
* This test the getLogoPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoPositionX()
* @test
*/
public function it_should_test_the_method_getLogoPositionX()
{
$this->assertTrue(is_float($this->mock->getLogoPositionX()));
}
/**
* This test the getLogoPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoPositionY()
* @test
*/
public function it_should_test_the_method_getLogoPositionY()
{
$this->assertTrue(is_float($this->mock->getLogoPositionY()));
}
/**
* This test the getTitle method.
* @covers ProcessMaker\PDF\BasicStruct::getTitle()
* @test
*/
public function it_should_test_the_method_getTitle()
{
$this->assertTrue(is_string($this->mock->getTitle()));
}
/**
* This test the getTitleFontSize method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontSize()
* @test
*/
public function it_should_test_the_method_getTitleFontSize()
{
$this->assertTrue(is_float($this->mock->getTitleFontSize()));
}
/**
* This test the getTitleFontPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontPositionX()
* @test
*/
public function it_should_test_the_method_getTitleFontPositionX()
{
$this->assertTrue(is_float($this->mock->getTitleFontPositionX()));
}
/**
* This test the getTitleFontPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontPositionY()
* @test
*/
public function it_should_test_the_method_getTitleFontPositionY()
{
$this->assertTrue(is_float($this->mock->getTitleFontPositionY()));
}
/**
* This test the getPageNumber method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumber()
* @test
*/
public function it_should_test_the_method_getPageNumber()
{
$this->assertTrue(is_bool($this->mock->getPageNumber()));
}
/**
* This test the getPageNumberTitle method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberTitle()
* @test
*/
public function it_should_test_the_method_getPageNumberTitle()
{
$this->assertTrue(is_string($this->mock->getPageNumberTitle()));
}
/**
* This test the getPageNumberTotal method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberTotal()
* @test
*/
public function it_should_test_the_method_getPageNumberTotal()
{
$this->assertTrue(is_bool($this->mock->getPageNumberTotal()));
}
/**
* This test the getPageNumberPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberPositionX()
* @test
*/
public function it_should_test_the_method_getPageNumberPositionX()
{
$this->assertTrue(is_float($this->mock->getPageNumberPositionX()));
}
/**
* This test the getPageNumberPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberPositionY()
* @test
*/
public function it_should_test_the_method_getPageNumberPositionY()
{
$this->assertTrue(is_float($this->mock->getPageNumberPositionY()));
}
/**
* This test the setTitle method.
* @covers ProcessMaker\PDF\BasicStruct::setTitle()
* @test
*/
public function it_should_test_the_method_setTitle()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setTitle($this->faker->title));
}
/**
* This test the setTitleFontSize method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontSize()
* @test
*/
public function it_should_test_the_method_setTitleFontSize()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setTitleFontSize($this->faker->randomFloat()));
}
/**
* This test the setTitleFontPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontPositionX()
* @test
*/
public function it_should_test_the_method_setTitleFontPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setTitleFontPositionX($this->faker->randomFloat()));
}
/**
* This test the setTitleFontPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontPositionY()
* @test
*/
public function it_should_test_the_method_setTitleFontPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setTitleFontPositionY($this->faker->randomFloat()));
}
/**
* This test the setLogo method.
* @covers ProcessMaker\PDF\BasicStruct::setLogo()
* @test
*/
public function it_should_test_the_method_setLogo()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setLogo($this->faker->word));
}
/**
* This test the setLogoWidth method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoWidth()
* @test
*/
public function it_should_test_the_method_setLogoWidth()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setLogoWidth($this->faker->randomFloat()));
}
/**
* This test the setLogoPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoPositionX()
* @test
*/
public function it_should_test_the_method_setLogoPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setLogoPositionX($this->faker->randomFloat()));
}
/**
* This test the setLogoPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoPositionY()
* @test
*/
public function it_should_test_the_method_setLogoPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setLogoPositionY($this->faker->randomFloat()));
}
/**
* This test the setPageNumber method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumber()
* @test
*/
public function it_should_test_the_method_setPageNumber()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setPageNumber($this->faker->boolean));
}
/**
* This test the setPageNumberTitle method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberTitle()
* @test
*/
public function it_should_test_the_method_setPageNumberTitle()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setPageNumberTitle($this->faker->title));
}
/**
* This test the setPageNumberTotal method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberTotal()
* @test
*/
public function it_should_test_the_method_setPageNumberTotal()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setPageNumberTotal($this->faker->boolean));
}
/**
* This test the setPageNumberPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberPositionX()
* @test
*/
public function it_should_test_the_method_setPageNumberPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setPageNumberPositionX($this->faker->randomFloat()));
}
/**
* This test the setPageNumberPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberPositionY()
* @test
*/
public function it_should_test_the_method_setPageNumberPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->mock->setPageNumberPositionY($this->faker->randomFloat()));
}
}

View File

@@ -0,0 +1,317 @@
<?php
namespace ProcessMaker\PDF;
use Faker\Factory;
use Tests\TestCase;
/**
* @covers ProcessMaker\PDF\FooterStruct
* @test
*/
class FooterStructTest extends TestCase
{
/**
* FooterStruct object.
* @var FooterStruct
*/
protected $object;
/**
* Object faker.
* @var object
*/
private $faker;
/**
* setUp method.
*/
public function setUp()
{
parent::setUp();
$this->faker = Factory::create();
$this->object = new FooterStruct();
}
/**
* tearDown method.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* This test the getLogo method.
* @covers ProcessMaker\PDF\BasicStruct::getLogo()
* @test
*/
public function it_should_test_the_method_getLogo()
{
$this->assertTrue(is_string($this->object->getLogo()));
}
/**
* This test the getLogoWidth method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoWidth()
* @test
*/
public function it_should_test_the_method_getLogoWidth()
{
$this->assertTrue(is_float($this->object->getLogoWidth()));
}
/**
* This test the getLogoPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoPositionX()
* @test
*/
public function it_should_test_the_method_getLogoPositionX()
{
$this->assertTrue(is_float($this->object->getLogoPositionX()));
}
/**
* This test the getLogoPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoPositionY()
* @test
*/
public function it_should_test_the_method_getLogoPositionY()
{
$this->assertTrue(is_float($this->object->getLogoPositionY()));
}
/**
* This test the getTitle method.
* @covers ProcessMaker\PDF\BasicStruct::getTitle()
* @test
*/
public function it_should_test_the_method_getTitle()
{
$this->assertTrue(is_string($this->object->getTitle()));
}
/**
* This test the getTitleFontSize method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontSize()
* @test
*/
public function it_should_test_the_method_getTitleFontSize()
{
$this->assertTrue(is_float($this->object->getTitleFontSize()));
}
/**
* This test the getTitleFontPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontPositionX()
* @test
*/
public function it_should_test_the_method_getTitleFontPositionX()
{
$this->assertTrue(is_float($this->object->getTitleFontPositionX()));
}
/**
* This test the getTitleFontPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontPositionY()
* @test
*/
public function it_should_test_the_method_getTitleFontPositionY()
{
$this->assertTrue(is_float($this->object->getTitleFontPositionY()));
}
/**
* This test the getPageNumber method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumber()
* @test
*/
public function it_should_test_the_method_getPageNumber()
{
$this->assertTrue(is_bool($this->object->getPageNumber()));
}
/**
* This test the getPageNumberTitle method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberTitle()
* @test
*/
public function it_should_test_the_method_getPageNumberTitle()
{
$this->assertTrue(is_string($this->object->getPageNumberTitle()));
}
/**
* This test the getPageNumberTotal method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberTotal()
* @test
*/
public function it_should_test_the_method_getPageNumberTotal()
{
$this->assertTrue(is_bool($this->object->getPageNumberTotal()));
}
/**
* This test the getPageNumberPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberPositionX()
* @test
*/
public function it_should_test_the_method_getPageNumberPositionX()
{
$this->assertTrue(is_float($this->object->getPageNumberPositionX()));
}
/**
* This test the getPageNumberPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberPositionY()
* @test
*/
public function it_should_test_the_method_getPageNumberPositionY()
{
$this->assertTrue(is_float($this->object->getPageNumberPositionY()));
}
/**
* This test the setTitle method.
* @covers ProcessMaker\PDF\BasicStruct::setTitle()
* @test
*/
public function it_should_test_the_method_setTitle()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitle($this->faker->title));
}
/**
* This test the setTitleFontSize method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontSize()
* @test
*/
public function it_should_test_the_method_setTitleFontSize()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitleFontSize($this->faker->randomFloat()));
}
/**
* This test the setTitleFontPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontPositionX()
* @test
*/
public function it_should_test_the_method_setTitleFontPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitleFontPositionX($this->faker->randomFloat()));
}
/**
* This test the setTitleFontPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontPositionY()
* @test
*/
public function it_should_test_the_method_setTitleFontPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitleFontPositionY($this->faker->randomFloat()));
}
/**
* This test the setLogo method.
* @covers ProcessMaker\PDF\BasicStruct::setLogo()
* @test
*/
public function it_should_test_the_method_setLogo()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogo($this->faker->word));
}
/**
* This test the setLogoWidth method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoWidth()
* @test
*/
public function it_should_test_the_method_setLogoWidth()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogoWidth($this->faker->randomFloat()));
}
/**
* This test the setLogoPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoPositionX()
* @test
*/
public function it_should_test_the_method_setLogoPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogoPositionX($this->faker->randomFloat()));
}
/**
* This test the setLogoPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoPositionY()
* @test
*/
public function it_should_test_the_method_setLogoPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogoPositionY($this->faker->randomFloat()));
}
/**
* This test the setPageNumber method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumber()
* @test
*/
public function it_should_test_the_method_setPageNumber()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumber($this->faker->boolean));
}
/**
* This test the setPageNumberTitle method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberTitle()
* @test
*/
public function it_should_test_the_method_setPageNumberTitle()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberTitle($this->faker->title));
}
/**
* This test the setPageNumberTotal method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberTotal()
* @test
*/
public function it_should_test_the_method_setPageNumberTotal()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberTotal($this->faker->boolean));
}
/**
* This test the setPageNumberPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberPositionX()
* @test
*/
public function it_should_test_the_method_setPageNumberPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberPositionX($this->faker->randomFloat()));
}
/**
* This test the setPageNumberPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberPositionY()
* @test
*/
public function it_should_test_the_method_setPageNumberPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberPositionY($this->faker->randomFloat()));
}
}

View File

@@ -0,0 +1,311 @@
<?php
namespace ProcessMaker\PDF;
use Faker\Factory;
use Tests\TestCase;
/**
* @covers ProcessMaker\PDF\HeaderStruct
* @test
*/
class HeaderStructTest extends TestCase
{
/**
* HeaderStruct object.
* @var HeaderStruct
*/
protected $object;
/**
* setUp method.
*/
public function setUp()
{
parent::setUp();
$this->faker = Factory::create();
$this->object = new HeaderStruct();
}
/**
* tearDown method.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* This test the getLogo method.
* @covers ProcessMaker\PDF\BasicStruct::getLogo()
* @test
*/
public function it_should_test_the_method_getLogo()
{
$this->assertTrue(is_string($this->object->getLogo()));
}
/**
* This test the getLogoWidth method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoWidth()
* @test
*/
public function it_should_test_the_method_getLogoWidth()
{
$this->assertTrue(is_float($this->object->getLogoWidth()));
}
/**
* This test the getLogoPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoPositionX()
* @test
*/
public function it_should_test_the_method_getLogoPositionX()
{
$this->assertTrue(is_float($this->object->getLogoPositionX()));
}
/**
* This test the getLogoPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getLogoPositionY()
* @test
*/
public function it_should_test_the_method_getLogoPositionY()
{
$this->assertTrue(is_float($this->object->getLogoPositionY()));
}
/**
* This test the getTitle method.
* @covers ProcessMaker\PDF\BasicStruct::getTitle()
* @test
*/
public function it_should_test_the_method_getTitle()
{
$this->assertTrue(is_string($this->object->getTitle()));
}
/**
* This test the getTitleFontSize method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontSize()
* @test
*/
public function it_should_test_the_method_getTitleFontSize()
{
$this->assertTrue(is_float($this->object->getTitleFontSize()));
}
/**
* This test the getTitleFontPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontPositionX()
* @test
*/
public function it_should_test_the_method_getTitleFontPositionX()
{
$this->assertTrue(is_float($this->object->getTitleFontPositionX()));
}
/**
* This test the getTitleFontPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getTitleFontPositionY()
* @test
*/
public function it_should_test_the_method_getTitleFontPositionY()
{
$this->assertTrue(is_float($this->object->getTitleFontPositionY()));
}
/**
* This test the getPageNumber method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumber()
* @test
*/
public function it_should_test_the_method_getPageNumber()
{
$this->assertTrue(is_bool($this->object->getPageNumber()));
}
/**
* This test the getPageNumberTitle method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberTitle()
* @test
*/
public function it_should_test_the_method_getPageNumberTitle()
{
$this->assertTrue(is_string($this->object->getPageNumberTitle()));
}
/**
* This test the getPageNumberTotal method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberTotal()
* @test
*/
public function it_should_test_the_method_getPageNumberTotal()
{
$this->assertTrue(is_bool($this->object->getPageNumberTotal()));
}
/**
* This test the getPageNumberPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberPositionX()
* @test
*/
public function it_should_test_the_method_getPageNumberPositionX()
{
$this->assertTrue(is_float($this->object->getPageNumberPositionX()));
}
/**
* This test the getPageNumberPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::getPageNumberPositionY()
* @test
*/
public function it_should_test_the_method_getPageNumberPositionY()
{
$this->assertTrue(is_float($this->object->getPageNumberPositionY()));
}
/**
* This test the setTitle method.
* @covers ProcessMaker\PDF\BasicStruct::setTitle()
* @test
*/
public function it_should_test_the_method_setTitle()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitle($this->faker->title));
}
/**
* This test the setTitleFontSize method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontSize()
* @test
*/
public function it_should_test_the_method_setTitleFontSize()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitleFontSize($this->faker->randomFloat()));
}
/**
* This test the setTitleFontPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontPositionX()
* @test
*/
public function it_should_test_the_method_setTitleFontPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitleFontPositionX($this->faker->randomFloat()));
}
/**
* This test the setTitleFontPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setTitleFontPositionY()
* @test
*/
public function it_should_test_the_method_setTitleFontPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setTitleFontPositionY($this->faker->randomFloat()));
}
/**
* This test the setLogo method.
* @covers ProcessMaker\PDF\BasicStruct::setLogo()
* @test
*/
public function it_should_test_the_method_setLogo()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogo($this->faker->word));
}
/**
* This test the setLogoWidth method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoWidth()
* @test
*/
public function it_should_test_the_method_setLogoWidth()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogoWidth($this->faker->randomFloat()));
}
/**
* This test the setLogoPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoPositionX()
* @test
*/
public function it_should_test_the_method_setLogoPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogoPositionX($this->faker->randomFloat()));
}
/**
* This test the setLogoPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setLogoPositionY()
* @test
*/
public function it_should_test_the_method_setLogoPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setLogoPositionY($this->faker->randomFloat()));
}
/**
* This test the setPageNumber method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumber()
* @test
*/
public function it_should_test_the_method_setPageNumber()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumber($this->faker->boolean));
}
/**
* This test the setPageNumberTitle method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberTitle()
* @test
*/
public function it_should_test_the_method_setPageNumberTitle()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberTitle($this->faker->title));
}
/**
* This test the setPageNumberTotal method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberTotal()
* @test
*/
public function it_should_test_the_method_setPageNumberTotal()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberTotal($this->faker->boolean));
}
/**
* This test the setPageNumberPositionX method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberPositionX()
* @test
*/
public function it_should_test_the_method_setPageNumberPositionX()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberPositionX($this->faker->randomFloat()));
}
/**
* This test the setPageNumberPositionY method.
* @covers ProcessMaker\PDF\BasicStruct::setPageNumberPositionY()
* @test
*/
public function it_should_test_the_method_setPageNumberPositionY()
{
$this->faker->numberBetween(400, 500);
$this->assertEmpty($this->object->setPageNumberPositionY($this->faker->randomFloat()));
}
}

View File

@@ -0,0 +1,173 @@
<?php
namespace ProcessMaker\PDF;
use stdClass;
use Tests\TestCase;
/**
* @covers ProcessMaker\PDF\TCPDFHeaderFooter
* @test
*/
class TCPDFHeaderFooterTest extends TestCase
{
/**
* TCPDFHeaderFooter object.
* @var TCPDFHeaderFooter
*/
protected $object;
/**
* setUp method.
*/
protected function setUp()
{
parent::setUp();
$this->object = new TCPDFHeaderFooter('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$this->object->SetCreator(PDF_CREATOR);
$this->object->SetAuthor('admin');
$this->object->SetTitle('test');
$this->object->SetSubject('test.pdf');
$this->object->SetCompression(true);
$this->setHeaderData();
$this->setFooterData();
}
/**
* tearDown method.
*/
protected function tearDown()
{
parent::tearDown();
}
/**
* Setting data for header configuration.
*/
private function setHeaderData()
{
$header = new stdClass();
$header->logo = PATH_TRUNK . "/vendor/tecnickcom/tcpdf/examples/images/logo_example.jpg";
$header->logoWidth = 10;
$header->logoPositionX = 50;
$header->logoPositionY = 0;
$header->title = "Test1 Test1";
$header->titleFontSize = 60;
$header->titleFontPositionX = 10;
$header->titleFontPositionY = 0;
$header->pageNumber = true;
$header->pageNumberTitle = "Pages";
$header->pageNumberTotal = true;
$header->pageNumberPositionX = 10;
$header->pageNumberPositionY = 0;
$struct = $this->object->getHeaderStruct();
$struct->setLogo($header->logo);
$struct->setLogoWidth($header->logoWidth);
$struct->setLogoPositionX($header->logoPositionX);
$struct->setLogoPositionY($header->logoPositionY);
$struct->setTitle($header->title);
$struct->setTitleFontSize($header->titleFontSize);
$struct->setTitleFontPositionX($header->titleFontPositionX);
$struct->setTitleFontPositionY($header->titleFontPositionY);
$struct->setPageNumber($header->pageNumber);
$struct->setPageNumberTitle($header->pageNumberTitle);
$struct->setPageNumberTotal($header->pageNumberTotal);
$struct->setPageNumberPositionX($header->pageNumberPositionX);
$struct->setPageNumberPositionY($header->pageNumberPositionY);
}
/**
* Setting data for footer configuration.
*/
private function setFooterData()
{
$footer = new stdClass();
$footer->logo = PATH_TRUNK . "/vendor/tecnickcom/tcpdf/examples/images/logo_example.jpg";
$footer->logoWidth = 15;
$footer->logoPositionX = 10;
$footer->logoPositionY = 0;
$footer->title = "Hola mundo como estas";
$footer->titleFontSize = 20;
$footer->titleFontPositionX = 0;
$footer->titleFontPositionY = 5;
$footer->pageNumber = true;
$footer->pageNumberTitle = "Pages";
$footer->pageNumberTotal = true;
$footer->pageNumberPositionX = 40;
$footer->pageNumberPositionY = 5;
$struct = $this->object->getFooterStruct();
$struct->setLogo($footer->logo);
$struct->setLogoWidth($footer->logoWidth);
$struct->setLogoPositionX($footer->logoPositionX);
$struct->setLogoPositionY($footer->logoPositionY);
$struct->setTitle($footer->title);
$struct->setTitleFontSize($footer->titleFontSize);
$struct->setTitleFontPositionX($footer->titleFontPositionX);
$struct->setTitleFontPositionY($footer->titleFontPositionY);
$struct->setPageNumber($footer->pageNumber);
$struct->setPageNumberTitle($footer->pageNumberTitle);
$struct->setPageNumberTotal($footer->pageNumberTotal);
$struct->setPageNumberPositionX($footer->pageNumberPositionX);
$struct->setPageNumberPositionY($footer->pageNumberPositionY);
}
/**
* This test the getHeaderStruct() method.
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::getHeaderStruct()
* @test
*/
public function it_should_test_the_getHeaderStruct()
{
$result = $this->object->getHeaderStruct();
$this->assertNotNull($result);
$this->assertEquals(HeaderStruct::class, get_class($result));
}
/**
* This test the getFooterStruct() method.
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::getFooterStruct()
* @test
*/
public function it_should_test_the_getFooterStruct()
{
$result = $this->object->getFooterStruct();
$this->assertNotNull($result);
$this->assertEquals(FooterStruct::class, get_class($result));
}
/**
* This test the Header() method override.
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::Header()
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::buildHeaderLogo()
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::buildHeaderTitle()
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::buildHeaderPageNumber()
* @test
*/
public function it_should_test_the_Header()
{
$this->object->AddPage();
$result = $this->object->Header();
$this->assertEmpty($result);
}
/**
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::Footer()
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::buildFooterLogo()
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::buildFooterTitle()
* @covers ProcessMaker\PDF\TCPDFHeaderFooter::buildFooterPageNumber()
* @test
*/
public function it_should_test_the_Footer()
{
$this->object->AddPage();
$result = $this->object->Footer();
$this->assertEmpty($result);
}
}