Merged in bugfix/PMCORE-1801 (pull request #7444)

PMCORE-1801

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2020-08-19 17:56:31 +00:00
2 changed files with 44 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace Tests\unit\gulliver\system;
use Form;
use G;
use Tests\TestCase;
class FormTest extends TestCase
{
/**
* Test the creation of the XML file if not exists or has no content
*
* @covers Form::createXMLFileIfNotExists()
* @test
*/
public function it_should_test_create_xml_file_if_not_exists()
{
// Build the file path
$xmlForm = PATH_DYNAFORM . G::generateUniqueID() . '/' . G::generateUniqueID() . '.xml';
// The file doesn't exists, so, should be created
Form::createXMLFileIfNotExists($xmlForm);
// File created?
$this->assertFileExists($xmlForm);
// File with content?
$this->assertNotEmpty(file_get_contents($xmlForm));
// Delete the file
unlink($xmlForm);
// Create another empty
touch($xmlForm);
// The file exists, but is empty, should be regenerated
Form::createXMLFileIfNotExists($xmlForm);
// File with content?
$this->assertNotEmpty(file_get_contents($xmlForm));
}
}