Skip to content

Commit 939399e

Browse files
committed
fix: tests
* reverts some changes and keeps some deprecations
1 parent b85becd commit 939399e

File tree

5 files changed

+27
-32
lines changed

5 files changed

+27
-32
lines changed

phpunit.xml.dist

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
<?xml version="1.0"?>
2-
<phpunit
3-
bootstrap="./vendor/autoload.php"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
verbose="true"
9-
stopOnFailure="false"
10-
processIsolation="false"
11-
backupGlobals="false"
12-
>
13-
<testsuite name="Crate-DBAL unit tests">
14-
<directory>./test/Crate/Test</directory>
15-
</testsuite>
16-
<filter>
17-
<whitelist addUncoveredFilesFromWhitelist="true">
18-
<directory suffix=".php">./src</directory>
19-
</whitelist>
20-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" verbose="true" stopOnFailure="false" processIsolation="false" backupGlobals="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage includeUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
</coverage>
8+
<testsuite name="Crate-DBAL unit tests">
9+
<directory>./test/Crate/Test</directory>
10+
</testsuite>
2111
</phpunit>

test/Crate/Test/DBAL/Functional/ConnectionTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Crate\PDO\PDOCrateDB;
2525
use Crate\Test\DBAL\DBALFunctionalTestCase;
2626

27-
class ConnectionTestCase extends DBALFunctionalTestCase
27+
class ConnectionTest extends DBALFunctionalTestCase
2828
{
2929
public function setUp() : void
3030
{
@@ -49,7 +49,7 @@ public function testBasicAuthConnection()
4949
'password' => $auth[1],
5050
);
5151
$conn = \Doctrine\DBAL\DriverManager::getConnection($params);
52-
$this->assertEquals($auth[0], $conn->getParams()['username']);
52+
$this->assertEquals($auth[0], $conn->getParams()['user']);
5353
$this->assertEquals($auth[1], $conn->getParams()['password']);
5454
$auth_attr = $conn->getWrappedConnection()->getAttribute(PDOCrateDB::CRATE_ATTR_HTTP_BASIC_AUTH);
5555
$this->assertEquals($auth_attr, $auth);
@@ -82,7 +82,7 @@ public function testConnect()
8282
$stmt = $this->_conn->executeQuery('select * from sys.cluster');
8383
$this->assertEquals(1, $stmt->rowCount());
8484

85-
$row = $stmt->fetchOne();
85+
$row = $stmt->fetchAssociative();
8686
$this->assertEquals('crate', $row['name']);
8787
}
8888

test/Crate/Test/DBAL/Functional/DataAccessTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
use PDO;
3535

3636

37-
class DataAccessTestCase extends DBALFunctionalTestCase
37+
class DataAccessTest extends DBALFunctionalTestCase
3838
{
3939
static private $generated = false;
4040

@@ -164,7 +164,7 @@ public function testPrepareWithFetchAllBoth()
164164
$stmt->bindParam(2, $paramStr, PDO::PARAM_STR);
165165
$result = $stmt->executeQuery();
166166

167-
$rows = $result->fetchAllAssociative();
167+
$rows = $result->fetchAll(PDO::FETCH_BOTH);
168168
$rows[0] = array_change_key_case($rows[0], \CASE_LOWER);
169169
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'), $rows[0]);
170170
}
@@ -296,7 +296,7 @@ public function testFetchColumn()
296296
$this->assertEquals(1, $testInt);
297297

298298
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
299-
$testString = $this->_conn->fetchOne($sql, array(1, 'foo'));
299+
$testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1);
300300

301301
$this->assertEquals('foo', $testString);
302302
}
@@ -485,7 +485,7 @@ public function testFetchAllStyleColumn()
485485
$this->refresh("fetch_table");
486486

487487
$sql = "SELECT test_int FROM fetch_table ORDER BY test_int ASC";
488-
$rows = $this->_conn->executeQuery($sql)->fetchOne();
488+
$rows = $this->_conn->executeQuery($sql)->fetchAll(PDO::FETCH_COLUMN);
489489

490490
$this->assertEquals(array(1, 10), $rows);
491491
}

test/Crate/Test/DBAL/Functional/WriteTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ public function testExecuteUpdateFirstTypeIsNull()
8282
$this->refresh('write_table');
8383

8484
$sql = "SELECT test_obj, test_string, test_int FROM write_table WHERE test_string = ? AND test_int = ?";
85-
$this->assertEquals($this->_conn->fetchOne($sql, array("text", 1111)), null);
86-
$this->assertEquals($this->_conn->fetchOne($sql, array("text", 1111)), "text");
87-
$this->assertEquals($this->_conn->fetchOne($sql, array("text", 1111)), 1111);
85+
$this->assertEquals($this->_conn->fetchColumn($sql, array("text", 1111)), null);
86+
$this->assertEquals($this->_conn->fetchColumn($sql, array("text", 1111), 1), "text");
87+
$this->assertEquals($this->_conn->fetchColumn($sql, array("text", 1111), 2), 1111);
8888
}
8989

9090
public function testExecuteUpdate()

test/Crate/Test/DBAL/Platforms/CratePlatformTest.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use Doctrine\DBAL\Types\Type;
3939
use Doctrine\DBAL\Types\Types;
4040
use Doctrine\Tests\DBAL\Platforms\AbstractPlatformTestCase;
41+
use Doctrine\Tests\DBAL\Platforms\GetAlterTableSqlDispatchEventListener;
4142

4243
class CratePlatformTest extends AbstractPlatformTestCase {
4344

@@ -402,11 +403,15 @@ public function testGeneratesTableAlterationSql() : void
402403
public function testGetAlterTableSqlDispatchEvent() : void
403404
{
404405
$events = array(
405-
'onSchemaAlterTableAddColumn'
406+
'onSchemaAlterTableAddColumn',
407+
'onSchemaAlterTableChangeColumn',
408+
'onSchemaAlterTableRemoveColumn',
409+
'onSchemaAlterTableRenameColumn',
410+
'onSchemaAlterTable'
406411
);
407412

408-
$listenerMock = $this->getMockBuilder('GetAlterTableSqlDispatchEvenListener')
409-
->addMethods($events)
413+
$listenerMock = $this->getMockBuilder(GetAlterTableSqlDispatchEventListener::class)
414+
->onlyMethods($events)
410415
->getMock();
411416
$listenerMock
412417
->expects($this->once())

0 commit comments

Comments
 (0)