From d671145572fd3983f2a6170b4d2b116b77d3b82a Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Sun, 8 Nov 2020 23:17:59 +0100 Subject: [PATCH] Failing test case for #4400 --- .../Tests/DBAL/Functional/LockModeTest.php | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php diff --git a/tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php b/tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php new file mode 100644 index 00000000000..e4bcbe449ef --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php @@ -0,0 +1,75 @@ +c1 = TestUtil::getConnection(); + $this->c2 = TestUtil::getConnection(); + + $table = new Table('users'); + $table->addColumn('id', 'integer'); + + $this->c1->getSchemaManager()->createTable($table); + + if ($this->c2->getSchemaManager()->tablesExist('users')) { + return; + } + + if ($this->c2->getDatabasePlatform() instanceof SqlitePlatform) { + self::markTestSkipped('This test cannot run on SQLite using an in-memory database'); + } + + self::fail('Separate connections do not seem to talk to the same database'); + } + + public function tearDown(): void + { + $this->c1->getSchemaManager()->dropTable('users'); + + $this->c1->close(); + $this->c2->close(); + } + + public function testLockModeNoneDoesNotBreakTransactionIsolation(): void + { + try { + $this->c1->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); + $this->c2->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); + } catch (Exception $e) { + self::markTestSkipped('This test must be able to set a transaction isolation level'); + } + + $this->c1->beginTransaction(); + $this->c2->beginTransaction(); + + $this->c1->insert('users', ['id' => 1]); + + $query = 'SELECT id FROM users'; + $query = $this->c2->getDatabasePlatform()->appendLockHint($query, LockMode::NONE); + + self::assertFalse($this->c2->fetchOne($query)); + + $this->c1->commit(); + $this->c2->commit(); + } +}