Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>

<extensions>
<bootstrap class="LaminasIntegrationTest\Db\Extension\ListenerExtension" />
</extensions>

<testsuites>
<testsuite name="unit test">
Expand All @@ -19,9 +18,6 @@
</testsuite>
</testsuites>

<listeners>
<listener class="LaminasIntegrationTest\Db\IntegrationTestListener" file="./test/integration/IntegrationTestListener.php"/>
</listeners>

<php>
<!-- Note: the following is a FULL list of ALL POSSIBLE constants
Comment thread
tyrsson marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @property Adapter $adapter
*/
abstract class AbstractAdapterTest extends TestCase
abstract class AbstractAdapterTestCase extends TestCase
{
public const DB_SERVER_PORT = null;

Expand Down
4 changes: 2 additions & 2 deletions test/integration/Adapter/Driver/Pdo/Mysql/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace LaminasIntegrationTest\Db\Adapter\Driver\Pdo\Mysql;

use Laminas\Db\Adapter\Adapter;
use LaminasIntegrationTest\Db\Adapter\Driver\Pdo\AbstractAdapterTest;
use LaminasIntegrationTest\Db\Adapter\Driver\Pdo\AbstractAdapterTestCase;

class AdapterTest extends AbstractAdapterTest
class AdapterTest extends AbstractAdapterTestCase
{
use AdapterTrait;

Expand Down
2 changes: 1 addition & 1 deletion test/integration/Adapter/Driver/Pdo/Mysql/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class QueryTest extends TestCase
* 2: array<string, mixed>
* }>
*/
public function getQueriesWithRowResult(): array
public static function getQueriesWithRowResult(): array
{
return [
['SELECT * FROM test WHERE id = ?', [1], ['id' => 1, 'name' => 'foo', 'value' => 'bar']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function tearDown(): void
$this->adapter = null;
}

public function connections(): array
public static function connections(): array
{
return array_fill(0, 200, []);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testTableGatewayWithMetadataFeature($table)
}

/** @psalm-return array<string, array{0: mixed}> */
public function tableProvider(): array
public static function tableProvider(): array
{
return [
'string' => ['test'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace LaminasIntegrationTest\Db\Adapter\Driver\Pdo\Postgresql;

use Laminas\Db\Adapter\Adapter;
use LaminasIntegrationTest\Db\Adapter\Driver\Pdo\AbstractAdapterTest;
use LaminasIntegrationTest\Db\Adapter\Driver\Pdo\AbstractAdapterTestCase;

class AdapterTest extends AbstractAdapterTest
class AdapterTest extends AbstractAdapterTestCase
{
use AdapterTrait;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
<?php

namespace LaminasIntegrationTest\Db;
namespace LaminasIntegrationTest\Db\Extension;

use LaminasIntegrationTest\Db\Platform\FixtureLoader;
use LaminasIntegrationTest\Db\Platform\MysqlFixtureLoader;
use LaminasIntegrationTest\Db\Platform\PgsqlFixtureLoader;
use LaminasIntegrationTest\Db\Platform\SqlServerFixtureLoader;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestListenerDefaultImplementation;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Runner\TestHook;
use PHPUnit\Event\TestSuite\Started;
use PHPUnit\Event\TestSuite\StartedSubscriber;

use function getenv;
use function printf;

class IntegrationTestListener implements TestHook, TestListener
final class IntegrationTestStartedListener implements StartedSubscriber
{
use TestListenerDefaultImplementation;

/** @var FixtureLoader[] */
private $fixtureLoaders = [];

public function startTestSuite(TestSuite $suite): void
public function notify(Started $event): void
{
if ($suite->getName() !== 'integration test') {
if ($event->testSuite()->name() !== 'integration test') {
return;
}

Expand All @@ -49,20 +45,4 @@ public function startTestSuite(TestSuite $suite): void
$fixtureLoader->createDatabase();
}
}

public function endTestSuite(TestSuite $suite): void
{
if (
$suite->getName() !== 'integration test'
|| empty($this->fixtureLoaders)
) {
return;
}

printf("\nIntegration test ended.\n");

foreach ($this->fixtureLoaders as $fixtureLoader) {
$fixtureLoader->dropDatabase();
}
}
}
31 changes: 31 additions & 0 deletions test/integration/Extension/IntegrationTestStoppedListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace LaminasIntegrationTest\Db\Extension;

use LaminasIntegrationTest\Db\Platform\FixtureLoader;
use PHPUnit\Event\TestSuite\Finished;
use PHPUnit\Event\TestSuite\FinishedSubscriber;

use function printf;

final class IntegrationTestStoppedListener implements FinishedSubscriber
{
/** @var FixtureLoader[] */
private $fixtureLoaders = [];

public function notify(Finished $event): void
{
if (
$event->testSuite()->name() !== 'integration test'
|| empty($this->fixtureLoaders)
) {
return;
}

printf("\nIntegration test ended.\n");

foreach ($this->fixtureLoaders as $fixtureLoader) {
$fixtureLoader->dropDatabase();
}
}
}
22 changes: 22 additions & 0 deletions test/integration/Extension/ListenerExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace LaminasIntegrationTest\Db\Extension;

use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;

final class ListenerExtension implements Extension
{
public function bootstrap(
Configuration $configuration,
Facade $facade,
ParameterCollection $parameters
): void {
$facade->registerSubscribers(
new IntegrationTestStartedListener(),
new IntegrationTestStoppedListener(),
);
}
}