Skip to content

Commit

Permalink
Raise min version to PHP 7.3, check compatibility PHP 8.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Sep 29, 2023
1 parent 5d02376 commit e8eca0c
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 168 deletions.
153 changes: 81 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,86 @@
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 }}-${{ matrix.os }}

env:
extensions: pdo, pdo_mysql
key: cache-v1

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-18.04

php:
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"

steps:
- name: Checkout
uses: actions/[email protected]

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

- name: Update composer
run: composer self-update

- name: Install dependencies with composer php < 8.0
if: matrix.php != '8.0'
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
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
run: cd tests/data/actions && sh sphinx-setup.sh

- name: Run tests with phpunit
if: matrix.php != '7.4'
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: 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
tests:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

env:
extensions: pdo, pdo_mysql
key: cache-v1

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Update composer
run: composer self-update

- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- 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
run: cd tests/data/actions && sh sphinx-setup.sh

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

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

- name: Upload coverage to Codecov.
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
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
}
}
}
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
22 changes: 14 additions & 8 deletions tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function testSelect()
$query = new Query();
$query->select('*');
$this->assertEquals(['*' => '*'], $query->select);
$this->assertNull($query->distinct);
$this->assertEquals(null, $query->selectOption);
$this->assertFalse($query->distinct);
$this->assertNull($query->selectOption);

$query = new Query();
$query->select('id, name', 'something')->distinct(true);
Expand All @@ -43,7 +43,7 @@ public function testMatch()
$this->assertEquals($match, $query->match);

$command = $query->createCommand($this->getConnection(false));
$this->assertContains('MATCH(', $command->getSql(), 'No MATCH operator present!');
$this->assertStringContainsString('MATCH(', $command->getSql(), 'No MATCH operator present!');
$this->assertContains($match, $command->params, 'No match query among params!');
}

Expand Down Expand Up @@ -73,7 +73,7 @@ public function testWhereExpression()
$query->where($expression);

$command = $query->createCommand($this->getConnection(false));
$this->assertContains($expression->expression, $command->getSql());
$this->assertStringContainsString($expression->expression, $command->getSql());
$this->assertEquals($expression->params, $command->params);
}

Expand Down Expand Up @@ -271,8 +271,11 @@ public function testSnippet()
->all($connection);
$this->assertNotEmpty($rows);
foreach ($rows as $row) {
$this->assertContains($snippetPrefix, $row['snippet'], 'Snippet source not present!');
$this->assertContains($snippetOptions['before_match'] . $match, $row['snippet'] . $snippetOptions['after_match'], 'Options not applied!');
$this->assertStringContainsString($snippetPrefix, $row['snippet'], 'Snippet source not present!');
$this->assertStringContainsString(
$snippetOptions['before_match'] . $match, $row['snippet'] . $snippetOptions['after_match'],
'Options not applied!',
);
}

// @see https://github.com/yiisoft/yii2-sphinx/issues/61
Expand All @@ -284,8 +287,11 @@ public function testSnippet()
->all($connection);
$this->assertNotEmpty($rows);
foreach ($rows as $row) {
$this->assertContains($snippetPrefix, $row['snippet'], 'Snippet source not present!');
$this->assertContains($snippetOptions['before_match'] . $match, $row['snippet'] . $snippetOptions['after_match'], 'Options not applied!');
$this->assertStringContainsString($snippetPrefix, $row['snippet'], 'Snippet source not present!');
$this->assertStringContainsString(
$snippetOptions['before_match'] . $match, $row['snippet'] . $snippetOptions['after_match'],
'Options not applied!',
);
}

// @see https://github.com/yiisoft/yii2-sphinx/pull/93
Expand Down
Loading

0 comments on commit e8eca0c

Please sign in to comment.