Skip to content

Commit fd220f5

Browse files
committed
Latest revisions to unit test
Fixes ALL phpunit deprecations fixes all test except for one in Pdo\QueryTest Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent c3a3ad0 commit fd220f5

File tree

7 files changed

+56
-31
lines changed

7 files changed

+56
-31
lines changed

test/integration/Driver/Mysqli/ConnectionTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@
33
namespace LaminasIntegrationTest\Db\Mysql\Driver\Mysqli;
44

55
use Laminas\Db\Mysql\Driver\Mysqli\Connection;
6+
7+
use PHPUnit\Framework\Attributes;
68
use PHPUnit\Framework\TestCase;
79

8-
/**
9-
* @group integration
10-
* @group integration-mysqli
11-
*/
10+
#[Attributes\Group('integration')]
11+
#[Attributes\Group('integration-mysqli')]
12+
#[Attributes\CoversMethod(Connection::class, 'connect')]
13+
#[Attributes\CoversMethod(Connection::class, 'disconnect')]
1214
final class ConnectionTest extends TestCase
1315
{
1416
use TraitSetup;
1517

16-
public function testConnectionOk(): void
18+
public function testConnection(): void
1719
{
1820
$connection = new Connection($this->variables);
1921
$connection->connect();
2022

2123
self::assertTrue($connection->isConnected());
2224
$connection->disconnect();
25+
self::assertFalse($connection->isConnected());
2326
}
2427
}

test/integration/Driver/Mysqli/TableGatewayTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
use Laminas\Db\Mysql\Platform;
99
use Laminas\Db\ResultSet\ResultSet;
1010
use Laminas\Db\TableGateway\TableGateway;
11+
use PHPUnit\Framework\Attributes;
1112
use PHPUnit\Framework\TestCase;
1213

