Merged in bugfix/PMCORE-1158 (pull request #7258)

PMCORE-1158 ReportTablesTest: Solve the incomplete test

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Roly
2020-02-14 20:24:00 +00:00
committed by Julio Cesar Laura Avendaño

View File

@@ -17,12 +17,20 @@ class ReportTablesTest extends TestCase
/** /**
* Sets up the unit tests. * Sets up the unit tests.
*/ */
protected function setUp() public function setUp()
{ {
$this->markTestIncomplete();//@todo: Please correct this unit test parent::setUp();
$_SERVER["REQUEST_URI"] = ""; $_SERVER["REQUEST_URI"] = "";
} }
/**
* Tear down the unit tests.
*/
public function tearDown()
{
parent::tearDown();
}
/** /**
* Check if the "populateTable" function returns an array value if entered all parameters. * Check if the "populateTable" function returns an array value if entered all parameters.
* @test * @test
@@ -31,7 +39,7 @@ class ReportTablesTest extends TestCase
public function it_should_populating_data_with_all_parameters() public function it_should_populating_data_with_all_parameters()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 1); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = $result->fields; $fields = $result->fields;
@@ -61,7 +69,7 @@ class ReportTablesTest extends TestCase
public function it_should_populating_data_with_all_parameters_with_type_is_grid() public function it_should_populating_data_with_all_parameters_with_type_is_grid()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 18, true); $result = $this->prepareData($tableName, true);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'GRID'; $type = 'GRID';
$fields = $result->fields; $fields = $result->fields;
@@ -100,7 +108,7 @@ class ReportTablesTest extends TestCase
public function it_should_populating_data_with_all_parameters_with_type_is_grid_null() public function it_should_populating_data_with_all_parameters_with_type_is_grid_null()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 19, true); $result = $this->prepareData($tableName, true);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'GRID'; $type = 'GRID';
$fields = $result->fields; $fields = $result->fields;
@@ -130,7 +138,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_only_with_the_mandatory_parameter_tableName() public function this_should_populate_the_reports_table_only_with_the_mandatory_parameter_tableName()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 2); $result = $this->prepareData($tableName);
$reportTables = new ReportTables(); $reportTables = new ReportTables();
$reportTables->populateTable($tableName); $reportTables->populateTable($tableName);
@@ -156,7 +164,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_connectionShortName_parameter() public function this_should_populate_the_reports_table_with_the_connectionShortName_parameter()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 3); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$reportTables = new ReportTables(); $reportTables = new ReportTables();
@@ -183,7 +191,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_connectionShortName_parameter_is_null() public function this_should_populate_the_reports_table_with_the_connectionShortName_parameter_is_null()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 8); $result = $this->prepareData($tableName);
$connectionShortName = null; $connectionShortName = null;
$reportTables = new ReportTables(); $reportTables = new ReportTables();
@@ -210,7 +218,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_connectionShortName_parameter_is_incorrect_value() public function this_should_populate_the_reports_table_with_the_connectionShortName_parameter_is_incorrect_value()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 9); $result = $this->prepareData($tableName);
$connectionShortName = G::generateUniqueID(); $connectionShortName = G::generateUniqueID();
$reportTables = new ReportTables(); $reportTables = new ReportTables();
@@ -237,7 +245,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 4); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
@@ -265,7 +273,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_is_grid() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_is_grid()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 11); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'GRID'; $type = 'GRID';
@@ -293,7 +301,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_is_null() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_is_null()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 10); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = null; $type = null;
@@ -321,7 +329,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 5); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = $result->fields; $fields = $result->fields;
@@ -350,7 +358,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_is_null() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_is_null()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 12); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = null; $fields = null;
@@ -379,7 +387,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_is_empty_array() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_is_empty_array()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 13); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = []; $fields = [];
@@ -408,7 +416,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_is_incorrect_value() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_is_incorrect_value()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 14); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = ""; $fields = "";
@@ -437,7 +445,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 6); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = $result->fields; $fields = $result->fields;
@@ -467,7 +475,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid_is_null() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid_is_null()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 15); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = $result->fields; $fields = $result->fields;
@@ -497,7 +505,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid_grid() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid_grid()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 7); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = $result->fields; $fields = $result->fields;
@@ -528,7 +536,7 @@ class ReportTablesTest extends TestCase
public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid_grid_if_null() public function this_should_populate_the_reports_table_with_the_parameters_connectionShortName_type_fields_proUid_grid_if_null()
{ {
$tableName = 'TestReportTable'; $tableName = 'TestReportTable';
$result = $this->prepareData($tableName, 16); $result = $this->prepareData($tableName);
$connectionShortName = 'wf'; $connectionShortName = 'wf';
$type = 'NORMAL'; $type = 'NORMAL';
$fields = $result->fields; $fields = $result->fields;
@@ -649,8 +657,14 @@ class ReportTablesTest extends TestCase
* @param boolean $grid * @param boolean $grid
* @return object * @return object
*/ */
private function prepareData($tableName, $applicationNumber, $grid = null) private function prepareData($tableName, $grid = null)
{ {
$applicationNumber = Application::max('APP_NUMBER');
if (is_null($applicationNumber)) {
$applicationNumber = 0;
}
$applicationNumber = $applicationNumber + 1;
$faker = Faker\Factory::create(); $faker = Faker\Factory::create();
$date = $faker->dateTime(); $date = $faker->dateTime();