Skip to content

Commit dec1ea0

Browse files
Raise min version to PHP 7.3, check compatibility PHP 8.3 (#346)
1 parent d697c96 commit dec1ea0

30 files changed

+99
-85
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ trim_trailing_whitespace = true
1212

1313
[*.md]
1414
trim_trailing_whitespace = false
15+
16+
[*.yml]
17+
indent_size = 2

.github/workflows/build.yml

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
on:
2-
- pull_request
3-
- push
2+
pull_request:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.gitattributes'
9+
- 'infection.json.dist'
10+
- 'psalm.xml'
11+
12+
push:
13+
paths-ignore:
14+
- 'docs/**'
15+
- 'README.md'
16+
- 'CHANGELOG.md'
17+
- '.gitignore'
18+
- '.gitattributes'
19+
- 'infection.json.dist'
20+
- 'psalm.xml'
421

522
name: build
623

724
jobs:
825
tests:
9-
name: PHP ${{ matrix.php-version }} / ES ${{ matrix.es-version }}
26+
name: PHP ${{ matrix.php }} / ES ${{ matrix.es }}
27+
1028
env:
1129
extensions: curl, mbstring, dom, intl
12-
key: cache-v1
1330

1431
runs-on: ubuntu-latest
1532

1633
strategy:
1734
matrix:
18-
php-version:
19-
- 5.6
20-
- 7.0
21-
- 7.1
22-
- 7.2
35+
php:
2336
- 7.3
2437
- 7.4
38+
- 8.0
39+
- 8.1
40+
- 8.2
41+
- 8.3
2542

26-
es-version:
43+
es:
2744
- 8.1.3
2845
- 7.14.0
2946
- 7.7.0
@@ -32,24 +49,24 @@ jobs:
3249

3350
steps:
3451
- name: Service elastisearch 8.1.3.
35-
if: matrix.es-version == '8.1.3'
52+
if: matrix.es == '8.1.3'
3653
run: |
3754
docker network create somenetwork
38-
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -e "http.publish_host=127.0.0.1" -e "transport.host=127.0.0.1" -e "indices.id_field_data.enabled=true" -e "xpack.security.enabled=false" elasticsearch:${{ matrix.es-version }}
55+
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -e "http.publish_host=127.0.0.1" -e "transport.host=127.0.0.1" -e "indices.id_field_data.enabled=true" -e "xpack.security.enabled=false" elasticsearch:${{ matrix.es }}
3956
4057
- name: Service elastisearch < 8.1.3.
41-
if: matrix.es-version != '8.1.3'
58+
if: matrix.es != '8.1.3'
4259
run: |
4360
docker network create somenetwork
44-
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -e "http.publish_host=127.0.0.1" -e "transport.host=127.0.0.1" elasticsearch:${{ matrix.es-version }}
61+
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -e "http.publish_host=127.0.0.1" -e "transport.host=127.0.0.1" elasticsearch:${{ matrix.es }}
4562
4663
- name: Checkout.
4764
uses: actions/checkout@v3
4865

4966
- name: Install PHP with extensions.
5067
uses: shivammathur/setup-php@v2
5168
with:
52-
php-version: ${{ matrix.php-version }}
69+
php-version: ${{ matrix.php }}
5370
extensions: ${{ env.extensions }}
5471
ini-values: date.timezone='UTC'
5572

@@ -60,4 +77,16 @@ jobs:
6077
run: wget --retry-connrefused --waitretry=3 --timeout=30 -t 10 -O /dev/null http://127.0.0.1:9200
6178

6279
- name: Run tests with phpunit.
63-
run: ES_VERSION=${{ matrix.es-version }} vendor/bin/phpunit
80+
if: matrix.php != '8.1'
81+
run: ES_VERSION=${{ matrix.es }} vendor/bin/phpunit --colors=always
82+
83+
- name: Run tests with phpunit and generate coverage.
84+
if: matrix.php == '8.1'
85+
run: ES_VERSION=${{ matrix.es }} vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always
86+
87+
- name: Upload coverage to Codecov.
88+
if: matrix.php == '8.1'
89+
uses: codecov/codecov-action@v3
90+
with:
91+
token: ${{ secrets.CODECOV_TOKEN }}
92+
file: ./coverage.xml

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
1717
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-elasticsearch/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-elasticsearch)
1818
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-elasticsearch/downloads.png)](https://packagist.org/packages/yiisoft/yii2-elasticsearch)
1919
[![Build Status](https://travis-ci.com/yiisoft/yii2-elasticsearch.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-elasticsearch)
20+
[![codecov](https://codecov.io/gh/yiisoft/yii2-elasticsearch/graph/badge.svg?token=oi71bPc1SU)](https://codecov.io/gh/yiisoft/yii2-elasticsearch)
2021

2122
Requirements
2223
------------
2324

25+
- PHP 7.3 or higher.
26+
2427
Depending on the version of Elasticsearch you are using you need a different version of this extension.
2528

2629
- For Elasticsearch 1.6.0 to 1.7.6 use extension version 2.0.x

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
}
1919
],
2020
"require": {
21-
"yiisoft/yii2": "~2.0.14",
21+
"php": ">=7.3",
2222
"ext-curl": "*",
2323
"ext-json": "*",
2424
"ext-mbstring": "*",
25-
"paragonie/random_compat": ">=1"
25+
"yiisoft/yii2": "~2.0.14"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "4.8.27|~5.7.21|^6.2"
28+
"phpunit/phpunit": "^9.6"
2929
},
3030
"autoload": {
31-
"psr-4": { "yii\\elasticsearch\\": "" }
31+
"psr-4": { "yii\\elasticsearch\\": "src" }
3232
},
3333
"config": {
3434
"allow-plugins": {

phpunit.xml.dist

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit bootstrap="./tests/bootstrap.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
stopOnFailure="false">
8-
<testsuites>
9-
<testsuite name="Test Suite">
10-
<directory>./tests</directory>
11-
</testsuite>
12-
</testsuites>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="./tests/bootstrap.php"
5+
colors="true" convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
stopOnFailure="false"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
10+
>
11+
12+
<php>
13+
<ini name="error_reporting" value="-1"/>
14+
</php>
15+
16+
<testsuites>
17+
<testsuite name="Yii2-ElasticSearch">
18+
<directory>./tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
22+
<coverage>
23+
<include>
24+
<directory>./src</directory>
25+
</include>
26+
</coverage>
1327
</phpunit>
28+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Query.php renamed to src/Query.php

File renamed without changes.
File renamed without changes.

tests/ActiveDataProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class ActiveDataProviderTest extends TestCase
1212
{
13-
public function setUp()
13+
protected function setUp(): void
1414
{
1515
parent::setUp();
1616

tests/ActiveQueryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class ActiveQueryTest extends TestCase
1111
{
12-
protected function setUp()
12+
protected function setUp(): void
1313
{
1414
parent::setUp();
1515

@@ -42,4 +42,4 @@ public function testColumn()
4242
$result = $activeQuery->scalar('name', $this->getConnection());
4343
$this->assertEquals('item1', $result);
4444
}
45-
}
45+
}

tests/ActiveRecordTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getOrderItemClass()
4343
return OrderItem::className();
4444
}
4545

46-
public function setUp()
46+
protected function setUp(): void
4747
{
4848
parent::setUp();
4949

@@ -163,7 +163,7 @@ public function testSearch()
163163
$this->assertTrue($customer instanceof Customer);
164164
$this->assertEquals(2, $customer->_id);
165165
}
166-
166+
167167
public function testSuggestion()
168168
{
169169
$result = Customer::find()->addSuggester('customer_name', [
@@ -175,7 +175,7 @@ public function testSuggestion()
175175

176176
$this->assertCount(3, $result['suggest']['customer_name'][0]['options']);
177177
}
178-
178+
179179
public function testGetDb()
180180
{
181181
$this->mockApplication(['components' => ['elasticsearch' => Connection::className()]]);

tests/ActiveRecordTestTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,13 +1141,14 @@ public function testViaWithCallable()
11411141
$cheapItems = $order->cheapItemsUsingViaWithCallable;
11421142

11431143
$this->assertCount(2, $expensiveItems);
1144+
11441145
$expensiveItemIds = [
11451146
$expensiveItems[0]->_id,
11461147
$expensiveItems[1]->_id,
11471148
];
1148-
$this->assertContains(4, $expensiveItemIds);
1149-
$this->assertContains(5, $expensiveItemIds);
11501149

1150+
$this->assertContains('4', $expensiveItemIds);
1151+
$this->assertContains('5', $expensiveItemIds);
11511152
$this->assertCount(1, $cheapItems);
11521153
$this->assertEquals(3, $cheapItems[0]->_id);
11531154
}

tests/CommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CommandTest extends TestCase
1313
/** @var Command */
1414
private $command;
1515

16-
protected function setUp()
16+
protected function setUp(): void
1717
{
1818
parent::setUp();
1919
$this->command = $this->getConnection()->createCommand();

tests/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ConnectionTest extends TestCase
1414
*/
1515
private $connection;
1616

17-
protected function setUp()
17+
protected function setUp(): void
1818
{
1919
parent::setUp();
2020
$this->connection = $this->getConnection();

tests/ElasticsearchTargetTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testExport()
3636
$this->assertArrayHasKey('category', $source);
3737
}
3838

39-
protected function setUp()
39+
protected function setUp(): void
4040
{
4141
parent::setUp();
4242

@@ -61,7 +61,7 @@ protected function setUp()
6161
]);
6262
}
6363

64-
protected function tearDown()
64+
protected function tearDown(): void
6565
{
6666
$command = $this->getConnection()->createCommand();
6767
$command->deleteIndex($this->index);

tests/QueryBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class QueryBuilderTest extends TestCase
1515
*/
1616
private $version;
1717

18-
public function setUp()
18+
protected function setUp(): void
1919
{
2020
parent::setUp();
2121
$command = $this->getConnection()->createCommand();

tests/QueryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class QueryTest extends TestCase
1111
{
12-
protected function setUp()
12+
protected function setUp(): void
1313
{
1414
parent::setUp();
1515

@@ -457,6 +457,7 @@ public function testRuntimeMappings()
457457
// Check that Elasticsearch is version 7.11.0 or later before running this test
458458
$elasticsearchInfo = $this->getConnection()->get('/');
459459
if(!version_compare($elasticsearchInfo['version']['number'], '7.11.0', '>=')) {
460+
$this->expectNotToPerformAssertions();
460461
return;
461462
}
462463

tests/TestCase.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
use yii\helpers\ArrayHelper;
88
use Yii;
99

10-
// backward compatibility
11-
if (!class_exists('\PHPUnit\Framework\TestCase')) {
12-
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
13-
}
14-
15-
1610
/**
1711
* This is the base class for all yii framework unit tests.
1812
*/
@@ -40,7 +34,7 @@ public static function getParam($name, $default = null)
4034
* Clean up after test.
4135
* By default the application created with [[mockApplication]] will be destroyed.
4236
*/
43-
protected function tearDown()
37+
protected function tearDown(): void
4438
{
4539
parent::tearDown();
4640
$this->destroyApplication();
@@ -86,7 +80,7 @@ protected function destroyApplication()
8680
Yii::$container = new Container();
8781
}
8882

89-
protected function setUp()
83+
protected function setUp(): void
9084
{
9185
$this->mockApplication();
9286

tests/compatibility.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)