Skip to content

Commit

Permalink
Fix tests when running them in separated PHP processes
Browse files Browse the repository at this point in the history
vendor/bin/phpunit --process-isolation

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Jun 4, 2021
1 parent cbe13a7 commit 3f9265b
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 348 deletions.
8 changes: 3 additions & 5 deletions test/classes/Controllers/ExportTemplateControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ class ExportTemplateControllerTest extends AbstractTestCase

protected function setUp(): void
{
global $dbi, $config;

$this->setGlobalDbi();
parent::setUp();
parent::setTheme();

$config = new Config();
global $dbi, $config;

$config->enableBc();

$_SESSION = [' PMA_token ' => 'token'];
$GLOBALS['server'] = 1;
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_PHP_SELF'] = '';
Expand Down
61 changes: 11 additions & 50 deletions test/classes/Gis/GisGeometryCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,61 +175,22 @@ public function providerForGenerateParams(): array
];
}

/**
* Test for prepareRowAsPng
*
* @param string $spatial string to parse
* @param string $label field label
* @param string $line_color line color
* @param array $scale_data scaling parameters
* @param resource $image initial image
*
* @dataProvider providerForPrepareRowAsPng
*/
public function testPrepareRowAsPng(
string $spatial,
string $label,
string $line_color,
array $scale_data,
$image
): void {
$return = $this->object->prepareRowAsPng(
$spatial,
$label,
$line_color,
$scale_data,
$image
);
$this->assertEquals(120, imagesx($return));
$this->assertEquals(150, imagesy($return));
}

