Skip to content
Snippets Groups Projects

Remove withConsecutive() in pgsql SchemaTest.

Files

@@ -6,8 +6,7 @@
use Drupal\pgsql\Driver\Database\pgsql\Schema;
use Drupal\Tests\UnitTestCase;
// cSpell:ignore conname
use Prophecy\Argument;
/**
* @coversDefaultClass \Drupal\pgsql\Driver\Database\pgsql\Schema
@@ -15,24 +14,6 @@
*/
class SchemaTest extends UnitTestCase {
/**
* The PostgreSql DB connection.
*
* @var \PHPUnit\Framework\MockObject\MockObject|\Drupal\pgsql\Driver\Database\pgsql\Connection
*/
protected $connection;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->connection = $this->getMockBuilder('\Drupal\pgsql\Driver\Database\pgsql\Connection')
->disableOriginalConstructor()
->getMock();
}
/**
* Tests whether the actual constraint name is correctly computed.
*
@@ -48,24 +29,20 @@ protected function setUp(): void {
*/
public function testComputedConstraintName($table_name, $name, $expected) {
$max_identifier_length = 63;
$schema = new Schema($this->connection);
$statement = $this->createMock('\Drupal\Core\Database\StatementInterface');
$statement->expects($this->any())
->method('fetchField')
->willReturn($max_identifier_length);
$connection = $this->prophesize('\Drupal\pgsql\Driver\Database\pgsql\Connection');
$connection->getConnectionOptions()->willReturn([]);
$connection->getPrefix()->willReturn('');
$statement = $this->prophesize('\Drupal\Core\Database\StatementInterface');
$statement->fetchField()->willReturn($max_identifier_length);
$connection->query('SHOW max_identifier_length')->willReturn($statement->reveal());
$this->connection->expects($this->exactly(2))
->method('query')
->withConsecutive(
[$this->anything()],
["SELECT 1 FROM pg_constraint WHERE conname = '$expected'"],
)
->willReturnOnConsecutiveCalls(
$statement,
$this->createMock('\Drupal\Core\Database\StatementInterface'),
);
$connection->query(Argument::containingString($expected))
->willReturn($this->prophesize('\Drupal\Core\Database\StatementInterface')->reveal())
->shouldBeCalled();
$schema = new Schema($connection->reveal());
$schema->constraintExists($table_name, $name);
}
Loading