Skip to content
Snippets Groups Projects

Fix postgres test

Closed Alex Pott requested to merge issue/drupal-3405976:3405976-10.2.x-fix-postgres into 10.2.x
1 file
+ 10
4
Compare changes
  • Side-by-side
  • Inline
@@ -896,15 +896,21 @@ public function testTransactionManagerFailureOnPendingStackItems(): void {
@@ -896,15 +896,21 @@ public function testTransactionManagerFailureOnPendingStackItems(): void {
$reflectionProperty = new \ReflectionProperty(TransactionManagerBase::class, 'connectionTransactionState');
$reflectionProperty = new \ReflectionProperty(TransactionManagerBase::class, 'connectionTransactionState');
$reflectionProperty->setValue($manager, ClientConnectionTransactionState::Active);
$reflectionProperty->setValue($manager, ClientConnectionTransactionState::Active);
$this->expectException(\AssertionError::class);
$this->expectExceptionMessageMatches("/^Transaction .stack was not empty\\. Active stack: bar\\\\qux/");
// Ensure that __destruct() results in an assertion error. Note that this
// Ensure that __destruct() results in an assertion error. Note that this
// will normally be called by PHP during the object's destruction but Drupal
// will normally be called by PHP during the object's destruction but Drupal
// will commit all transactions when a database is closed thereby making
// will commit all transactions when a database is closed thereby making
// this impossible to test with calling it directly.
// this impossible to test unless it is called directly.
$manager->__destruct();
try {
 
$manager->__destruct();
 
$this->fail("Expected AssertionError error not thrown");
 
}
 
catch (\AssertionError $e) {
 
$this->assertStringStartsWith('Transaction $stack was not empty. Active stack: bar\\qux', $e->getMessage());
 
}
// Clean up.
// Clean up.
 
$reflectionProperty = new \ReflectionProperty(TransactionManagerBase::class, 'stack');
 
$reflectionProperty->setValue($manager, []);
unset($testConnection);
unset($testConnection);
Database::closeConnection('test_fail');
Database::closeConnection('test_fail');
}
}
Loading