Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise min version to PHP 7.3, check compatibility PHP 8.3. #346

Merged
merged 6 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
61 changes: 45 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: build

jobs:
tests:
name: PHP ${{ matrix.php-version }} / ES ${{ matrix.es-version }}
name: PHP ${{ matrix.php }} / ES ${{ matrix.es }}

env:
extensions: curl, mbstring, dom, intl
key: cache-v1

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- 5.6
- 7.0
- 7.1
- 7.2
php:
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3

es-version:
es:
- 8.1.3
- 7.14.0
- 7.7.0
Expand All @@ -32,24 +49,24 @@ jobs:

steps:
- name: Service elastisearch 8.1.3.
if: matrix.es-version == '8.1.3'
if: matrix.es == '8.1.3'
run: |
docker network create somenetwork
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 }}
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 }}
- name: Service elastisearch < 8.1.3.
if: matrix.es-version != '8.1.3'
if: matrix.es != '8.1.3'
run: |
docker network create somenetwork
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 }}
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 }}
- name: Checkout.
uses: actions/checkout@v3

- name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
ini-values: date.timezone='UTC'

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

- name: Run tests with phpunit.
run: ES_VERSION=${{ matrix.es-version }} vendor/bin/phpunit
if: matrix.php != '8.1'
run: ES_VERSION=${{ matrix.es }} vendor/bin/phpunit --colors=always

- name: Run tests with phpunit and generate coverage.
if: matrix.php == '8.1'
run: ES_VERSION=${{ matrix.es }} vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always

- name: Upload coverage to Codecov.
if: matrix.php == '8.1'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-elasticsearch/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-elasticsearch)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-elasticsearch/downloads.png)](https://packagist.org/packages/yiisoft/yii2-elasticsearch)
[![Build Status](https://travis-ci.com/yiisoft/yii2-elasticsearch.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-elasticsearch)
[![codecov](https://codecov.io/gh/yiisoft/yii2-elasticsearch/graph/badge.svg?token=oi71bPc1SU)](https://codecov.io/gh/yiisoft/yii2-elasticsearch)

Requirements
------------

- PHP 7.3 or higher.

Depending on the version of Elasticsearch you are using you need a different version of this extension.

- For Elasticsearch 1.6.0 to 1.7.6 use extension version 2.0.x
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.14",
"php": ">=7.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"paragonie/random_compat": ">=1"
"yiisoft/yii2": "~2.0.14"
},
"require-dev": {
"phpunit/phpunit": "4.8.27|~5.7.21|^6.2"
"phpunit/phpunit": "^9.6"
},
"autoload": {
"psr-4": { "yii\\elasticsearch\\": "" }
"psr-4": { "yii\\elasticsearch\\": "src" }
},
"config": {
"allow-plugins": {
Expand Down
37 changes: 26 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./tests/bootstrap.php"
colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>

<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Yii2-ElasticSearch">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>

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.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/ActiveDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ActiveDataProviderTest extends TestCase
{
public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions tests/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class ActiveQueryTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -42,4 +42,4 @@ public function testColumn()
$result = $activeQuery->scalar('name', $this->getConnection());
$this->assertEquals('item1', $result);
}
}
}
6 changes: 3 additions & 3 deletions tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getOrderItemClass()
return OrderItem::className();
}

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -163,7 +163,7 @@ public function testSearch()
$this->assertTrue($customer instanceof Customer);
$this->assertEquals(2, $customer->_id);
}

public function testSuggestion()
{
$result = Customer::find()->addSuggester('customer_name', [
Expand All @@ -175,7 +175,7 @@ public function testSuggestion()

$this->assertCount(3, $result['suggest']['customer_name'][0]['options']);
}

public function testGetDb()
{
$this->mockApplication(['components' => ['elasticsearch' => Connection::className()]]);
Expand Down
5 changes: 3 additions & 2 deletions tests/ActiveRecordTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -1141,13 +1141,14 @@ public function testViaWithCallable()
$cheapItems = $order->cheapItemsUsingViaWithCallable;

$this->assertCount(2, $expensiveItems);

$expensiveItemIds = [
$expensiveItems[0]->_id,
$expensiveItems[1]->_id,
];
$this->assertContains(4, $expensiveItemIds);
$this->assertContains(5, $expensiveItemIds);

$this->assertContains('4', $expensiveItemIds);
$this->assertContains('5', $expensiveItemIds);
$this->assertCount(1, $cheapItems);
$this->assertEquals(3, $cheapItems[0]->_id);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CommandTest extends TestCase
/** @var Command */
private $command;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->command = $this->getConnection()->createCommand();
Expand Down
2 changes: 1 addition & 1 deletion tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConnectionTest extends TestCase
*/
private $connection;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->connection = $this->getConnection();
Expand Down
4 changes: 2 additions & 2 deletions tests/ElasticsearchTargetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testExport()
$this->assertArrayHasKey('category', $source);
}

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -61,7 +61,7 @@ protected function setUp()
]);
}

protected function tearDown()
protected function tearDown(): void
{
$command = $this->getConnection()->createCommand();
$command->deleteIndex($this->index);
Expand Down
2 changes: 1 addition & 1 deletion tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class QueryBuilderTest extends TestCase
*/
private $version;

public function setUp()
protected function setUp(): void
{
parent::setUp();
$command = $this->getConnection()->createCommand();
Expand Down
3 changes: 2 additions & 1 deletion tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class QueryTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

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

Expand Down
10 changes: 2 additions & 8 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
use yii\helpers\ArrayHelper;
use Yii;

// backward compatibility
if (!class_exists('\PHPUnit\Framework\TestCase')) {
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
}


/**
* This is the base class for all yii framework unit tests.
*/
Expand Down Expand Up @@ -40,7 +34,7 @@ public static function getParam($name, $default = null)
* Clean up after test.
* By default the application created with [[mockApplication]] will be destroyed.
*/
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
$this->destroyApplication();
Expand Down Expand Up @@ -86,7 +80,7 @@ protected function destroyApplication()
Yii::$container = new Container();
}

protected function setUp()
protected function setUp(): void
{
$this->mockApplication();

Expand Down
32 changes: 0 additions & 32 deletions tests/compatibility.php

This file was deleted.