Skip to content
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
79 changes: 49 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,56 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

name: build

jobs:
tests:
name: PHP ${{ matrix.php }}-redis-4
name: PHP ${{ matrix.php }}-redis-${{ matrix.redis }}

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

strategy:
fail-fast: false

matrix:
os:
- ubuntu-latest

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

redis:
- 6
- 7
- 8

services:
redis:
image: redis:${{ matrix.redis }}
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5

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

- name: Start Redis v4
uses: superchargejs/redis-github-action@1.1.0
with:
redis-version: 4
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
Expand All @@ -42,19 +60,20 @@ jobs:
ini-values: date.timezone='UTC'
tools: composer:v2, pecl

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer dependencies
uses: actions/cache@v2.1.4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

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

- name: Run Redis tests with PhpUnit
run: vendor/bin/phpunit --coverage-clover=coverage.clover
- name: Run tests with phpunit.
if: matrix.php != '8.1'
run: vendor/bin/phpunit --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 coverage to Codecov.
if: matrix.php == '8.1'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
69 changes: 0 additions & 69 deletions .github/workflows/ci-redis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
Requirements
------------

At least redis version 2.6.12 is required for all components to work properly.
At least redis version is required for all components to work properly.

Installation
------------
Expand All @@ -32,13 +32,13 @@ The preferred way to install this extension is through [composer](https://getcom
Either run

```
php composer.phar require --prefer-dist yiisoft/yii2-redis:"~2.0.0"
php composer.phar require --prefer-dist yiisoft/yii2-redis:^22.x-dev
```

or add

```json
"yiisoft/yii2-redis": "~2.0.0"
"yiisoft/yii2-redis": "^22.x-dev"
```

to the require section of your composer.json.
Expand Down
27 changes: 11 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"name": "yiisoft/yii2-redis",
"description": "Redis Cache, Session and ActiveRecord for the Yii framework",
"keywords": ["yii2", "redis", "active-record", "cache", "session"],
"keywords": [
"yii2",
"redis",
"active-record",
"cache",
"session"
],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
Expand All @@ -18,30 +24,19 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.39",
"ext-openssl": "*"
"php": ">=8.1",
"ext-openssl": "*",
"yiisoft/yii2": "22.0.x-dev"
},
"require-dev": {
"phpunit/phpunit": "<7",
"yiisoft/yii2-dev": "~2.0.39"
"phpunit/phpunit": "^9.6"
},
"autoload": {
"psr-4": { "yii\\redis\\": "src" }
},
"autoload-dev": {
"psr-4": { "yiiunit\\extensions\\redis\\": "tests/"}
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
Expand Down
36 changes: 20 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?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>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<phpunit
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
>
<testsuites>
<testsuite name="Yii2-Redis">
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
6 changes: 3 additions & 3 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public function open()
}

$connection = $this->connectionString . ', database=' . $this->database;
\Yii::trace('Opening redis DB connection: ' . $connection, __METHOD__);
\Yii::debug('Opening redis DB connection: ' . $connection, __METHOD__);
$socket = @stream_socket_client(
$this->connectionString,
$errorNumber,
Expand Down Expand Up @@ -672,7 +672,7 @@ public function close()
{
foreach ($this->_pool as $socket) {
$connection = $this->connectionString . ', database=' . $this->database;
\Yii::trace('Closing DB connection: ' . $connection, __METHOD__);
\Yii::debug('Closing DB connection: ' . $connection, __METHOD__);
try {
$this->executeCommand('QUIT');
} catch (SocketException $e) {
Expand Down Expand Up @@ -769,7 +769,7 @@ public function executeCommand($name, $params = [])
$command .= '$' . mb_strlen($arg ?? '', '8bit') . "\r\n" . $arg . "\r\n";
}

\Yii::trace("Executing Redis Command: {$name}", __METHOD__);
\Yii::debug("Executing Redis Command: {$name}", __METHOD__);
if ($this->retries > 0) {
$tries = $this->retries;
while ($tries-- > 0) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ActiveDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class ActiveDataProviderTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand Down
12 changes: 6 additions & 6 deletions tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use yii\redis\ActiveQuery;
use yii\redis\LuaScriptBuilder;
use yiiunit\extensions\redis\base\ActiveRecordTestTrait;
use yiiunit\extensions\redis\data\ar\ActiveRecord;
use yiiunit\extensions\redis\data\ar\Customer;
use yiiunit\extensions\redis\data\ar\OrderItem;
use yiiunit\extensions\redis\data\ar\Order;
use yiiunit\extensions\redis\data\ar\Item;
use yiiunit\extensions\redis\data\ar\OrderItemWithNullFK;
use yiiunit\extensions\redis\data\ar\OrderWithNullFK;
use yiiunit\framework\ar\ActiveRecordTestTrait;

/**
* @group redis
Expand Down Expand Up @@ -68,7 +68,7 @@ public function getOrderItemWithNullFKmClass()
return OrderItemWithNullFK::className();
}

public function setUp()
public function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
Expand Down Expand Up @@ -539,10 +539,10 @@ public function testValueEscapingInWhere($filterWithInjection, $expectedStrings,
$script = $lua->buildOne($query);

foreach($expectedStrings as $string) {
$this->assertContains($string, $script);
$this->assertStringContainsString($string, $script);
}
foreach($unexpectedStrings as $string) {
$this->assertNotContains($string, $script);
$this->assertStringNotContainsString($string, $script);
}
}

Expand Down Expand Up @@ -594,10 +594,10 @@ public function testValueEscapingInFindByCondition($filterWithInjection, $expect
$script = $lua->buildOne($query);

foreach($expectedStrings as $string) {
$this->assertContains($string, $script);
$this->assertStringContainsString($string, $script);
}
foreach($unexpectedStrings as $string) {
$this->assertNotContains($string, $script);
$this->assertStringNotContainsString($string, $script);
}
// ensure injected FLUSHALL call did not succeed
$query->one();
Expand Down
4 changes: 2 additions & 2 deletions tests/RedisCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use yii\redis\Cache;
use yii\redis\Connection;
use yiiunit\framework\caching\CacheTestCase;
use yiiunit\extensions\redis\base\AbstractCacheTestCase;

/**
* Class for testing redis cache backend
* @group redis
* @group caching
*/
class RedisCacheTest extends CacheTestCase
class RedisCacheTest extends AbstractCacheTestCase
{
private $_cacheInstance;

Expand Down
Loading