Skip to content

Commit 852e939

Browse files
committed
added docker for locally running tests
1 parent c8f1641 commit 852e939

34 files changed

+164
-79
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ jobs:
4343

4444
- name: Tests
4545
run: make tests
46+
env:
47+
ELASTICSEARCH_HOST: 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

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/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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ 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']);
@@ -161,7 +161,7 @@ class AggregationCollection extends \Tester\TestCase
161161
);
162162

163163
$ch = \curl_init();
164-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
164+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
165165
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
166166
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
167167
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -186,7 +186,7 @@ class AggregationCollection extends \Tester\TestCase
186186
public function tearDown(): void
187187
{
188188
$ch = \curl_init();
189-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
189+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
190190
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
191191
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
192192
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

tests/SpameriTests/ElasticQuery/Aggregation/Avg.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Avg 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']);
@@ -64,7 +64,7 @@ class Avg extends \Tester\TestCase
6464
);
6565

6666
$ch = \curl_init();
67-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
67+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
6868
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
6969
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
7070
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -89,7 +89,7 @@ class Avg extends \Tester\TestCase
8989
public function tearDown(): void
9090
{
9191
$ch = \curl_init();
92-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
92+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
9393
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
9494
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
9595
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

tests/SpameriTests/ElasticQuery/Aggregation/Filter.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Filter 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']);
@@ -76,7 +76,7 @@ class Filter extends \Tester\TestCase
7676
);
7777

7878
$ch = \curl_init();
79-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
79+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
8080
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
8181
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
8282
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -101,7 +101,7 @@ class Filter extends \Tester\TestCase
101101
public function tearDown(): void
102102
{
103103
$ch = \curl_init();
104-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
104+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
105105
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
106106
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
107107
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

tests/SpameriTests/ElasticQuery/Aggregation/Histogram.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Histogram 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']);
@@ -65,7 +65,7 @@ class Histogram extends \Tester\TestCase
6565
);
6666

6767
$ch = \curl_init();
68-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
68+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
6969
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
7070
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
7171
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -90,7 +90,7 @@ class Histogram extends \Tester\TestCase
9090
public function tearDown(): void
9191
{
9292
$ch = \curl_init();
93-
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
93+
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
9494
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
9595
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
9696
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

0 commit comments

Comments
 (0)