Skip to content

Commit 781f460

Browse files
committed
Drop TarantoolAdapter and refactor tests
1 parent 1ebdca1 commit 781f460

22 files changed

+331
-334
lines changed

.php_cs.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class FilterableFixer implements FixerInterface
5757
};
5858

5959
$header = <<<EOF
60-
This file is part of the Tarantool Queue package.
60+
This file is part of the tarantool/queue package.
6161
6262
(c) Eugene Leonovich <[email protected]>
6363

.travis.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,34 @@ services:
77

88
env:
99
global:
10-
TNT_IMAGE='tarantool/tarantool:2'
10+
TNT_IMAGE='tarantool/tarantool:2.4'
1111

1212
matrix:
1313
- PHP_IMAGE='php:7.1-cli'
1414
- PHP_IMAGE='php:7.2-cli'
15-
- PHP_IMAGE='php:7.2-cli' TNT_CLIENT=pecl PHPUNIT_OPTS='--coverage-text --coverage-clover=coverage.clover'
16-
- PHP_IMAGE='php:7.3-cli' CHECK_CS=1
17-
- PHP_IMAGE='php:7.4-cli' PHPUNIT_OPTS='--coverage-text --coverage-clover=coverage.clover'
15+
- PHP_IMAGE='php:7.3-cli' QA=1
16+
- PHP_IMAGE='php:7.4-cli' COVERAGE_FILE='coverage.clover'
1817

1918
- PHP_IMAGE='php:7.4-cli' TNT_IMAGE='tarantool/tarantool:1.7'
2019
- PHP_IMAGE='php:7.4-cli' TNT_IMAGE='tarantool/tarantool:1.9'
2120
- PHP_IMAGE='php:7.4-cli' TNT_IMAGE='tarantool/tarantool:1'
2221
- PHP_IMAGE='php:7.4-cli' TNT_IMAGE='tarantool/tarantool:2.1'
22+
- PHP_IMAGE='php:7.4-cli' TNT_IMAGE='tarantool/tarantool:2.3'
2323

2424
install:
2525
- ./dockerfile.sh | tee /dev/tty | docker build -t queue -
2626

2727
script:
2828
- docker network create tarantool-php
2929
- docker run --net=tarantool-php --rm ${TNT_IMAGE} /usr/local/bin/tarantool --version
30-
- docker run -d --net=tarantool-php --name=tarantool -v `pwd`:/queue ${TNT_IMAGE} tarantool /queue/tests/Integration/queues.lua
31-
- docker run --rm --net=tarantool-php -v `pwd`:/queue -w /queue -e PHPUNIT_OPTS="$PHPUNIT_OPTS" queue
30+
- docker run -d --net=tarantool-php --name=tarantool -v `pwd`:/queue -e TNT_LISTEN_URI=$TNT_LISTEN_URI ${TNT_IMAGE} tarantool /queue/tests/Integration/queues.lua
31+
- docker run --rm --net=tarantool-php -v `pwd`:/queue -w /queue queue
32+
- if [[ -n "$QA" ]]; then
33+
docker run --net=tarantool-php --rm -v $(pwd):/queue -w /queue queue php vendor/bin/php-cs-fixer fix --dry-run --diff --verbose .;
34+
fi
3235

3336
after_script:
34-
- if [[ -f coverage.clover ]]; then
37+
- if [[ -f "$COVERAGE_FILE" ]]; then
3538
curl -sSOL https://scrutinizer-ci.com/ocular.phar &&
36-
docker run --rm -v $(pwd):/queue -w /queue queue php ocular.phar code-coverage:upload --format=php-clover coverage.clover;
39+
docker run --rm -v $(pwd):/queue -w /queue queue php ocular.phar code-coverage:upload --format=php-clover "$COVERAGE_FILE";
3740
fi

README.md