/**
* Data provider for testPrepareRowAsPng() test case
*
* @return array test data for testPrepareRowAsPng() test case
*/
public function providerForPrepareRowAsPng(): array
public function testPrepareRowAsPng(): void
{
if (! function_exists('imagecreatetruecolor')) {
$this->markTestSkipped('GD extension missing!');
}

return [
[
'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),'
. '(20 30,35 32,30 20,20 30)))',
'image',
'#B02EE0',
[
'x' => 12,
'y' => 69,
'scale' => 2,
'height' => 150,
],
imagecreatetruecolor(120, 150),
],
];
$return = $this->object->prepareRowAsPng(
'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),'
. '(20 30,35 32,30 20,20 30)))',
'image',
'#B02EE0',
['x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150],
imagecreatetruecolor(120, 150)
);
$this->assertEquals(120, imagesx($return));
$this->assertEquals(150, imagesy($return));
}

/**
Expand Down
58 changes: 9 additions & 49 deletions test/classes/Gis/GisLineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,60 +168,20 @@ public function providerForTestScaleRow(): array
];
}

/**
* test case for prepareRowAsPng() method
*
* @param string $spatial GIS LINESTRING object
* @param string $label label for the GIS LINESTRING object
* @param string $line_color color for the GIS LINESTRING object
* @param array $scale_data array containing data related to scaling
* @param resource $image image object
*
* @dataProvider providerForPrepareRowAsPng
*/
public function testPrepareRowAsPng(
string $spatial,
string $label,
string $line_color,
array $scale_data,
$image
): void {
$this->object->prepareRowAsPng(
$spatial,
$label,
$line_color,
$scale_data,
$image
);
/* TODO: this never fails */
$this->assertTrue(true);
}

/**
* data provider for testPrepareRowAsPng() test case
*
* @return array test data for testPrepareRowAsPng() test case
*/
public function providerForPrepareRowAsPng(): array
public function testPrepareRowAsPng(): void
{
if (! function_exists('imagecreatetruecolor')) {
$this->markTestSkipped('GD extension missing!');
}

return [
[
'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
'image',
'#B02EE0',
[
'x' => 12,
'y' => 69,
'scale' => 2,
'height' => 150,
],
imagecreatetruecolor(120, 150),
],
];
$return = $this->object->prepareRowAsPng(
'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
'image',
'#B02EE0',
['x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150],
imagecreatetruecolor(120, 150)
);
$this->assertImage($return);
}

/**
Expand Down
58 changes: 9 additions & 49 deletions test/classes/Gis/GisMultiLineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,60 +250,20 @@ public function providerForTestScaleRow(): array
];
}

/**
* test case for prepareRowAsPng() method
*
* @param string $spatial GIS MULTILINESTRING object
* @param string $label label for the GIS MULTILINESTRING object
* @param string $line_color color for the GIS MULTILINESTRING object
* @param array $scale_data array containing data related to scaling
* @param resource $image image object
*
* @dataProvider providerForPrepareRowAsPng
*/
public function testPrepareRowAsPng(
string $spatial,
string $label,
string $line_color,
array $scale_data,
$image
): void {
$this->object->prepareRowAsPng(
$spatial,
$label,
$line_color,
$scale_data,
$image
);
/* TODO: this never fails */
$this->assertTrue(true);
}

/**
* data provider for testPrepareRowAsPng() test case
*
* @return array test data for testPrepareRowAsPng() test case
*/
public function providerForPrepareRowAsPng(): array
public function testPrepareRowAsPng(): void
{
if (! function_exists('imagecreatetruecolor')) {
$this->markTestSkipped('GD extension missing!');
}

return [
[
'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))',
'image',
'#B02EE0',
[
'x' => 12,
'y' => 69,
'scale' => 2,
'height' => 150,
],
imagecreatetruecolor(120, 150),
],
];
$return = $this->object->prepareRowAsPng(
'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))',
'image',
'#B02EE0',
['x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150],
imagecreatetruecolor(120, 150)
);
$this->assertImage($return);
}

/**
Expand Down
57 changes: 9 additions & 48 deletions test/classes/Gis/GisMultiPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,59 +170,20 @@ public function providerForTestScaleRow(): array
];
}

/**
* test case for prepareRowAsPng() method
*
* @param string $spatial GIS MULTIPOINT object
* @param string $label label for the GIS MULTIPOINT object
* @param string $point_color color for the GIS MULTIPOINT object
* @param array $scale_data array containing data related to scaling
* @param resource $image image object
*
* @dataProvider providerForPrepareRowAsPng
*/
public function testPrepareRowAsPng(
string $spatial,
string $label,
string $point_color,
array $scale_data,
$image
): void {
$return = $this->object->prepareRowAsPng(
$spatial,
$label,
$point_color,
$scale_data,
$image
);
$this->assertImage($return);
}

/**
* data provider for testPrepareRowAsPng() test case
*
* @return array test data for testPrepareRowAsPng() test case
*/
public function providerForPrepareRowAsPng(): array
public function testPrepareRowAsPng(): void
{
if (! function_exists('imagecreatetruecolor')) {
$this->markTestSkipped('GD extension missing!');
}

return [
[
'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
'image',
'#B02EE0',
[
'x' => 12,
'y' => 69,
'scale' => 2,
'height' => 150,
],
imagecreatetruecolor(120, 150),
],
];
$return = $this->object->prepareRowAsPng(
'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
'image',
'#B02EE0',
['x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150],
imagecreatetruecolor(120, 150)
);
$this->assertImage($return);
}

/**
Expand Down
60 changes: 10 additions & 50 deletions test/classes/Gis/GisMultiPolygonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,61 +337,21 @@ public function providerForTestScaleRow(): array
];
}

/**
* test case for prepareRowAsPng() method
*
* @param string $spatial GIS MULTIPOLYGON object
* @param string $label label for the GIS MULTIPOLYGON object
* @param string $fill_color color for the GIS MULTIPOLYGON object
* @param array $scale_data array containing data related to scaling
* @param resource $image image object
*
* @dataProvider providerForPrepareRowAsPng
*/
public function testPrepareRowAsPng(
string $spatial,
string $label,
string $fill_color,
array $scale_data,
$image
): void {
$return = $this->object->prepareRowAsPng(
$spatial,
$label,
$fill_color,
$scale_data,
$image
);
$this->assertImage($return);
}

/**
* data provider for testPrepareRowAsPng() test case
*
* @return array test data for testPrepareRowAsPng() test case
*/
public function providerForPrepareRowAsPng(): array
public function testPrepareRowAsPng(): void
{
if (! function_exists('imagecreatetruecolor')) {
$this->markTestSkipped('GD extension missing!');
}

return [
[
'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),'
. '((105 0,56 20,78 73,105 0)))',
'image',
'#B02EE0',
[
'x' => 12,
'y' => 69,
'scale' => 2,
'height' => 150,
],
imagecreatetruecolor(120, 150),
],

];
$return = $this->object->prepareRowAsPng(
'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),'
. '((105 0,56 20,78 73,105 0)))',
'image',
'#B02EE0',
['x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150],
imagecreatetruecolor(120, 150)
);
$this->assertImage($return);
}

/**
Expand Down
Loading

0 comments on commit 3f9265b

Please sign in to comment.