-
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.
- Loading branch information
Showing
9 changed files
with
204 additions
and
0 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,20 @@ | ||
# phpstorm project files | ||
.idea | ||
|
||
# netbeans project files | ||
nbproject/* | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# Mac DS_Store Files | ||
.DS_Store | ||
|
||
/vendor/ | ||
composer.lock | ||
.phpunit.result.cache |
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,20 @@ | ||
FROM php:7.4-cli-alpine3.11 | ||
|
||
RUN apk add --no-cache \ | ||
libzip-dev \ | ||
openssl-dev && \ | ||
docker-php-ext-install -j$(nproc) \ | ||
zip | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer | ||
|
||
RUN apk add --no-cache --virtual .phpize_deps $PHPIZE_DEPS && \ | ||
pecl install xdebug-2.9.2 && \ | ||
docker-php-ext-enable xdebug && \ | ||
rm -rf /usr/share/php7 && \ | ||
rm -rf /tmp/pear && \ | ||
apk del .phpize_deps | ||
|
||
ENV PATH /var/app/bin:/var/app/vendor/bin:$PATH | ||
|
||
WORKDIR /var/app |
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,24 @@ | ||
UID=$(shell id -u) | ||
GID=$(shell id -g) | ||
DOCKER_PHP_SERVICE=php | ||
|
||
start: erase cache-folders build composer-install bash | ||
|
||
erase: | ||
docker-compose down -v | ||
|
||
build: | ||
docker-compose build && \ | ||
docker-compose pull | ||
|
||
cache-folders: | ||
mkdir -p ~/.composer && chown ${UID}:${GID} ~/.composer | ||
|
||
composer-install: | ||
docker-compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} composer install | ||
|
||
bash: | ||
docker-compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} sh | ||
|
||
logs: | ||
docker-compose logs -f ${DOCKER_PHP_SERVICE} |
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,32 @@ | ||
{ | ||
"name": "pccomponentes/dbal-transaction", | ||
"description": "DBAL Transaction", | ||
"authors": [ | ||
{ | ||
"name": "Sergio Hernández Martínez", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"license": "MIT", | ||
"type": "library", | ||
"autoload": { | ||
"psr-4": { | ||
"PcComponentes\\Transaction\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"PcComponentes\\Transaction\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require": { | ||
"php": "^7.4", | ||
"pccomponentes/transaction": "^1.0", | ||
"doctrine/dbal": "^2.10" | ||
}, | ||
"require-dev": { | ||
"pccomponentes/coding-standard": "^1.0", | ||
"phpunit/phpunit": "^8.5", | ||
"dg/bypass-finals": "^1.1" | ||
} | ||
} |
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,6 @@ | ||
version: '3.7' | ||
services: | ||
php: | ||
build: . | ||
volumes: | ||
- .:/var/app |
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,5 @@ | ||
<?xml version="1.0" ?> | ||
<ruleset name="Project rules"> | ||
<file>src</file> | ||
<rule ref="vendor/pccomponentes/coding-standard/PccomponentesCodingStandard/ruleset.xml" /> | ||
</ruleset> |
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,32 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PcComponentes\Transaction\Driver\DBAL; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
use PcComponentes\Transaction\Driver\TransactionalConnection; | ||
|
||
final class DBALTransactionalConnection implements TransactionalConnection | ||
{ | ||
private Connection $DBALConnection; | ||
|
||
public function __construct(Connection $DBALConnection) | ||
{ | ||
$this->DBALConnection = $DBALConnection; | ||
} | ||
|
||
public function beginTransaction(): void | ||
{ | ||
$this->DBALConnection->beginTransaction(); | ||
} | ||
|
||
public function commit(): void | ||
{ | ||
$this->DBALConnection->commit(); | ||
} | ||
|
||
public function rollBack(): void | ||
{ | ||
$this->DBALConnection->rollBack(); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PcComponentes\Transaction\Tests\Driver\DBAL; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
use PcComponentes\Transaction\Driver\DBAL\DBALTransactionalConnection; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class DBALTransactionalConnectionTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function given_dbal_connection_when_begin_transaction_then_it_is_done_in_dbal_connection() | ||
{ | ||
$DBALConnection = $this->createMock(Connection::class); | ||
|
||
$DBALConnection | ||
->expects($this->once()) | ||
->method('beginTransaction') | ||
; | ||
|
||
$transactionalConnection = new DBALTransactionalConnection($DBALConnection); | ||
$transactionalConnection->beginTransaction(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function given_dbal_connection_when_commit_then_it_is_done_in_dbal_connection() | ||
{ | ||
$DBALConnection = $this->createMock(Connection::class); | ||
|
||
$DBALConnection | ||
->expects($this->once()) | ||
->method('commit') | ||
; | ||
|
||
$transactionalConnection = new DBALTransactionalConnection($DBALConnection); | ||
$transactionalConnection->commit(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function given_dbal_connection_when_roll_back_then_it_is_done_in_dbal_connection() | ||
{ | ||
$DBALConnection = $this->createMock(Connection::class); | ||
|
||
$DBALConnection | ||
->expects($this->once()) | ||
->method('rollBack') | ||
; | ||
|
||
$transactionalConnection = new DBALTransactionalConnection($DBALConnection); | ||
$transactionalConnection->rollBack(); | ||
} | ||
} |
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,6 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
require dirname(__DIR__).'/vendor/autoload.php'; | ||
|
||
\DG\BypassFinals::enable(); |