+16-21
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Lua modules, called [LuaRocks](https://luarocks.org/). This package provides PHP
2222
* [Consumer API](#consumer-api)
2323
* [Statistics](#statistics)
2424
* [Custom methods](#custom-methods)
25-
* [Tests](#tests)
25+
* [Testing](#testing)
2626
* [License](#license)
2727

2828

@@ -34,10 +34,6 @@ The recommended way to install the library is through [Composer](http://getcompo
3434
composer require tarantool/queue
3535
```
3636

37-
In addition, you will need to install one of the supported Tarantool connectors
38-
(either [tarantool-php/client](https://github.com/tarantool-php/client)
39-
or [tarantool/tarantool-php](https://github.com/tarantool/tarantool-php)).
40-
4137

4238
## Before start
4339

@@ -47,14 +43,14 @@ is configured, up and running. The minimal required configuration might look lik
4743
```lua
4844
-- queues.lua
4945

50-
box.cfg {listen=3301}
46+
box.cfg {listen = 3301}
5147

5248
queue = require('queue')
53-
queue.create_tube('foobar', 'fifottl', {if_not_exists=true})
49+
queue.create_tube('foobar', 'fifottl', {if_not_exists = true})
5450
```
5551

56-
> *You can read more about the box configuration in the official [Tarantool documentation](http://tarantool.org/doc/book/configuration/index.html#initialization-file).
57-
> For more information about the queue configuration check out [queue's README](https://github.com/tarantool/queue/blob/master/README.md).*
52+
> *You can read more about the box configuration in the official Tarantool [documentation](http://tarantool.org/doc/book/configuration/index.html#initialization-file).
53+
> More information on queue configuration can be found [here](https://github.com/tarantool/queue/blob/master/README.md).*
5854
5955
To start the instance you need to copy (or symlink) `queues.lua` file into the `/etc/tarantool/instances.enabled`
6056
directory and run the following command:
@@ -77,8 +73,7 @@ use Tarantool\Queue\Queue;
7773
$queue = new Queue($client, 'foobar');
7874
```
7975

80-
where `$client` is either an instance of the `Tarantool` class from the [pecl extension](https://github.com/tarantool/tarantool-php)
81-
or an instance of `Tarantool\Client\Client` from the [pure PHP package](https://github.com/tarantool-php/client).
76+
where `$client` is an instance of `Tarantool\Client\Client` from the [tarantool/client](https://github.com/tarantool-php/client) package.
8277

8378

8479
### Data types
@@ -96,13 +91,13 @@ $queue->put(['foo' => ['bar' => ['baz' => null]]]);
9691
$queue->put(new MyObject());
9792
```
9893

99-
> *Object serialization is only supported when [tarantool/client](https://github.com/tarantool-php/client) is used.*
94+
> *To learn more about object serialization, please follow this [link](https://github.com/tarantool-php/client#user-defined-types).*
10095
10196

10297
### Tasks
10398

104-
Most of the [Queue API](src/Queue.php) methods return back
105-
a [Task](src/Task.php) object containing the following getters:
99+
Most of the [Queue API](src/Queue.php) methods return a [Task](src/Task.php) object
100+
containing the following getters:
106101

107102
```php
108103
Task::getId()
@@ -212,7 +207,7 @@ $queue->truncate();
212207

213208
> *For a detailed API documentation, please read the section
214209
> "[Using the queue module](https://github.com/tarantool/queue#using-the-queue-module)"
215-
> of the [queue's README](https://github.com/tarantool/queue/blob/master/README.md).*
210+
> of the queue README.*
216211
217212

218213
### Statistics
@@ -255,9 +250,9 @@ $total = $queue->stats('tasks.total');
255250

256251
### Custom methods
257252

258-
Thanks to flexible nature of the [tarantool/queue](https://github.com/tarantool/queue/) module,
259-
you can easily create your own queue drivers or extend existing ones with an additional functionality.
260-
For example, you added the `put_many` method to your `foobar` queue, which inserts multiple tasks in a transaction:
253+
Thanks to flexible nature of the [queue](https://github.com/tarantool/queue/) Lua module, you can easily create
254+
your own queue drivers or extend existing ones with an additional functionality. For example, suppose you added
255+
the `put_many` method to your `foobar` queue, which inserts multiple tasks atomically:
261256

262257
```lua
263258
-- queues.lua
@@ -277,7 +272,7 @@ queue.tube.foobar.put_many = function(self, items)
277272
end
278273
```
279274

280-
To call this method on a `$queue` object, use `Queue::call()`:
275+
To invoke this method from php, use `Queue::call()`:
281276

282277
```php
283278
$result = $queue->call('put_many', [
@@ -287,15 +282,15 @@ $result = $queue->call('put_many', [
287282
```
288283

289284

290-
## Tests
285+
## Testing
291286

292287
The easiest way to run tests is with Docker. First, build an image using the [dockerfile.sh](dockerfile.sh) generator:
293288

294289
```bash
295290
./dockerfile.sh | docker build -t queue -
296291
```
297292

298-
Then run Tarantool instance (needed for integration tests):
293+
Then run a Tarantool instance (needed for integration tests):
299294

300295
```bash
301296
docker network create tarantool-php

composer.json

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.1"
14+
"php": "^7.1",
15+
"tarantool/client": "^0.7"
1516
},
1617
"require-dev": {
1718
"friendsofphp/php-cs-fixer": "^2.14",
18-
"phpunit/phpunit": "^7.4",
19-
"rybakit/msgpack": "^0.6.0",
20-
"tarantool/client": "^0.6.0"
21-
},
22-
"suggest": {
23-
"ext-tarantool": "For using pecl extension",
24-
"tarantool/client": "For using pure client"
19+
"rybakit/msgpack": "^0.7",
20+
"tarantool/phpunit-extras": "dev-master"
2521
},
2622
"autoload": {
2723
"psr-4": {

dockerfile.sh

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
#!/usr/bin/env bash
22

33
if [[ -z "$PHP_IMAGE" ]] ; then
4-
PHP_IMAGE='php:7.2-cli'
4+
PHP_IMAGE='php:7.4-cli'
55
fi
66

7-
if [[ -z "$TNT_CLIENT" ]] ; then
8-
TNT_CLIENT='pure'
7+
if [[ -z "$TNT_LISTEN_URI" ]]; then
8+
TNT_LISTEN_URI='tarantool:3301'
99
fi
1010

11-
if [[ $TNT_CLIENT == pecl ]]; then
12-
RUN_CMDS="$RUN_CMDS && \\\\\n git clone https://github.com/tarantool/tarantool-php.git /usr/src/php/ext/tarantool"
13-
RUN_CMDS="$RUN_CMDS && \\\\\n git --git-dir=/usr/src/php/ext/tarantool/.git --work-tree=/usr/src/php/ext/tarantool checkout php7-v2"
14-
RUN_CMDS="$RUN_CMDS && \\\\\n echo tarantool >> /usr/src/php-available-exts && docker-php-ext-install tarantool"
15-
COMPOSER_REMOVE='tarantool/client'
16-
fi
17-
18-
if [[ $PHPUNIT_OPTS =~ (^|[[:space:]])--coverage-[[:alpha:]] ]]; then
19-
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install xdebug && docker-php-ext-enable xdebug"
20-
fi
21-
22-
if [[ "1" != "$CHECK_CS" ]]; then
23-
COMPOSER_REMOVE="$COMPOSER_REMOVE friendsofphp/php-cs-fixer"
11+
if [[ -n "$COVERAGE_FILE" ]]; then
12+
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install pcov && docker-php-ext-enable pcov"
2413
fi
2514

2615
echo -e "
@@ -31,8 +20,8 @@ RUN apt-get update && apt-get install -y curl git unzip${RUN_CMDS}
3120
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
3221
3322
ENV PATH=~/.composer/vendor/bin:\$PATH
34-
ENV TARANTOOL_HOST=tarantool TARANTOOL_PORT=3301
23+
ENV TNT_LISTEN_URI=$TNT_LISTEN_URI
3524
36-
CMD if [ ! -f composer.lock ]; then ${COMPOSER_REMOVE:+composer remove --dev --no-update }$COMPOSER_REMOVE${COMPOSER_REMOVE:+ && }composer install; fi && \\
37-
vendor/bin/phpunit\${PHPUNIT_OPTS:+ }\$PHPUNIT_OPTS
25+
CMD if [ ! -f composer.lock ]; then composer install; fi && \\
26+
vendor/bin/phpunit ${COVERAGE_FILE:+ --coverage-text --coverage-clover=}$COVERAGE_FILE
3827
"

phpunit.xml.dist

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
<ini name="display_startup_errors" value="On" />
1212
<ini name="error_reporting" value="E_ALL" />
1313

14-
<env name="TARANTOOL_HOST" value="127.0.0.1" />
15-
<env name="TARANTOOL_PORT" value="3301" />
14+
<env name="TNT_LISTEN_URI" value="3301" />
1615
</php>
1716

1817
<testsuites>
@@ -30,4 +29,13 @@
3029
<directory>src</directory>
3130
</whitelist>
3231
</filter>
32+
33+
<!-- <extensions>-->
34+
<!--&lt;!&ndash; <extension class="Tarantool\PhpUnit\Annotation\AnnotationExtension">&ndash;&gt;-->
35+
<!-- <extension class="Tarantool\Queue\Tests\AnnotationExtension">-->
36+
<!-- <arguments>-->
37+
<!-- <string>tcp://%env(TARANTOOL_HOST)%:%env(TARANTOOL_PORT)%</string>-->
38+
<!-- </arguments>-->
39+
<!-- </extension>-->
40+
<!-- </extensions>-->
3341
</phpunit>

src/Options.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* This file is part of the Tarantool Queue package.
4+
* This file is part of the tarantool/queue package.
55
*
66
* (c) Eugene Leonovich <[email protected]>
77
*
@@ -20,4 +20,8 @@ final class Options
2020
public const TTL = 'ttl';
2121
public const TTR = 'ttr';
2222
public const UTUBE = 'utube';
23+
24+
private function __construct()
25+
{
26+
}
2327
}

0 commit comments

Comments
 (0)