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(); + } +}