File tree Expand file tree Collapse file tree 9 files changed +204
-0
lines changed
Expand file tree Collapse file tree 9 files changed +204
-0
lines changed Original file line number Diff line number Diff line change 1+ # phpstorm project files
2+ .idea
3+
4+ # netbeans project files
5+ nbproject /*
6+
7+ # zend studio for eclipse project files
8+ .buildpath
9+ .project
10+ .settings
11+
12+ # windows thumbnail cache
13+ Thumbs.db
14+
15+ # Mac DS_Store Files
16+ .DS_Store
17+
18+ /vendor /
19+ composer.lock
20+ .phpunit.result.cache
Original file line number Diff line number Diff line change 1+ FROM php:7.4-cli-alpine3.11
2+
3+ RUN apk add --no-cache \
4+ libzip-dev \
5+ openssl-dev && \
6+ docker-php-ext-install -j$(nproc) \
7+ zip
8+
9+ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
10+
11+ RUN apk add --no-cache --virtual .phpize_deps $PHPIZE_DEPS && \
12+ pecl install xdebug-2.9.2 && \
13+ docker-php-ext-enable xdebug && \
14+ rm -rf /usr/share/php7 && \
15+ rm -rf /tmp/pear && \
16+ apk del .phpize_deps
17+
18+ ENV PATH /var/app/bin:/var/app/vendor/bin:$PATH
19+
20+ WORKDIR /var/app
Original file line number Diff line number Diff line change 1+ UID =$(shell id -u)
2+ GID =$(shell id -g)
3+ DOCKER_PHP_SERVICE =php
4+
5+ start : erase cache-folders build composer-install bash
6+
7+ erase :
8+ docker-compose down -v
9+
10+ build :
11+ docker-compose build && \
12+ docker-compose pull
13+
14+ cache-folders :
15+ mkdir -p ~ /.composer && chown ${UID} :${GID} ~ /.composer
16+
17+ composer-install :
18+ docker-compose run --rm -u ${UID} :${GID} ${DOCKER_PHP_SERVICE} composer install
19+
20+ bash :
21+ docker-compose run --rm -u ${UID} :${GID} ${DOCKER_PHP_SERVICE} sh
22+
23+ logs :
24+ docker-compose logs -f ${DOCKER_PHP_SERVICE}
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " pccomponentes/dbal-transaction" ,
3+ "description" : " DBAL Transaction" ,
4+ "authors" : [
5+ {
6+ "name" : " Sergio Hernández Martínez" ,
7+ "email" : " sergio.hernandez@pccomponentes.com"
8+ }
9+ ],
10+ "license" : " MIT" ,
11+ "type" : " library" ,
12+ "autoload" : {
13+ "psr-4" : {
14+ "PcComponentes\\ Transaction\\ " : " src/"
15+ }
16+ },
17+ "autoload-dev" : {
18+ "psr-4" : {
19+ "PcComponentes\\ Transaction\\ Tests\\ " : " tests/"
20+ }
21+ },
22+ "require" : {
23+ "php" : " ^7.4" ,
24+ "pccomponentes/transaction" : " ^1.0" ,
25+ "doctrine/dbal" : " ^2.10"
26+ },
27+ "require-dev" : {
28+ "pccomponentes/coding-standard" : " ^1.0" ,
29+ "phpunit/phpunit" : " ^8.5" ,
30+ "dg/bypass-finals" : " ^1.1"
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ version : ' 3.7'
2+ services :
3+ php :
4+ build : .
5+ volumes :
6+ - .:/var/app
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <ruleset name =" Project rules" >
3+ <file >src</file >
4+ <rule ref =" vendor/pccomponentes/coding-standard/PccomponentesCodingStandard/ruleset.xml" />
5+ </ruleset >
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace PcComponentes \Transaction \Driver \DBAL ;
5+
6+ use Doctrine \DBAL \Driver \Connection ;
7+ use PcComponentes \Transaction \Driver \TransactionalConnection ;
8+
9+ final class DBALTransactionalConnection implements TransactionalConnection
10+ {
11+ private Connection $ DBALConnection ;
12+
13+ public function __construct (Connection $ DBALConnection )
14+ {
15+ $ this ->DBALConnection = $ DBALConnection ;
16+ }
17+
18+ public function beginTransaction (): void
19+ {
20+ $ this ->DBALConnection ->beginTransaction ();
21+ }
22+
23+ public function commit (): void
24+ {
25+ $ this ->DBALConnection ->commit ();
26+ }
27+
28+ public function rollBack (): void
29+ {
30+ $ this ->DBALConnection ->rollBack ();
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace PcComponentes \Transaction \Tests \Driver \DBAL ;
5+
6+ use Doctrine \DBAL \Driver \Connection ;
7+ use PcComponentes \Transaction \Driver \DBAL \DBALTransactionalConnection ;
8+ use PHPUnit \Framework \TestCase ;
9+
10+ final class DBALTransactionalConnectionTest extends TestCase
11+ {
12+ /**
13+ * @test
14+ */
15+ public function given_dbal_connection_when_begin_transaction_then_it_is_done_in_dbal_connection ()
16+ {
17+ $ DBALConnection = $ this ->createMock (Connection::class);
18+
19+ $ DBALConnection
20+ ->expects ($ this ->once ())
21+ ->method ('beginTransaction ' )
22+ ;
23+
24+ $ transactionalConnection = new DBALTransactionalConnection ($ DBALConnection );
25+ $ transactionalConnection ->beginTransaction ();
26+ }
27+
28+ /**
29+ * @test
30+ */
31+ public function given_dbal_connection_when_commit_then_it_is_done_in_dbal_connection ()
32+ {
33+ $ DBALConnection = $ this ->createMock (Connection::class);
34+
35+ $ DBALConnection
36+ ->expects ($ this ->once ())
37+ ->method ('commit ' )
38+ ;
39+
40+ $ transactionalConnection = new DBALTransactionalConnection ($ DBALConnection );
41+ $ transactionalConnection ->commit ();
42+ }
43+
44+ /**
45+ * @test
46+ */
47+ public function given_dbal_connection_when_roll_back_then_it_is_done_in_dbal_connection ()
48+ {
49+ $ DBALConnection = $ this ->createMock (Connection::class);
50+
51+ $ DBALConnection
52+ ->expects ($ this ->once ())
53+ ->method ('rollBack ' )
54+ ;
55+
56+ $ transactionalConnection = new DBALTransactionalConnection ($ DBALConnection );
57+ $ transactionalConnection ->rollBack ();
58+ }
59+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ require dirname (__DIR__ ).'/vendor/autoload.php ' ;
5+
6+ \DG \BypassFinals::enable ();
You can’t perform that action at this time.
0 commit comments