Skip to content

Commit 76b3ffc

Browse files
authored
Merge pull request #12 from Spameri/v2
ci trigger
2 parents dad0cac + 6ee0967 commit 76b3ffc

37 files changed

+178
-187
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vendor/
2+
.git/
3+
.phpcs-cache
4+
.idea/
5+
*.log

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
uses: elastic/elastic-github-actions/elasticsearch@master
3030
with:
3131
stack-version: ${{ matrix.elastic }}
32+
security-enabled: false
3233

3334
- name: Composer
3435
run: make composer
@@ -43,3 +44,5 @@ jobs:
4344

4445
- name: Tests
4546
run: make tests
47+
env:
48+
ELASTICSEARCH_HOST: http://localhost:9200

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM php:8.2-cli
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
unzip \
6+
libcurl4-openssl-dev \
7+
&& docker-php-ext-install curl \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
11+
12+
WORKDIR /app

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"require-dev": {
1818
"ext-curl": "*",
1919
"phpstan/phpstan": "^1.11.3",
20-
"nette/tester": "v2.3.1",
21-
"elasticsearch/elasticsearch": "^7",
22-
"guzzlehttp/guzzle": "^6.3",
20+
"nette/tester": "v2.5.7",
21+
"elasticsearch/elasticsearch": "^9.0.0",
22+
"guzzlehttp/guzzle": "^7.0",
2323
"slevomat/coding-standard": "^8.0"
2424
},
2525
"autoload": {
@@ -34,10 +34,11 @@
3434
},
3535
"config": {
3636
"allow-plugins": {
37-
"dealerdirect/phpcodesniffer-composer-installer": true
37+
"dealerdirect/phpcodesniffer-composer-installer": true,
38+
"php-http/discovery": true
3839
}
3940
},
4041
"brach-alias": {
41-
"dev-master": "2.0.x-dev"
42+
"dev-master": "2.0.0"
4243
}
4344
}

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
php:
3+
build: .
4+
volumes:
5+
- .:/app
6+
environment:
7+
- ELASTICSEARCH_HOST=elasticsearch:9200
8+
depends_on:
9+
elasticsearch:
10+
condition: service_healthy
11+
12+
elasticsearch:
13+
image: elasticsearch:9.2.2
14+
environment:
15+
- discovery.type=single-node
16+
- xpack.security.enabled=false
17+
- xpack.security.enrollment.enabled=false
18+
- ES_JAVA_OPTS=-Xms512m -Xmx512m
19+
ports:
20+
- "9202:9200"
21+
healthcheck:
22+
test: curl -s http://localhost:9200 >/dev/null || exit 1
23+
interval: 10s
24+
timeout: 5s
25+
retries: 10

src/Aggregation/Range.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
class Range implements LeafAggregationInterface
1212
{
1313

14-
private \Spameri\ElasticQuery\Aggregation\RangeValueCollection $ranges;
15-
16-
1714
public function __construct(
1815
private string $field,
1916
private bool $keyed = false,
20-
\Spameri\ElasticQuery\Aggregation\RangeValueCollection $rangeValueCollection = null,
17+
private \Spameri\ElasticQuery\Aggregation\RangeValueCollection $ranges = new \Spameri\ElasticQuery\Aggregation\RangeValueCollection(),
2118
)
2219
{
23-
$this->ranges = $rangeValueCollection ?: new \Spameri\ElasticQuery\Aggregation\RangeValueCollection();
2420
}
2521

2622

src/Exception/ResponseCouldNotBeMapped.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ResponseCouldNotBeMapped extends \InvalidArgumentException
1111
public function __construct(
1212
string $message,
1313
int $code = 0,
14-
\Throwable $previous = null,
14+
\Throwable|null $previous = null,
1515
)
1616
{
1717
parent::__construct((string) \json_encode($message), $code, $previous);

src/Mapping/Settings/Mapping/FieldSeparator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
declare(strict_types = 1);
4-
3+
declare(strict_types = 1);
4+
55
namespace Spameri\ElasticQuery\Mapping\Settings\Mapping;
66

77
class FieldSeparator

src/Response/Result/Version.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class Version
2828
public const ELASTIC_VERSION_ID_67 = 60700;
2929
public const ELASTIC_VERSION_ID_7 = 70000;
3030
public const ELASTIC_VERSION_ID_8 = 80000;
31+
public const ELASTIC_VERSION_ID_9 = 90000;
32+
public const ELASTIC_VERSION_ID_10 = 100000;
3133

3234
private int $id;
3335

tests/SpameriTests/ElasticQuery/Aggregation/AggregationCollection.phpt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ class AggregationCollection extends \Tester\TestCase
1414
public function setUp(): void
1515
{
1616
$ch = \curl_init();
17-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
17+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
1818
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
1919
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'PUT');
2020
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
2121

2222
\curl_exec($ch);
23-
\curl_close($ch);
2423
}
2524

2625

@@ -161,7 +160,7 @@ class AggregationCollection extends \Tester\TestCase
161160
);
162161

163162
$ch = \curl_init();
164-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
163+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
165164
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
166165
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
167166
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -178,21 +177,18 @@ class AggregationCollection extends \Tester\TestCase
178177
$result = $resultMapper->map(\json_decode($response, true));
179178
\Tester\Assert::type(\Spameri\ElasticQuery\Response\ResultSearch::class, $result);
180179
});
181-
182-
\curl_close($ch);
183180
}
184181

185182

186183
public function tearDown(): void
187184
{
188185
$ch = \curl_init();
189-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
186+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
190187
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
191188
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
192189
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
193190

194191
\curl_exec($ch);
195-
\curl_close($ch);
196192
}
197193

198194
}

0 commit comments

Comments
 (0)