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. #142

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
76 changes: 43 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
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

Expand All @@ -17,23 +34,20 @@ jobs:
strategy:
matrix:
os:
- ubuntu-18.04
- ubuntu-latest

php:
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3

steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Checkout.
uses: actions/checkout@v3

- name: Install PHP
- name: Install PHP.
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand All @@ -42,36 +56,32 @@ jobs:
coverage: pcov
tools: composer:v2

- name: Update composer
- name: Update composer.
run: composer self-update

- name: Install dependencies with composer php < 8.0
if: matrix.php != '8.0'
- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with composer php 8.0
if: matrix.php == '8.0'
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Setup source database
- name: Setup source database.
run: |
sudo /etc/init.d/mysql start
mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;'
mysql -D yiitest -uroot -proot < tests/data/source.sql

- name: Install sphinx
- name: Install sphinx.
run: cd tests/data/actions && sh sphinx-setup.sh

- name: Run tests with phpunit
if: matrix.php != '7.4'
- name: Run tests with phpunit.
if: matrix.php != '8.1'
run: vendor/bin/phpunit --colors=always

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

- name: Upload code coverage scrutinizer
if: matrix.php == '7.4'
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- name: Upload coverage to Codecov.
if: matrix.php == '8.1'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-sphinx/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-sphinx)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-sphinx/downloads.png)](https://packagist.org/packages/yiisoft/yii2-sphinx)
[![Build status](https://github.com/yiisoft/yii2-sphinx/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-sphinx/actions?query=workflow%3Abuild)
[![codecov](https://codecov.io/gh/yiisoft/yii2-sphinx/graph/badge.svg?token=eEgiSUaKxc)](https://codecov.io/gh/yiisoft/yii2-sphinx)


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

At least Sphinx version 2.0 is required. However, in order to use all extension features, Sphinx version 2.2.3 or
- PHP 7.3 or higher.
- At least Sphinx version 2.0 is required. However, in order to use all extension features, Sphinx version 2.2.3 or
higher is required.


Installation
------------

Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.13",
"php": ">=7.3",
"ext-pdo": "*",
"ext-pdo_mysql": "*"
"ext-pdo_mysql": "*",
"yiisoft/yii2": "~2.0.13"
},
"require-dev": {
"phpunit/phpunit": "4.8.27|~5.7.21|^6.2"
"phpunit/phpunit": "^9.6"
},
"repositories": [
{
Expand All @@ -38,5 +39,10 @@
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
}
36 changes: 25 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<?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="Yii2-sphinx 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-Sphinx">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
2 changes: 1 addition & 1 deletion tests/ActiveDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class ActiveDataProviderTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand Down
2 changes: 1 addition & 1 deletion tests/ActiveFixtureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ActiveFixtureTest extends TestCase
{
public function setUp()
protected function setUp(): void
{
parent::setUp();
\Yii::$app->set('sphinx', $this->getConnection());
Expand Down
6 changes: 3 additions & 3 deletions tests/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class ActiveQueryTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand All @@ -31,10 +31,10 @@ public function testFacet()
$this->assertTrue($results['hits'][0] instanceof ArticleIndex, 'Unable to populate results as AR object');
}

public function testIndexBy()
public function testIndexBy()
{
$results = ArticleIndex::find()->indexBy('id')->all();
$result = reset($results);
$result = reset($results);
$this->assertTrue($result->id == key($results), 'Unable to index results by column');
}
}
10 changes: 5 additions & 5 deletions tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*/
class ActiveRecordTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
}

protected function tearDown()
protected function tearDown(): void
{
$this->truncateIndex('yii2_test_rt_index');
parent::tearDown();
Expand Down Expand Up @@ -262,11 +262,11 @@ public function testCallSnippets()

$snippet = ArticleIndex::callSnippets($source, $query);
$this->assertNotEmpty($snippet, 'Unable to call snippets!');
$this->assertContains('<b>' . $query . '</b>', $snippet, 'Query not present in the snippet!');
$this->assertStringContainsString('<b>' . $query . '</b>', $snippet, 'Query not present in the snippet!');

$rows = ArticleIndex::callSnippets([$source], $query);
$this->assertNotEmpty($rows, 'Unable to call snippets!');
$this->assertContains('<b>' . $query . '</b>', $rows[0], 'Query not present in the snippet!');
$this->assertStringContainsString('<b>' . $query . '</b>', $rows[0], 'Query not present in the snippet!');
}

public function testCallKeywords()
Expand Down Expand Up @@ -371,4 +371,4 @@ public function testEmulateExecution()
->search();
$this->assertSame(['hits' => [], 'facets' => [], 'meta' => []], $rows);
}
}
}
2 changes: 1 addition & 1 deletion tests/ActiveRelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class ActiveRelationTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand Down
4 changes: 2 additions & 2 deletions tests/BatchQueryResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BatchQueryResultTest extends TestCase
{
public function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand Down Expand Up @@ -154,4 +154,4 @@ public function testActiveQuery()
$this->assertCount(2, $allModels[1]->tags);
$this->assertCount(0, $allModels[2]->tags);
}
}
}
10 changes: 7 additions & 3 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class CommandTest extends TestCase
{
protected function tearDown()
protected function tearDown(): void
{
$this->truncateIndex('yii2_test_rt_index');
parent::tearDown();
Expand Down Expand Up @@ -373,7 +373,7 @@ public function testCallSnippets()

$rows = $db->createCommand()->callSnippets('yii2_test_item_index', $source, $query)->queryColumn();
$this->assertNotEmpty($rows, 'Unable to call snippets!');
$this->assertContains('<b>' . $query . '</b>', $rows[0], 'Query not present in the snippet!');
$this->assertStringContainsString('<b>' . $query . '</b>', $rows[0], 'Query not present in the snippet!');

$rows = $db->createCommand()->callSnippets('yii2_test_item_index', [$source], $query)->queryColumn();
$this->assertNotEmpty($rows, 'Unable to call snippets for array source!');
Expand All @@ -384,7 +384,11 @@ public function testCallSnippets()
'limit' => 20,
];
$snippet = $db->createCommand()->callSnippets('yii2_test_item_index', $source, $query, $options)->queryScalar();
$this->assertContains($options['before_match'] . $query . $options['after_match'], $snippet, 'Unable to apply options!');
$this->assertStringContainsString(
$options['before_match'] . $query . $options['after_match'],
$snippet,
'Unable to apply options!',
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/ExternalActiveRelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ExternalActiveRelationTest extends TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand Down
Loading