From 115e17b67eb9b1297e6ec15f16f8de2f58417177 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 --- phpunit.xml.dist | 4 +- .../Tests/DBAL/Functional/LockModeTest.php | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f79efc83e40..85e41c7b4f7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -23,14 +23,14 @@ - + diff --git a/tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php b/tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php new file mode 100644 index 00000000000..73c904992e3 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/LockModeTest.php @@ -0,0 +1,70 @@ +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 + { + $this->c1->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); + $this->c2->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); + + $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(); + } +}