Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
* reverts some changes and keeps some deprecations
  • Loading branch information
JulianMar committed Sep 3, 2024
1 parent bc2c807 commit 4cdfaab
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
28 changes: 9 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
<?xml version="1.0"?>
<phpunit
bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
>
<testsuite name="Crate-DBAL unit tests">
<directory>./test/Crate/Test</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<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">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuite name="Crate-DBAL unit tests">
<directory>./test/Crate/Test</directory>
</testsuite>
</phpunit>
6 changes: 3 additions & 3 deletions test/Crate/Test/DBAL/Functional/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Crate\PDO\PDOCrateDB;
use Crate\Test\DBAL\DBALFunctionalTestCase;

class ConnectionTestCase extends DBALFunctionalTestCase
class ConnectionTest extends DBALFunctionalTestCase
{
public function setUp() : void
{
Expand All @@ -49,7 +49,7 @@ public function testBasicAuthConnection()
'password' => $auth[1],
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($params);
$this->assertEquals($auth[0], $conn->getParams()['username']);
$this->assertEquals($auth[0], $conn->getParams()['user']);
$this->assertEquals($auth[1], $conn->getParams()['password']);
$auth_attr = $conn->getWrappedConnection()->getAttribute(PDOCrateDB::CRATE_ATTR_HTTP_BASIC_AUTH);
$this->assertEquals($auth_attr, $auth);
Expand Down Expand Up @@ -82,7 +82,7 @@ public function testConnect()
$stmt = $this->_conn->executeQuery('select * from sys.cluster');
$this->assertEquals(1, $stmt->rowCount());

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

Expand Down
8 changes: 4 additions & 4 deletions test/Crate/Test/DBAL/Functional/DataAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use PDO;


class DataAccessTestCase extends DBALFunctionalTestCase
class DataAccessTest extends DBALFunctionalTestCase
{
static private $generated = false;

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

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

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

$this->assertEquals('foo', $testString);
}
Expand Down Expand Up @@ -485,7 +485,7 @@ public function testFetchAllStyleColumn()
$this->refresh("fetch_table");

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

$this->assertEquals(array(1, 10), $rows);
}
Expand Down
6 changes: 3 additions & 3 deletions test/Crate/Test/DBAL/Functional/WriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public function testExecuteUpdateFirstTypeIsNull()
$this->refresh('write_table');

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

public function testExecuteUpdate()
Expand Down
11 changes: 8 additions & 3 deletions test/Crate/Test/DBAL/Platforms/CratePlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DBAL\Platforms\AbstractPlatformTestCase;
use Doctrine\Tests\DBAL\Platforms\GetAlterTableSqlDispatchEventListener;

class CratePlatformTest extends AbstractPlatformTestCase {

Expand Down Expand Up @@ -402,11 +403,15 @@ public function testGeneratesTableAlterationSql() : void
public function testGetAlterTableSqlDispatchEvent() : void
{
$events = array(
'onSchemaAlterTableAddColumn'
'onSchemaAlterTableAddColumn',
'onSchemaAlterTableChangeColumn',
'onSchemaAlterTableRemoveColumn',
'onSchemaAlterTableRenameColumn',
'onSchemaAlterTable'
);

$listenerMock = $this->getMockBuilder('GetAlterTableSqlDispatchEvenListener')
->addMethods($events)
$listenerMock = $this->getMockBuilder(GetAlterTableSqlDispatchEventListener::class)
->onlyMethods($events)
->getMock();
$listenerMock
->expects($this->once())
Expand Down

0 comments on commit 4cdfaab

Please sign in to comment.