14+
#[Attributes\Group('integration')]
15+
#[Attributes\Group('integration-mysqli')]
16+
#[Attributes\CoversClass(TableGateway::class)]
17+
#[Attributes\CoversMethod(TableGateway::class, '__construct')]
1318
final class TableGatewayTest extends TestCase
1419
{
1520
use TraitSetup;

test/integration/Driver/Pdo/AbstractAdapterTestCase.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44

55
use Laminas\Db\Adapter\AdapterInterface;
66
use Laminas\Db\Mysql\Adapter;
7+
use Laminas\Db\Mysql\Driver\Pdo\Connection;
8+
use PHPUnit\Framework\Attributes;
79
use PHPUnit\Framework\TestCase;
810

911
use function getmypid;
1012
use function shell_exec;
1113

14+
#[Attributes\Group('integration')]
15+
#[Attributes\Group('integration-pdo')]
16+
#[Attributes\CoversClass(Adapter::class)]
17+
#[Attributes\CoversMethod(Adapter::class, '__construct')]
18+
#[Attributes\CoversClass(Connection::class)]
19+
#[Attributes\CoversMethod(Connection::class, 'connect')]
20+
#[Attributes\CoversMethod(Connection::class, 'disconnect')]
1221
abstract class AbstractAdapterTestCase extends TestCase
1322
{
1423
/** @var ?int */
1524
public const DB_SERVER_PORT = null;
1625

1726
protected AdapterInterface&Adapter $adapter;
1827

19-
/**
20-
* @covers \Laminas\Db\Adapter\Adapter::__construct()
21-
*/
2228
public function testConnection(): void
2329
{
2430
$this->assertInstanceOf(Adapter::class, $this->adapter);

test/integration/Driver/Pdo/AdapterTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
namespace LaminasIntegrationTest\Db\Mysql\Driver\Pdo;
44

5+
use PHPUnit\Framework\Attributes;
6+
7+
#[Attributes\Group('integration')]
8+
#[Attributes\Group('integration-pdo')]
9+
#[Attributes\CoversNothing()]
510
final class AdapterTest extends AbstractAdapterTestCase
611
{
712
use AdapterTrait;

test/integration/Driver/Pdo/QueryTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22

33
namespace LaminasIntegrationTest\Db\Mysql\Driver\Pdo;
44

5-
use Laminas\Db\Mysql\Driver\Pdo\Result as PdoResult;
65
use Laminas\Db\Adapter\Exception\RuntimeException;
6+
use Laminas\Db\Mysql\Adapter;
7+
use Laminas\Db\Mysql\Driver\Pdo\Result as PdoResult;
78
use Laminas\Db\ResultSet\ResultSet;
89
use Laminas\Db\Sql\Sql;
910
use Laminas\Stdlib\ArrayObject;
11+
use PHPUnit\Framework\Attributes;
1012
use PHPUnit\Framework\TestCase;
1113

14+
#[Attributes\Group('integration')]
15+
#[Attributes\Group('integration-pdo')]
16+
#[Attributes\CoversMethod(Adapter::class, 'query')]
17+
#[Attributes\CoversMethod(ResultSet::class, 'current')]
1218
final class QueryTest extends TestCase
1319
{
1420
use AdapterTrait;
@@ -36,11 +42,7 @@ public static function getQueriesWithRowResult(): array
3642
];
3743
}
3844

39-
/**
40-
* @dataProvider getQueriesWithRowResult
41-
* @covers \Laminas\Db\Adapter\Adapter::query
42-
* @covers \Laminas\Db\ResultSet\ResultSet::current
43-
*/
45+
#[Attributes\DataProvider('getQueriesWithRowResult')]
4446
public function testQuery(string $query, array $params, array $expected): void
4547
{
4648
$result = $this->adapter->query($query, $params);

test/integration/Driver/Pdo/TableGatewayAndAdapterTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Laminas\Db\ResultSet\ResultSet;
66
use Laminas\Db\Sql\Select;
77
use Laminas\Db\TableGateway\TableGateway;
8+
use PHPUnit\Framework\Attributes;
89
use PHPUnit\Framework\TestCase;
910

1011
use function array_fill;
@@ -15,24 +16,30 @@
1516
* On tear down disconnected from the database and set the driver adapter on null
1617
* Running many tests ended up in consuming all mysql connections and not releasing them
1718
*/
19+
#[Attributes\Group('integration')]
20+
#[Attributes\Group('integration-pdo')]
21+
#[Attributes\CoversClass(TableGateway::class)]
22+
#[Attributes\CoversMethod(TableGateway::class, '__construct')]
23+
#[Attributes\CoversMethod(TableGateway::class, 'getSql')]
24+
#[Attributes\CoversMethod(TableGateway::class, 'selectWith')]
1825
final class TableGatewayAndAdapterTest extends TestCase
1926
{
2027
use AdapterTrait;
2128

22-
/**
23-
* @dataProvider connections
24-
*/
29+
#[Attributes\DataProvider('connections')]
2530
public function testGetOutOfConnections(): void
2631
{
2732
$this->adapter->query('SELECT VERSION();');
28-
$table = new TableGateway(
33+
$table = new TableGateway(
2934
'test',
3035
$this->adapter
3136
);
3237
/** @var Select */
3338
$select = $table->getSql()->select()->where(['name' => 'foo']);
39+
self::assertInstanceOf(Select::class, $select);
3440
/** @var ResultSet */
3541
$result = $table->selectWith($select);
42+
self::assertInstanceOf(ResultSet::class, $result);
3643
/** @psalm-suppress PossiblyNullArgument */
3744
self::assertCount(3, $result->current());
3845
}

test/integration/Driver/Pdo/TableGatewayTest.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,29 @@
88
use Laminas\Db\TableGateway\Feature\MetadataFeature;
99
use Laminas\Db\TableGateway\TableGateway;
1010
use Laminas\Stdlib\ArrayObject;
11+
use PHPUnit\Framework\Attributes;
1112
use PHPUnit\Framework\TestCase;
1213
use Webmozart\Assert\Assert;
1314

1415
use function count;
1516

17+
#[Attributes\Group('integration')]
18+
#[Attributes\Group('integration-pdo')]
19+
#[Attributes\CoversClass(TableGateway::class)]
20+
#[Attributes\CoversMethod(TableGateway::class, '__construct')]
21+
#[Attributes\CoversMethod(TableGateway::class, 'select')]
22+
#[Attributes\CoversMethod(TableGateway::class, 'insert')]
23+
#[Attributes\CoversMethod(TableGateway::class, 'update')]
1624
final class TableGatewayTest extends TestCase
1725
{
1826
use AdapterTrait;
1927

20-
/**
21-
* @covers \Laminas\Db\TableGateway\TableGateway::__construct
22-
*/
2328
public function testConstructor(): void
2429
{
2530
$tableGateway = new TableGateway('test', $this->adapter);
2631
$this->assertInstanceOf(TableGateway::class, $tableGateway);
2732
}
2833

29-
/**
30-
* @covers \Laminas\Db\TableGateway\TableGateway::select
31-
*/
3234
public function testSelect(): void
3335
{
3436
$tableGateway = new TableGateway('test', $this->adapter);
@@ -44,10 +46,6 @@ public function testSelect(): void
4446
}
4547
}
4648

47-
/**
48-
* @covers \Laminas\Db\TableGateway\TableGateway::insert
49-
* @covers \Laminas\Db\TableGateway\TableGateway::select
50-
*/
5149
public function testInsert(): void
5250
{
5351
$tableGateway = new TableGateway('test', $this->adapter);
@@ -90,9 +88,9 @@ public function testInsertWithExtendedCharsetFieldName(): int
9088
}
9189

9290
/**
93-
* @depends testInsertWithExtendedCharsetFieldName
9491
* @param mixed $id
9592
*/
93+
#[Attributes\Depends('testInsertWithExtendedCharsetFieldName')]
9694
public function testUpdateWithExtendedCharsetFieldName($id): void
9795
{
9896
Assert::isInstanceOf($this->adapter, AdapterInterface::class);
@@ -116,9 +114,9 @@ public function testUpdateWithExtendedCharsetFieldName($id): void
116114
}
117115

118116
/**
119-
* @dataProvider tableProvider
120117
* @param string|TableIdentifier|array $table
121118
*/
119+
#[Attributes\DataProvider('tableProvider')]
122120
public function testTableGatewayWithMetadataFeature($table): void
123121
{
124122
Assert::isInstanceOf($this->adapter, AdapterInterface::class);
@@ -130,7 +128,6 @@ public function testTableGatewayWithMetadataFeature($table): void
130128

131129
/**
132130
* @psalm-return array<array-key, array{0: string|TableIdentifier|array}>
133-
*
134131
* */
135132
public static function tableProvider(): array
136133
{

0 commit comments

Comments
 (0)