-
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.
Merge pull request #7 from stratedge/feature/implement-commit-and-rol…
…lback Feature/implement commit and rollback
- Loading branch information
Showing
10 changed files
with
349 additions
and
7 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Tests\PDO\PDO; | ||
|
||
use PDOException; | ||
use Stratedge\Wye\Wye; | ||
|
||
class CommitTest extends \Tests\TestCase | ||
{ | ||
public function testNoTransactionThrowsException() | ||
{ | ||
$this->setExpectedException(PDOException::class); | ||
|
||
Wye::makePDO()->commit(); | ||
} | ||
|
||
public function testMarksLastTransactionCommitted() | ||
{ | ||
$pdo = Wye::makePDO(); | ||
|
||
$pdo->beginTransaction(); | ||
|
||
$transaction = Wye::currentTransaction(); | ||
|
||
$this->assertFalse($transaction->getCommitted()); | ||
|
||
$pdo->commit(); | ||
|
||
$this->assertTrue($transaction->getCommitted()); | ||
} | ||
|
||
public function testReturnsTrue() | ||
{ | ||
$pdo = Wye::makePDO(); | ||
|
||
$pdo->beginTransaction(); | ||
|
||
$this->assertTrue($pdo->commit()); | ||
} | ||
|
||
public function testMarksWyeNoLongerInTransaction() | ||
{ | ||
$pdo = Wye::makePDO(); | ||
|
||
$this->assertFalse(Wye::getInTransaction()); | ||
|
||
$pdo->beginTransaction(); | ||
|
||
$this->assertTrue(Wye::getInTransaction()); | ||
|
||
$pdo->commit(); | ||
|
||
$this->assertFalse(Wye::getInTransaction()); | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
namespace Tests\PDO\PDO; | ||
|
||
use PDOException; | ||
use Stratedge\Wye\Wye; | ||
|
||
class RollBackTest extends \Tests\TestCase | ||
{ | ||
public function testNoTransactionThrowsException() | ||
{ | ||
$this->setExpectedException(PDOException::class); | ||
|
||
Wye::makePDO()->rollBack(); | ||
} | ||
|
||
public function testMarksLastTransactionRolledBack() | ||
{ | ||
$pdo = Wye::makePDO(); | ||
|
||
$pdo->beginTransaction(); | ||
|
||
$transaction = Wye::currentTransaction(); | ||
|
||
$this->assertFalse($transaction->getRolledBack()); | ||
|
||
$pdo->rollBack(); | ||
|
||
$this->assertTrue($transaction->getRolledBack()); | ||
} | ||
|
||
public function testReturnsTrue() | ||
{ | ||
$pdo = Wye::makePDO(); | ||
|
||
$pdo->beginTransaction(); | ||
|
||
$this->assertTrue($pdo->rollBack()); | ||
} | ||
|
||
public function testMarksWyeNoLongerInTransaction() | ||
{ | ||
$pdo = Wye::makePDO(); | ||
|
||
$this->assertFalse(Wye::getInTransaction()); | ||
|
||
$pdo->beginTransaction(); | ||
|
||
$this->assertTrue(Wye::getInTransaction()); | ||
|
||
$pdo->rollBack(); | ||
|
||
$this->assertFalse(Wye::getInTransaction()); | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace Tests\Transaction; | ||
|
||
use Stratedge\Wye\Wye; | ||
|
||
class GetRolledBackTest extends \Tests\TestCase | ||
{ | ||
public function testReturnsPropertyValue() | ||
{ | ||
$transaction = Wye::makeTransaction(); | ||
|
||
$this->assertFalse($transaction->getRolledBack()); | ||
|
||
$transaction->setRolledBack(true); | ||
|
||
$this->assertTrue($transaction->getRolledBack()); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Tests\Transaction; | ||
|
||
use Stratedge\Wye\Wye; | ||
|
||
class SetRolledBackTest extends \Tests\TestCase | ||
{ | ||
public function testSetsPropertyValue() | ||
{ | ||
$transaction = Wye::makeTransaction(); | ||
|
||
$this->assertFalse($transaction->getRolledBack()); | ||
|
||
$transaction->setRolledBack(true); | ||
|
||
$this->assertTrue($transaction->getRolledBack()); | ||
|
||
$transaction->setRolledBack(false); | ||
|
||
$this->assertFalse($transaction->getRolledBack()); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Tests\Wye; | ||
|
||
use PDOException; | ||
use Stratedge\Wye\Wye; | ||
|
||
class CommitTransactionTest extends \Tests\TestCase | ||
{ | ||
public function testNoTransactionThrowsException() | ||
{ | ||
$this->setExpectedException(PDOException::class); | ||
Wye::commitTransaction(); | ||
} | ||
|
||
public function testMarksTransactionCommitted() | ||
{ | ||
Wye::beginTransaction(); | ||
|
||
$transaction = Wye::currentTransaction(); | ||
|
||
$this->assertFalse($transaction->getCommitted()); | ||
|
||
Wye::commitTransaction(); | ||
|
||
$this->assertTrue($transaction->getCommitted()); | ||
} | ||
|
||
public function testSetsInTransactionToFalse() | ||
{ | ||
$this->assertFalse(Wye::getInTransaction()); | ||
|
||
Wye::beginTransaction(); | ||
|
||
$this->assertTrue(Wye::getInTransaction()); | ||
|
||
Wye::commitTransaction(); | ||
|
||
$this->assertFalse(Wye::getInTransaction()); | ||
} | ||
} |
Oops, something went wrong.