Skip to content

allow inheriting from TimeSeries class #32

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions src/TimeSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Palicao\PhpRedisTimeSeries\Exception\RedisClientException;
use RedisException;

final class TimeSeries
class TimeSeries
{
public const DUPLICATE_POLICY_BLOCK = 'BLOCK';
public const DUPLICATE_POLICY_FIRST = 'FIRST';
Expand All @@ -18,7 +18,7 @@ final class TimeSeries
public const DUPLICATE_POLICY_MAX = 'MAX';
public const DUPLICATE_POLICY_SUM = 'SUM';

private const DUPLICATE_POLICIES = [
protected const DUPLICATE_POLICIES = [
self::DUPLICATE_POLICY_BLOCK,
self::DUPLICATE_POLICY_FIRST,
self::DUPLICATE_POLICY_LAST,
Expand All @@ -29,7 +29,7 @@ final class TimeSeries


/** @var RedisClientInterface */
private $redis;
protected $redis;

/**
* @param RedisClientInterface $redis
Expand Down
40 changes: 40 additions & 0 deletions tests/Integration/ExtendTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/* @noinspection PhpUnhandledExceptionInspection */

declare(strict_types=1);

namespace Palicao\PhpRedisTimeSeries\Tests\Integration;

use Palicao\PhpRedisTimeSeries\Client\RedisClient;
use Palicao\PhpRedisTimeSeries\Client\RedisConnectionParams;
use Palicao\PhpRedisTimeSeries\TimeSeries;
use PHPUnit\Framework\TestCase;
use Redis;

class MyTimeSeries extends TimeSeries
{
public function getRedis()
{
return $this->redis;
}
}

class ExtendTest extends TestCase
{
private $redisClient;
private $sut;

public function setUp(): void
{
$host = getenv('REDIS_HOST') ?: 'php-rts-redis';
$port = getenv('REDIS_PORT') ? (int) getenv('REDIS_PORT') : 6379;
$connectionParams = new RedisConnectionParams($host, $port);
$this->redisClient = new RedisClient(new Redis(), $connectionParams);
$this->sut = new MyTimeSeries($this->redisClient);
}

public function testRedisPropertyScope(): void
{
self::assertSame($this->redisClient, $this->sut->getRedis());
}
}