forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the OCI8Connection::getExecuteMode() method
The existing relationship between the connection and its statement violate the ISP principle. Instead of having access only to the execution mode of the connection, statements have access to the entire connection API. Having a method which is not defined in the driver connection interface makes it impossible to mark the method `final` (doctrine#3590).
- Loading branch information
Showing
4 changed files
with
86 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Driver\OCI8; | ||
|
||
/** | ||
* Encapsulates the execution mode that is shared between the connection and its statements. | ||
*/ | ||
final class ExecutionMode | ||
{ | ||
/** @var bool */ | ||
private $isAutoCommitEnabled = true; | ||
|
||
public function enableAutoCommit() : void | ||
{ | ||
$this->isAutoCommitEnabled = true; | ||
} | ||
|
||
public function disableAutoCommit() : void | ||
{ | ||
$this->isAutoCommitEnabled = false; | ||
} | ||
|
||
public function isAutoCommitEnabled() : bool | ||
{ | ||
return $this->isAutoCommitEnabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/Doctrine/Tests/DBAL/Driver/OCI8/ExecutionModeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\DBAL\Driver\OCI8; | ||
|
||
use Doctrine\DBAL\Driver\OCI8\ExecutionMode; | ||
use PHPStan\Testing\TestCase; | ||
|
||
final class ExecutionModeTest extends TestCase | ||
{ | ||
/** @var ExecutionMode */ | ||
private $mode; | ||
|
||
protected function setUp() : void | ||
{ | ||
$this->mode = new ExecutionMode(); | ||
} | ||
|
||
public function testDefaultAutoCommitStatus() : void | ||
{ | ||
self::assertTrue($this->mode->isAutoCommitEnabled()); | ||
} | ||
|
||
public function testChangeAutoCommitStatus() : void | ||
{ | ||
$this->mode->disableAutoCommit(); | ||
self::assertFalse($this->mode->isAutoCommitEnabled()); | ||
|
||
$this->mode->enableAutoCommit(); | ||
self::assertTrue($this->mode->isAutoCommitEnabled()); | ||
} | ||
} |