Got rid of or reworked the assertions which are no longer needed due to improved type system

parent ac0e13a1
...@@ -1300,7 +1300,6 @@ abstract class AbstractPlatform ...@@ -1300,7 +1300,6 @@ abstract class AbstractPlatform
if (($createFlags & self::CREATE_INDEXES) > 0) { if (($createFlags & self::CREATE_INDEXES) > 0) {
foreach ($table->getIndexes() as $index) { foreach ($table->getIndexes() as $index) {
assert($index instanceof Index);
if (! $index->isPrimary()) { if (! $index->isPrimary()) {
$options['indexes'][$index->getQuotedName($this)] = $index; $options['indexes'][$index->getQuotedName($this)] = $index;
......
...@@ -20,7 +20,6 @@ use function array_diff; ...@@ -20,7 +20,6 @@ use function array_diff;
use function array_merge; use function array_merge;
use function array_unique; use function array_unique;
use function array_values; use function array_values;
use function assert;
use function count; use function count;
use function explode; use function explode;
use function implode; use function implode;
...@@ -424,7 +423,6 @@ SQL ...@@ -424,7 +423,6 @@ SQL
} }
foreach ($diff->changedColumns as $columnDiff) { foreach ($diff->changedColumns as $columnDiff) {
assert($columnDiff instanceof ColumnDiff);
if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) { if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
continue; continue;
} }
......
...@@ -1050,10 +1050,6 @@ class SqlitePlatform extends AbstractPlatform ...@@ -1050,10 +1050,6 @@ class SqlitePlatform extends AbstractPlatform
} }
foreach ($diff->removedForeignKeys as $constraint) { foreach ($diff->removedForeignKeys as $constraint) {
if (! $constraint instanceof ForeignKeyConstraint) {
$constraint = new Identifier($constraint);
}
$constraintName = $constraint->getName(); $constraintName = $constraint->getName();
if ($constraintName === '') { if ($constraintName === '') {
......
...@@ -107,8 +107,6 @@ class Comparator ...@@ -107,8 +107,6 @@ class Comparator
} }
foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) { foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) {
assert($removedForeignKey instanceof ForeignKeyConstraint);
// We check if the key is from the removed table if not we skip. // We check if the key is from the removed table if not we skip.
if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) { if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) {
continue; continue;
......
...@@ -19,7 +19,6 @@ use function array_keys; ...@@ -19,7 +19,6 @@ use function array_keys;
use function array_merge; use function array_merge;
use function array_search; use function array_search;
use function array_unique; use function array_unique;
use function assert;
use function in_array; use function in_array;
use function is_string; use function is_string;
use function preg_match; use function preg_match;
...@@ -257,7 +256,6 @@ class Table extends AbstractAsset ...@@ -257,7 +256,6 @@ class Table extends AbstractAsset
public function columnsAreIndexed(array $columnNames) : bool public function columnsAreIndexed(array $columnNames) : bool
{ {
foreach ($this->getIndexes() as $index) { foreach ($this->getIndexes() as $index) {
assert($index instanceof Index);
if ($index->spansColumns($columnNames)) { if ($index->spansColumns($columnNames)) {
return true; return true;
} }
......
...@@ -107,23 +107,11 @@ class ConnectionTest extends TestCase ...@@ -107,23 +107,11 @@ class ConnectionTest extends TestCase
$this->connection->isRollbackOnly(); $this->connection->isRollbackOnly();
} }
public function testGetConfiguration() : void
{
$config = $this->connection->getConfiguration();
self::assertInstanceOf(Configuration::class, $config);
}
public function testGetDriver() : void public function testGetDriver() : void
{ {
self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver());
} }
public function testGetEventManager() : void
{
self::assertInstanceOf(EventManager::class, $this->connection->getEventManager());
}
public function testConnectDispatchEvent() : void public function testConnectDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener')) $listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener'))
......
...@@ -53,7 +53,6 @@ class DBALExceptionTest extends TestCase ...@@ -53,7 +53,6 @@ class DBALExceptionTest extends TestCase
$url = 'mysql://localhost'; $url = 'mysql://localhost';
$exception = DriverRequired::new($url); $exception = DriverRequired::new($url);
self::assertInstanceOf(DBALException::class, $exception);
self::assertSame( self::assertSame(
sprintf( sprintf(
'The options "driver" or "driverClass" are mandatory if a connection URL without scheme ' . 'The options "driver" or "driverClass" are mandatory if a connection URL without scheme ' .
......
...@@ -4,7 +4,6 @@ declare(strict_types=1); ...@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Exception; namespace Doctrine\DBAL\Tests\Exception;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\DriverRequired; use Doctrine\DBAL\Exception\DriverRequired;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function sprintf; use function sprintf;
...@@ -16,7 +15,6 @@ class DriverRequiredTest extends TestCase ...@@ -16,7 +15,6 @@ class DriverRequiredTest extends TestCase
$url = 'mysql://localhost'; $url = 'mysql://localhost';
$exception = DriverRequired::new($url); $exception = DriverRequired::new($url);
self::assertInstanceOf(DBALException::class, $exception);
self::assertSame( self::assertSame(
sprintf( sprintf(
'The options "driver" or "driverClass" are mandatory if a connection URL without scheme ' . 'The options "driver" or "driverClass" are mandatory if a connection URL without scheme ' .
......
...@@ -5,7 +5,6 @@ declare(strict_types=1); ...@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Exception; namespace Doctrine\DBAL\Tests\Exception;
use Doctrine\DBAL\Exception\EmptyCriteriaNotAllowed; use Doctrine\DBAL\Exception\EmptyCriteriaNotAllowed;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class EmptyCriteriaNotAllowedTest extends TestCase class EmptyCriteriaNotAllowedTest extends TestCase
...@@ -14,7 +13,6 @@ class EmptyCriteriaNotAllowedTest extends TestCase ...@@ -14,7 +13,6 @@ class EmptyCriteriaNotAllowedTest extends TestCase
{ {
$exception = EmptyCriteriaNotAllowed::new(); $exception = EmptyCriteriaNotAllowed::new();
self::assertInstanceOf(InvalidArgumentException::class, $exception);
self::assertSame('Empty criteria was used, expected non-empty criteria.', $exception->getMessage()); self::assertSame('Empty criteria was used, expected non-empty criteria.', $exception->getMessage());
} }
} }
...@@ -4,7 +4,6 @@ declare(strict_types=1); ...@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Exception; namespace Doctrine\DBAL\Tests\Exception;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\InvalidColumnIndex; use Doctrine\DBAL\Exception\InvalidColumnIndex;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
...@@ -14,7 +13,6 @@ class InvalidColumnIndexTest extends TestCase ...@@ -14,7 +13,6 @@ class InvalidColumnIndexTest extends TestCase
{ {
$exception = InvalidColumnIndex::new(5, 1); $exception = InvalidColumnIndex::new(5, 1);
self::assertInstanceOf(DBALException::class, $exception);
self::assertSame('Invalid column index 5. The statement result contains 1 column.', $exception->getMessage()); self::assertSame('Invalid column index 5. The statement result contains 1 column.', $exception->getMessage());
} }
...@@ -22,7 +20,6 @@ class InvalidColumnIndexTest extends TestCase ...@@ -22,7 +20,6 @@ class InvalidColumnIndexTest extends TestCase
{ {
$exception = InvalidColumnIndex::new(5, 2); $exception = InvalidColumnIndex::new(5, 2);
self::assertInstanceOf(DBALException::class, $exception);
self::assertSame('Invalid column index 5. The statement result contains 2 columns.', $exception->getMessage()); self::assertSame('Invalid column index 5. The statement result contains 2 columns.', $exception->getMessage());
} }
} }
...@@ -6,10 +6,8 @@ namespace Doctrine\DBAL\Tests\Functional; ...@@ -6,10 +6,8 @@ namespace Doctrine\DBAL\Tests\Functional;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ConnectionException; use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
...@@ -41,11 +39,6 @@ class ConnectionTest extends FunctionalTestCase ...@@ -41,11 +39,6 @@ class ConnectionTest extends FunctionalTestCase
$this->resetSharedConn(); $this->resetSharedConn();
} }
public function testGetWrappedConnection() : void
{
self::assertInstanceOf(DriverConnection::class, $this->connection->getWrappedConnection());
}
public function testCommitWithRollbackOnlyThrowsException() : void public function testCommitWithRollbackOnlyThrowsException() : void
{ {
$this->connection->beginTransaction(); $this->connection->beginTransaction();
...@@ -346,7 +339,6 @@ class ConnectionTest extends FunctionalTestCase ...@@ -346,7 +339,6 @@ class ConnectionTest extends FunctionalTestCase
$this->connection->getEventManager() $this->connection->getEventManager()
); );
self::assertInstanceOf(AbstractPlatform::class, $connection->getDatabasePlatform());
self::assertFalse($connection->isConnected()); self::assertFalse($connection->isConnected());
self::assertSame($params, $connection->getParams()); self::assertSame($params, $connection->getParams());
......
...@@ -6,7 +6,6 @@ namespace Doctrine\DBAL\Tests\Functional\Driver; ...@@ -6,7 +6,6 @@ namespace Doctrine\DBAL\Tests\Functional\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
abstract class AbstractDriverTest extends FunctionalTestCase abstract class AbstractDriverTest extends FunctionalTestCase
...@@ -36,9 +35,8 @@ abstract class AbstractDriverTest extends FunctionalTestCase ...@@ -36,9 +35,8 @@ abstract class AbstractDriverTest extends FunctionalTestCase
$user = $params['user'] ?? ''; $user = $params['user'] ?? '';
$password = $params['password'] ?? ''; $password = $params['password'] ?? '';
$connection = $this->driver->connect($params, $user, $password); $this->expectNotToPerformAssertions();
$this->driver->connect($params, $user, $password);
self::assertInstanceOf(DriverConnection::class, $connection);
} }
/** /**
......
...@@ -51,7 +51,6 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -51,7 +51,6 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
$names = $this->schemaManager->getSchemaNames(); $names = $this->schemaManager->getSchemaNames();
self::assertIsArray($names);
self::assertNotEmpty($names); self::assertNotEmpty($names);
self::assertContains('public', $names, 'The public schema should be found.'); self::assertContains('public', $names, 'The public schema should be found.');
} }
...@@ -143,7 +142,6 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -143,7 +142,6 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertNotNull($diff); self::assertNotNull($diff);
self::assertInstanceOf(TableDiff::class, $diff, 'There should be a difference and not false being returned from the table comparison');
self::assertEquals(['ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT'], $this->connection->getDatabasePlatform()->getAlterTableSQL($diff)); self::assertEquals(['ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT'], $this->connection->getDatabasePlatform()->getAlterTableSQL($diff));
$this->schemaManager->alterTable($diff); $this->schemaManager->alterTable($diff);
...@@ -380,7 +378,6 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -380,7 +378,6 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$foundTable = false; $foundTable = false;
foreach ($tables as $table) { foreach ($tables as $table) {
self::assertInstanceOf(Table::class, $table, 'No Table instance was found in tables array.');
if (strtolower($table->getName()) !== 'list_tables_excludes_views_test_view') { if (strtolower($table->getName()) !== 'list_tables_excludes_views_test_view') {
continue; continue;
} }
......
...@@ -24,7 +24,6 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -24,7 +24,6 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
$views = $this->schemaManager->listViews(); $views = $this->schemaManager->listViews();
self::assertCount(1, $views, 'Database has to have one view.'); self::assertCount(1, $views, 'Database has to have one view.');
self::assertInstanceOf(View::class, $views[$name]);
self::assertEquals($name, $views[$name]->getName()); self::assertEquals($name, $views[$name]->getName());
self::assertRegExp('/^SELECT \* from "?DBA"?\."?view_test_table"?$/', $views[$name]->getSql()); self::assertRegExp('/^SELECT \* from "?DBA"?\."?view_test_table"?$/', $views[$name]->getSql());
} }
...@@ -39,7 +38,6 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -39,7 +38,6 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
); );
$tableIndexes = $this->schemaManager->listTableIndexes('test_create_advanced_index'); $tableIndexes = $this->schemaManager->listTableIndexes('test_create_advanced_index');
self::assertIsArray($tableIndexes);
self::assertEquals('test', $tableIndexes['test']->getName()); self::assertEquals('test', $tableIndexes['test']->getName());
self::assertEquals(['test'], $tableIndexes['test']->getColumns()); self::assertEquals(['test'], $tableIndexes['test']->getColumns());
self::assertTrue($tableIndexes['test']->isUnique()); self::assertTrue($tableIndexes['test']->isUnique());
......
...@@ -6,7 +6,6 @@ namespace Doctrine\DBAL\Tests\Functional\Schema; ...@@ -6,7 +6,6 @@ namespace Doctrine\DBAL\Tests\Functional\Schema;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\OraclePlatform;
...@@ -126,8 +125,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -126,8 +125,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$connection = $this->connection->getDriver()->connect($params, $user, $password); $connection = $this->connection->getDriver()->connect($params, $user, $password);
self::assertInstanceOf(Connection::class, $connection);
$this->schemaManager->dropDatabase('test_drop_database'); $this->schemaManager->dropDatabase('test_drop_database');
self::assertNotContains('test_drop_database', $this->schemaManager->listDatabases()); self::assertNotContains('test_drop_database', $this->schemaManager->listDatabases());
...@@ -181,12 +178,8 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -181,12 +178,8 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$sequence = new Sequence('list_sequences_test_seq', 20, 10); $sequence = new Sequence('list_sequences_test_seq', 20, 10);
$this->schemaManager->createSequence($sequence); $this->schemaManager->createSequence($sequence);
$sequences = $this->schemaManager->listSequences();
self::assertIsArray($sequences, 'listSequences() should return an array.');
$foundSequence = null; $foundSequence = null;
foreach ($sequences as $sequence) { foreach ($sequences = $this->schemaManager->listSequences() as $sequence) {
self::assertInstanceOf(Sequence::class, $sequence, 'Array elements of listSequences() should be Sequence instances.'); self::assertInstanceOf(Sequence::class, $sequence, 'Array elements of listSequences() should be Sequence instances.');
if (strtolower($sequence->getName()) !== 'list_sequences_test_seq') { if (strtolower($sequence->getName()) !== 'list_sequences_test_seq') {
continue; continue;
...@@ -242,12 +235,10 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -242,12 +235,10 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$this->createTestTable('list_tables_test'); $this->createTestTable('list_tables_test');
$tables = $this->schemaManager->listTables(); $tables = $this->schemaManager->listTables();
self::assertIsArray($tables); self::assertNotEmpty($tables, "List Tables has to find at least one table named 'list_tables_test'.");
self::assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'.");
$foundTable = false; $foundTable = false;
foreach ($tables as $table) { foreach ($tables as $table) {
self::assertInstanceOf(Table::class, $table);
if (strtolower($table->getName()) !== 'list_tables_test') { if (strtolower($table->getName()) !== 'list_tables_test') {
continue; continue;
} }
...@@ -293,7 +284,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -293,7 +284,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
self::assertEquals(false, $columns['id']->getunsigned()); self::assertEquals(false, $columns['id']->getunsigned());
self::assertEquals(true, $columns['id']->getnotnull()); self::assertEquals(true, $columns['id']->getnotnull());
self::assertEquals(null, $columns['id']->getdefault()); self::assertEquals(null, $columns['id']->getdefault());
self::assertIsArray($columns['id']->getPlatformOptions());
self::assertArrayHasKey('test', $columns); self::assertArrayHasKey('test', $columns);
self::assertEquals(1, array_search('test', $columnsKeys)); self::assertEquals(1, array_search('test', $columnsKeys));
...@@ -303,7 +293,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -303,7 +293,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
self::assertEquals(false, $columns['test']->getFixed()); self::assertEquals(false, $columns['test']->getFixed());
self::assertEquals(false, $columns['test']->getNotnull()); self::assertEquals(false, $columns['test']->getNotnull());
self::assertEquals('expected default', $columns['test']->getDefault()); self::assertEquals('expected default', $columns['test']->getDefault());
self::assertIsArray($columns['test']->getPlatformOptions());
self::assertEquals('foo', strtolower($columns['foo']->getName())); self::assertEquals('foo', strtolower($columns['foo']->getName()));
self::assertEquals(2, array_search('foo', $columnsKeys)); self::assertEquals(2, array_search('foo', $columnsKeys));
...@@ -312,7 +301,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -312,7 +301,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
self::assertEquals(false, $columns['foo']->getFixed()); self::assertEquals(false, $columns['foo']->getFixed());
self::assertEquals(true, $columns['foo']->getNotnull()); self::assertEquals(true, $columns['foo']->getNotnull());
self::assertEquals(null, $columns['foo']->getDefault()); self::assertEquals(null, $columns['foo']->getDefault());
self::assertIsArray($columns['foo']->getPlatformOptions());
self::assertEquals('bar', strtolower($columns['bar']->getName())); self::assertEquals('bar', strtolower($columns['bar']->getName()));
self::assertEquals(3, array_search('bar', $columnsKeys)); self::assertEquals(3, array_search('bar', $columnsKeys));
...@@ -324,28 +312,24 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -324,28 +312,24 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
self::assertEquals(false, $columns['bar']->getFixed()); self::assertEquals(false, $columns['bar']->getFixed());
self::assertEquals(false, $columns['bar']->getNotnull()); self::assertEquals(false, $columns['bar']->getNotnull());
self::assertEquals(null, $columns['bar']->getDefault()); self::assertEquals(null, $columns['bar']->getDefault());
self::assertIsArray($columns['bar']->getPlatformOptions());
self::assertEquals('baz1', strtolower($columns['baz1']->getName())); self::assertEquals('baz1', strtolower($columns['baz1']->getName()));
self::assertEquals(4, array_search('baz1', $columnsKeys)); self::assertEquals(4, array_search('baz1', $columnsKeys));
self::assertInstanceOf(DateTimeType::class, $columns['baz1']->getType()); self::assertInstanceOf(DateTimeType::class, $columns['baz1']->getType());
self::assertEquals(true, $columns['baz1']->getNotnull()); self::assertEquals(true, $columns['baz1']->getNotnull());
self::assertEquals(null, $columns['baz1']->getDefault()); self::assertEquals(null, $columns['baz1']->getDefault());
self::assertIsArray($columns['baz1']->getPlatformOptions());
self::assertEquals('baz2', strtolower($columns['baz2']->getName())); self::assertEquals('baz2', strtolower($columns['baz2']->getName()));
self::assertEquals(5, array_search('baz2', $columnsKeys)); self::assertEquals(5, array_search('baz2', $columnsKeys));
self::assertContains($columns['baz2']->getType()->getName(), ['time', 'date', 'datetime']); self::assertContains($columns['baz2']->getType()->getName(), ['time', 'date', 'datetime']);
self::assertEquals(true, $columns['baz2']->getNotnull()); self::assertEquals(true, $columns['baz2']->getNotnull());
self::assertEquals(null, $columns['baz2']->getDefault()); self::assertEquals(null, $columns['baz2']->getDefault());
self::assertIsArray($columns['baz2']->getPlatformOptions());
self::assertEquals('baz3', strtolower($columns['baz3']->getName())); self::assertEquals('baz3', strtolower($columns['baz3']->getName()));
self::assertEquals(6, array_search('baz3', $columnsKeys)); self::assertEquals(6, array_search('baz3', $columnsKeys));
self::assertContains($columns['baz3']->getType()->getName(), ['time', 'date', 'datetime']); self::assertContains($columns['baz3']->getType()->getName(), ['time', 'date', 'datetime']);
self::assertEquals(true, $columns['baz3']->getNotnull()); self::assertEquals(true, $columns['baz3']->getNotnull());
self::assertEquals(null, $columns['baz3']->getDefault()); self::assertEquals(null, $columns['baz3']->getDefault());
self::assertIsArray($columns['baz3']->getPlatformOptions());
} }
/** /**
...@@ -475,7 +459,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -475,7 +459,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$this->schemaManager->dropAndCreateIndex($table->getIndex('test'), $table); $this->schemaManager->dropAndCreateIndex($table->getIndex('test'), $table);
$tableIndexes = $this->schemaManager->listTableIndexes('test_create_index'); $tableIndexes = $this->schemaManager->listTableIndexes('test_create_index');
self::assertIsArray($tableIndexes);
self::assertEquals('test', strtolower($tableIndexes['test']->getName())); self::assertEquals('test', strtolower($tableIndexes['test']->getName()));
self::assertEquals(['test'], array_map('strtolower', $tableIndexes['test']->getColumns())); self::assertEquals(['test'], array_map('strtolower', $tableIndexes['test']->getColumns()));
...@@ -532,9 +515,8 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -532,9 +515,8 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk1'); $fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk1');
self::assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key."); self::assertCount(1, $fkeys, "Table 'test_create_fk1' has to have one foreign key.");
self::assertInstanceOf(ForeignKeyConstraint::class, $fkeys[0]);
self::assertEquals(['foreign_key_test'], array_map('strtolower', $fkeys[0]->getLocalColumns())); self::assertEquals(['foreign_key_test'], array_map('strtolower', $fkeys[0]->getLocalColumns()));
self::assertEquals(['id'], array_map('strtolower', $fkeys[0]->getForeignColumns())); self::assertEquals(['id'], array_map('strtolower', $fkeys[0]->getForeignColumns()));
self::assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName())); self::assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName()));
...@@ -1037,8 +1019,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -1037,8 +1019,6 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$foundTable = false; $foundTable = false;
foreach ($tables as $table) { foreach ($tables as $table) {
self::assertInstanceOf(Table::class, $table, 'No Table instance was found in tables array.');
if (strtolower($table->getName()) !== 'list_tables_test_new_name') { if (strtolower($table->getName()) !== 'list_tables_test_new_name') {
continue; continue;
} }
...@@ -1069,9 +1049,8 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -1069,9 +1049,8 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk3'); $fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk3');
self::assertEquals(1, count($fkeys), "Table 'test_create_fk3' has to have one foreign key."); self::assertCount(1, $fkeys, "Table 'test_create_fk3' has to have one foreign key.");
self::assertInstanceOf(ForeignKeyConstraint::class, $fkeys[0]);
self::assertEquals(['id', 'foreign_key_test'], array_map('strtolower', $fkeys[0]->getLocalColumns())); self::assertEquals(['id', 'foreign_key_test'], array_map('strtolower', $fkeys[0]->getLocalColumns()));
self::assertEquals(['id', 'other_id'], array_map('strtolower', $fkeys[0]->getForeignColumns())); self::assertEquals(['id', 'other_id'], array_map('strtolower', $fkeys[0]->getForeignColumns()));
} }
......
...@@ -5,7 +5,6 @@ declare(strict_types=1); ...@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Functional\Schema; namespace Doctrine\DBAL\Tests\Functional\Schema;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
...@@ -58,8 +57,6 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -58,8 +57,6 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
$connection = $this->connection->getDriver()->connect($params, $user, $password); $connection = $this->connection->getDriver()->connect($params, $user, $password);
self::assertInstanceOf(Connection::class, $connection);
$this->schemaManager->dropDatabase('test_drop_database'); $this->schemaManager->dropDatabase('test_drop_database');
self::assertFileNotExists('test_drop_database'); self::assertFileNotExists('test_drop_database');
......
...@@ -8,7 +8,6 @@ use Doctrine\Common\EventManager; ...@@ -8,7 +8,6 @@ use Doctrine\Common\EventManager;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
...@@ -266,14 +265,15 @@ abstract class AbstractPlatformTestCase extends TestCase ...@@ -266,14 +265,15 @@ abstract class AbstractPlatformTestCase extends TestCase
public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys() : void public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys() : void
{ {
$fk = new ForeignKeyConstraint(['fk_name'], 'foreign', ['id'], 'constraint_fk');
if ($this->platform->supportsForeignKeyConstraints()) { if ($this->platform->supportsForeignKeyConstraints()) {
self::assertIsString($this->platform->getCreateForeignKeySQL($fk, 'test')); self::markTestSkipped('The platform supports foreign key constraints');
} else {
$this->expectException(DBALException::class);
$this->platform->getCreateForeignKeySQL($fk, 'test');
} }
$this->expectException(DBALException::class);
$this->platform->getCreateForeignKeySQL(
new ForeignKeyConstraint(['fk_name'], 'foreign', ['id'], 'constraint_fk'),
'test'
);
} }
protected function getBitAndComparisonExpressionSql(string $value1, string $value2) : string protected function getBitAndComparisonExpressionSql(string $value1, string $value2) : string
...@@ -619,7 +619,6 @@ abstract class AbstractPlatformTestCase extends TestCase ...@@ -619,7 +619,6 @@ abstract class AbstractPlatformTestCase extends TestCase
public function testKeywordList() : void public function testKeywordList() : void
{ {
$keywordList = $this->platform->getReservedKeywordsList(); $keywordList = $this->platform->getReservedKeywordsList();
self::assertInstanceOf(KeywordList::class, $keywordList);
self::assertTrue($keywordList->isKeyword('table')); self::assertTrue($keywordList->isKeyword('table'));
} }
......
...@@ -15,7 +15,6 @@ use Doctrine\DBAL\Schema\TableDiff; ...@@ -15,7 +15,6 @@ use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use UnexpectedValueException; use UnexpectedValueException;
use function assert;
use function sprintf; use function sprintf;
abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCase abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCase
...@@ -921,8 +920,6 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa ...@@ -921,8 +920,6 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testReturnsDisallowDatabaseConnectionsSQL() : void public function testReturnsDisallowDatabaseConnectionsSQL() : void
{ {
assert($this->platform instanceof PostgreSQL94Platform);
self::assertSame( self::assertSame(
"UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'foo'", "UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'foo'",
$this->platform->getDisallowDatabaseConnectionsSQL('foo') $this->platform->getDisallowDatabaseConnectionsSQL('foo')
...@@ -934,8 +931,6 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa ...@@ -934,8 +931,6 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testReturnsCloseActiveDatabaseConnectionsSQL() : void public function testReturnsCloseActiveDatabaseConnectionsSQL() : void
{ {
assert($this->platform instanceof PostgreSQL94Platform);
self::assertSame( self::assertSame(
"SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'foo'", "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'foo'",
$this->platform->getCloseActiveDatabaseConnectionsSQL('foo') $this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
...@@ -1024,8 +1019,6 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa ...@@ -1024,8 +1019,6 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() : void public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() : void
{ {
assert($this->platform instanceof PostgreSQL94Platform);
self::assertStringContainsStringIgnoringCase( self::assertStringContainsStringIgnoringCase(
"'Foo''Bar\\'", "'Foo''Bar\\'",
$this->platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\") $this->platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\")
......
...@@ -8,7 +8,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -8,7 +8,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use function assert;
class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase
{ {
...@@ -97,8 +96,6 @@ class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase ...@@ -97,8 +96,6 @@ class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase
*/ */
public function testReturnsCloseActiveDatabaseConnectionsSQL() : void public function testReturnsCloseActiveDatabaseConnectionsSQL() : void
{ {
assert($this->platform instanceof PostgreSQL94Platform);
self::assertSame( self::assertSame(
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'", "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'",
$this->platform->getCloseActiveDatabaseConnectionsSQL('foo') $this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
......
...@@ -10,7 +10,6 @@ use Doctrine\DBAL\Connection; ...@@ -10,7 +10,6 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\Schema\MySqlSchemaManager;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
...@@ -42,7 +41,6 @@ class MySqlSchemaManagerTest extends TestCase ...@@ -42,7 +41,6 @@ class MySqlSchemaManagerTest extends TestCase
$fkeys = $this->manager->listTableForeignKeys('dummy'); $fkeys = $this->manager->listTableForeignKeys('dummy');
self::assertCount(1, $fkeys, 'Table has to have one foreign key.'); self::assertCount(1, $fkeys, 'Table has to have one foreign key.');
self::assertInstanceOf(ForeignKeyConstraint::class, $fkeys[0]);
self::assertEquals(['column_1', 'column_2', 'column_3'], array_map('strtolower', $fkeys[0]->getLocalColumns())); self::assertEquals(['column_1', 'column_2', 'column_3'], array_map('strtolower', $fkeys[0]->getLocalColumns()));
self::assertEquals(['column_1', 'column_2', 'column_3'], array_map('strtolower', $fkeys[0]->getForeignColumns())); self::assertEquals(['column_1', 'column_2', 'column_3'], array_map('strtolower', $fkeys[0]->getForeignColumns()));
} }
......
...@@ -100,7 +100,6 @@ class SchemaTest extends TestCase ...@@ -100,7 +100,6 @@ class SchemaTest extends TestCase
$table = $schema->createTable('foo'); $table = $schema->createTable('foo');
self::assertInstanceOf(Table::class, $table);
self::assertEquals('foo', $table->getName()); self::assertEquals('foo', $table->getName());
self::assertTrue($schema->hasTable('foo')); self::assertTrue($schema->hasTable('foo'));
} }
...@@ -112,7 +111,7 @@ class SchemaTest extends TestCase ...@@ -112,7 +111,7 @@ class SchemaTest extends TestCase
$schema = new Schema([], [$sequence]); $schema = new Schema([], [$sequence]);
self::assertTrue($schema->hasSequence('a_seq')); self::assertTrue($schema->hasSequence('a_seq'));
self::assertInstanceOf(Sequence::class, $schema->getSequence('a_seq')); self::assertSame('a_seq', $schema->getSequence('a_seq')->getName());
$sequences = $schema->getSequences(); $sequences = $schema->getSequences();
self::assertArrayHasKey('public.a_seq', $sequences); self::assertArrayHasKey('public.a_seq', $sequences);
...@@ -150,7 +149,7 @@ class SchemaTest extends TestCase ...@@ -150,7 +149,7 @@ class SchemaTest extends TestCase
self::assertEquals(20, $sequence->getInitialValue()); self::assertEquals(20, $sequence->getInitialValue());
self::assertTrue($schema->hasSequence('a_seq')); self::assertTrue($schema->hasSequence('a_seq'));
self::assertInstanceOf(Sequence::class, $schema->getSequence('a_seq')); self::assertSame('a_seq', $schema->getSequence('a_seq')->getName());
$sequences = $schema->getSequences(); $sequences = $schema->getSequences();
self::assertArrayHasKey('public.a_seq', $sequences); self::assertArrayHasKey('public.a_seq', $sequences);
......
...@@ -46,8 +46,8 @@ class TableTest extends TestCase ...@@ -46,8 +46,8 @@ class TableTest extends TestCase
self::assertTrue($table->hasColumn('bar')); self::assertTrue($table->hasColumn('bar'));
self::assertFalse($table->hasColumn('baz')); self::assertFalse($table->hasColumn('baz'));
self::assertInstanceOf(Column::class, $table->getColumn('foo')); self::assertSame('foo', $table->getColumn('foo')->getName());
self::assertInstanceOf(Column::class, $table->getColumn('bar')); self::assertSame('bar', $table->getColumn('bar')->getName());
self::assertCount(2, $table->getColumns()); self::assertCount(2, $table->getColumns());
} }
...@@ -161,9 +161,9 @@ class TableTest extends TestCase ...@@ -161,9 +161,9 @@ class TableTest extends TestCase
self::assertTrue($table->hasIndex('bar_idx')); self::assertTrue($table->hasIndex('bar_idx'));
self::assertFalse($table->hasIndex('some_idx')); self::assertFalse($table->hasIndex('some_idx'));
self::assertInstanceOf(Index::class, $table->getPrimaryKey()); self::assertNotNull($table->getPrimaryKey());
self::assertInstanceOf(Index::class, $table->getIndex('the_primary')); self::assertSame('the_primary', $table->getIndex('the_primary')->getName());
self::assertInstanceOf(Index::class, $table->getIndex('bar_idx')); self::assertSame('bar_idx', $table->getIndex('bar_idx')->getName());
} }
public function testGetUnknownIndexThrowsException() : void public function testGetUnknownIndexThrowsException() : void
...@@ -833,18 +833,12 @@ class TableTest extends TestCase ...@@ -833,18 +833,12 @@ class TableTest extends TestCase
self::assertTrue($table->hasColumn($assetName)); self::assertTrue($table->hasColumn($assetName));
self::assertTrue($table->hasColumn('foo')); self::assertTrue($table->hasColumn('foo'));
self::assertInstanceOf(Column::class, $table->getColumn($assetName));
self::assertInstanceOf(Column::class, $table->getColumn('foo'));
self::assertTrue($table->hasIndex($assetName)); self::assertTrue($table->hasIndex($assetName));
self::assertTrue($table->hasIndex('foo')); self::assertTrue($table->hasIndex('foo'));
self::assertInstanceOf(Index::class, $table->getIndex($assetName));
self::assertInstanceOf(Index::class, $table->getIndex('foo'));
self::assertTrue($table->hasForeignKey($assetName)); self::assertTrue($table->hasForeignKey($assetName));
self::assertTrue($table->hasForeignKey('foo')); self::assertTrue($table->hasForeignKey('foo'));
self::assertInstanceOf(ForeignKeyConstraint::class, $table->getForeignKey($assetName));
self::assertInstanceOf(ForeignKeyConstraint::class, $table->getForeignKey('foo'));
$table->renameIndex($assetName, $assetName); $table->renameIndex($assetName, $assetName);
self::assertTrue($table->hasIndex($assetName)); self::assertTrue($table->hasIndex($assetName));
......
...@@ -30,8 +30,6 @@ abstract class BaseDateTypeTestCase extends TestCase ...@@ -30,8 +30,6 @@ abstract class BaseDateTypeTestCase extends TestCase
{ {
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class);
$this->currentTimezone = date_default_timezone_get(); $this->currentTimezone = date_default_timezone_get();
self::assertInstanceOf(Type::class, $this->type);
} }
protected function tearDown() : void protected function tearDown() : void
......
...@@ -4,7 +4,6 @@ declare(strict_types=1); ...@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Types; namespace Doctrine\DBAL\Tests\Types;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Exception\InvalidFormat; use Doctrine\DBAL\Types\Exception\InvalidFormat;
use Doctrine\DBAL\Types\Exception\InvalidType; use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\DBAL\Types\Exception\ValueNotConvertible; use Doctrine\DBAL\Types\Exception\ValueNotConvertible;
...@@ -25,7 +24,6 @@ class ConversionExceptionTest extends TestCase ...@@ -25,7 +24,6 @@ class ConversionExceptionTest extends TestCase
$exception = ValueNotConvertible::new('foo', 'foo', null, $previous); $exception = ValueNotConvertible::new('foo', 'foo', null, $previous);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame($previous, $exception->getPrevious()); self::assertSame($previous, $exception->getPrevious());
} }
...@@ -40,7 +38,6 @@ class ConversionExceptionTest extends TestCase ...@@ -40,7 +38,6 @@ class ConversionExceptionTest extends TestCase
$type = is_object($scalarValue) ? get_class($scalarValue) : gettype($scalarValue); $type = is_object($scalarValue) ? get_class($scalarValue) : gettype($scalarValue);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame( self::assertSame(
sprintf( sprintf(
'Could not convert PHP value "%s" of type "%s" to type "foo". Expected one of the following types: bar, baz.', 'Could not convert PHP value "%s" of type "%s" to type "foo". Expected one of the following types: bar, baz.',
...@@ -62,7 +59,6 @@ class ConversionExceptionTest extends TestCase ...@@ -62,7 +59,6 @@ class ConversionExceptionTest extends TestCase
$type = is_object($nonScalar) ? get_class($nonScalar) : gettype($nonScalar); $type = is_object($nonScalar) ? get_class($nonScalar) : gettype($nonScalar);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame( self::assertSame(
sprintf('Could not convert PHP value of type "%s" to type "foo". Expected one of the following types: bar, baz.', $type), sprintf('Could not convert PHP value of type "%s" to type "foo". Expected one of the following types: bar, baz.', $type),
$exception->getMessage() $exception->getMessage()
...@@ -75,7 +71,6 @@ class ConversionExceptionTest extends TestCase ...@@ -75,7 +71,6 @@ class ConversionExceptionTest extends TestCase
$exception = InvalidType::new('foo', 'foo', ['bar', 'baz'], $previous); $exception = InvalidType::new('foo', 'foo', ['bar', 'baz'], $previous);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame($previous, $exception->getPrevious()); self::assertSame($previous, $exception->getPrevious());
} }
...@@ -85,7 +80,6 @@ class ConversionExceptionTest extends TestCase ...@@ -85,7 +80,6 @@ class ConversionExceptionTest extends TestCase
$exception = InvalidFormat::new('foo', 'bar', 'baz', $previous); $exception = InvalidFormat::new('foo', 'bar', 'baz', $previous);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame($previous, $exception->getPrevious()); self::assertSame($previous, $exception->getPrevious());
} }
......
...@@ -5,10 +5,8 @@ declare(strict_types=1); ...@@ -5,10 +5,8 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Types\Exception; namespace Doctrine\DBAL\Tests\Types\Exception;
use Doctrine\DBAL\Types\Exception\TypeAlreadyRegistered; use Doctrine\DBAL\Types\Exception\TypeAlreadyRegistered;
use Doctrine\DBAL\Types\Exception\TypesException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function preg_match;
class TypeAlreadyRegisteredTest extends TestCase class TypeAlreadyRegisteredTest extends TestCase
{ {
...@@ -16,7 +14,9 @@ class TypeAlreadyRegisteredTest extends TestCase ...@@ -16,7 +14,9 @@ class TypeAlreadyRegisteredTest extends TestCase
{ {
$exception = TypeAlreadyRegistered::new(Type::getType('string')); $exception = TypeAlreadyRegistered::new(Type::getType('string'));
self::assertInstanceOf(TypesException::class, $exception); self::assertRegExp(
self::assertTrue(preg_match('/Type of the class Doctrine\\\DBAL\\\Types\\\StringType@([0-9a-zA-Z]+) is already registered./', $exception->getMessage()) === 1); '/Type of the class Doctrine\\\DBAL\\\Types\\\StringType@([0-9a-zA-Z]+) is already registered./',
$exception->getMessage()
);
} }
} }
...@@ -5,10 +5,8 @@ declare(strict_types=1); ...@@ -5,10 +5,8 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Types\Exception; namespace Doctrine\DBAL\Tests\Types\Exception;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered; use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Exception\TypesException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function preg_match;
class TypeNotRegisteredTest extends TestCase class TypeNotRegisteredTest extends TestCase
{ {
...@@ -16,7 +14,9 @@ class TypeNotRegisteredTest extends TestCase ...@@ -16,7 +14,9 @@ class TypeNotRegisteredTest extends TestCase
{ {
$exception = TypeNotRegistered::new(Type::getType('string')); $exception = TypeNotRegistered::new(Type::getType('string'));
self::assertInstanceOf(TypesException::class, $exception); self::assertRegExp(
self::assertTrue(preg_match('/Type of the class Doctrine\\\DBAL\\\Types\\\StringType@([0-9a-zA-Z]+) is not registered./', $exception->getMessage()) === 1); '/Type of the class Doctrine\\\DBAL\\\Types\\\StringType@([0-9a-zA-Z]+) is not registered./',
$exception->getMessage()
);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment