Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2019-09-19 03:58:37 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-09-19 03:58:37 +0300
commitf91a8090933e384bb503a77a51475157731bbeb6 (patch)
treec285816ab2d94f2b949d1e205970f389cf5e76c1 /tests/PHPUnit/Integration
parent3b60da8343e79a490e7459a4aab580f17a5c6ca4 (diff)
better handling of setting transaction level (#14899)
Diffstat (limited to 'tests/PHPUnit/Integration')
-rw-r--r--tests/PHPUnit/Integration/Db/TransactionLevelTest.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/Db/TransactionLevelTest.php b/tests/PHPUnit/Integration/Db/TransactionLevelTest.php
new file mode 100644
index 0000000000..3438108879
--- /dev/null
+++ b/tests/PHPUnit/Integration/Db/TransactionLevelTest.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Tests\Integration\Db;
+
+use Piwik\Db;
+use Piwik\Db\TransactionLevel;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+/**
+ * @group Funnels
+ * @group TransactionLevelTest
+ * @group TransactionLevel
+ * @group Plugins
+ */
+class TransactionLevelTest extends IntegrationTestCase
+{
+ /**
+ * @var TransactionLevel
+ */
+ private $level;
+
+ /**
+ * @var \Piwik\Tracker\Db|\Piwik\Db\AdapterInterface|\Piwik\Db $db
+ */
+ private $db;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->db = Db::get();
+ $this->level = new TransactionLevel($this->db);
+ }
+
+ public function test_canLikelySetTransactionLevel()
+ {
+ $this->assertTrue($this->level->canLikelySetTransactionLevel());
+ }
+
+ public function test_setUncommitted_restorePreviousStatus()
+ {
+ $value = $this->db->fetchOne('SELECT @@TX_ISOLATION');
+ $this->assertSame('REPEATABLE-READ', $value);
+
+ $this->level->setUncommitted();
+ $value = $this->db->fetchOne('SELECT @@TX_ISOLATION');
+
+ $this->assertSame('READ-UNCOMMITTED', $value);
+ $this->level->restorePreviousStatus();
+
+ $value = $this->db->fetchOne('SELECT @@TX_ISOLATION');
+ $this->assertSame('REPEATABLE-READ', $value);
+ }
+
+}