Skip to content

Commit

Permalink
cover exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 12, 2020
1 parent 6042141 commit 9348097
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;

use DateTime;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
Expand Down Expand Up @@ -237,6 +238,29 @@ public function testAlterTableExplicitColumnPosition(): void
self::assertSame(['id', 'new', 'b', 'a'], array_keys($this->schemaManager->listTableColumns($tableName)));
}

public function testAlterTableExplicitColumnPositionColumnNotFoundException(): void
{
$tableName = 'test_column_position';
$table = new Table($tableName);
$table->addColumn('id', 'integer');

$this->schemaManager->createTable($table);

$table2 = new Table($tableName);
$table2->addColumn('id', 'float');
$table2->addColumn('a', 'float');
$table2WithoutAColumn = new Table($tableName);
$table2WithoutAColumn->addColumn('id', 'float');

$comparator = new Comparator();
$diff = $comparator->diffTable($table, $table2);
$diff->toTable = $table2WithoutAColumn;

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('~Column name "a" not found');
$this->schemaManager->alterTable($diff);
}

public function testColumnCharset(): void
{
$table = new Table('test_column_charset');
Expand Down

0 comments on commit 9348097

Please sign in to comment.