Skip to content

Commit

Permalink
connection: rename method to getTransactionNestedIndex() and add to i…
Browse files Browse the repository at this point in the history
…nterface (BC break!)
  • Loading branch information
hrach committed May 7, 2020
1 parent 3a3aa4d commit 2da9cff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,8 @@ public function rollbackTransaction(): void
}


/**
* Returns current connection's transaction index.
* 0 = no running transaction
* 1 = basic transaction
* >1 = nested transaction through savepoints
* Todo: Add this method to interface in v4
* @return int
*/
public function getTransactionIndex(): int
/** @inheritdoc */
public function getTransactionNestedIndex(): int
{
return $this->nestedTransactionIndex;
}
Expand Down
9 changes: 9 additions & 0 deletions src/IConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ public function commitTransaction(): void;
public function rollbackTransaction(): void;


/**
* Returns current connection's transaction nested index.
* 0 = no running transaction
* 1 = basic transaction
* >1 = nested transaction through save-points
*/
public function getTransactionNestedIndex(): int;


/**
* Creates a savepoint.
* @throws DriverException
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/integration/transactions.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ class TransactionsTest extends IntegrationTestCase

$this->connection->rollbackTransaction();
$this->connection->rollbackTransaction();
Assert::same(0, $this->connection->getTransactionIndex());
Assert::same(0, $this->connection->getTransactionNestedIndex());

$this->connection->commitTransaction();
$this->connection->commitTransaction();
Assert::same(0, $this->connection->getTransactionIndex());
Assert::same(0, $this->connection->getTransactionNestedIndex());
}


Expand Down

0 comments on commit 2da9cff

Please sign in to comment.