diff --git a/core/modules/pgsql/tests/src/Unit/SchemaTest.php b/core/modules/pgsql/tests/src/Unit/SchemaTest.php index 1dd286a2187c94563ae0705b50b83527b673527e..40317a9fa17c3cef286be1f88a9a51663bdf86c7 100644 --- a/core/modules/pgsql/tests/src/Unit/SchemaTest.php +++ b/core/modules/pgsql/tests/src/Unit/SchemaTest.php @@ -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); } diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 54219d5f9bce530ae74109ddfbf1e95881b966f8..5eb7a3bda49de044097741e145036dbb36eef1fc 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -2078,11 +2078,6 @@ parameters: count: 1 path: modules/pgsql/src/Update10101.php - - - message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#" - count: 1 - path: modules/pgsql/tests/src/Unit/SchemaTest.php - - message: "#^Variable \\$responsive_image_styles in empty\\(\\) always exists and is not falsy\\.$#" count: 1