Skip to content

Commit

Permalink
Add PHP 8.2 support (#83)
Browse files Browse the repository at this point in the history
* Use AllowDynamicProperties to remove whitelist messages a few classes for dynamic property access

* Update failing tag test

* Make test config's REDIS_PORT match docker compose config

* Add a "dev" helper script to simplify starting docker image for testing
  • Loading branch information
ethanhann authored Jul 4, 2023
1 parent 6664c08 commit ddce4cd
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.0",
"php": ">=8.2",
"psr/log": "^3.0.0",
"ethanhann/redis-raw": "^2.1.0"
},
Expand Down
3 changes: 3 additions & 0 deletions dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker compose up
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.8'

services:
redis:
container_name: redis
image: 'redis/redis-stack'
ports:
- '6381:6379'
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<php>
<env name="REDIS_LIBRARY" value="Predis" />
<env name="REDIS_HOST" value="localhost" />
<env name="REDIS_PORT" value="6379" />
<env name="REDIS_PORT" value="6381" />
<env name="REDIS_DB" value="0" />
<env name="LOG_FILE" value="./tests.log" />
<env name="IS_LOGGING_ENABLED" value="true" />
Expand Down
2 changes: 2 additions & 0 deletions src/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Ehann\RediSearch\Document;

use AllowDynamicProperties;
use Ehann\RediSearch\Exceptions\OutOfRangeDocumentScoreException;
use Ehann\RediSearch\Fields\FieldInterface;

#[AllowDynamicProperties]
class Document implements DocumentInterface
{
protected $id;
Expand Down
14 changes: 9 additions & 5 deletions tests/RediSearch/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,30 @@ public function testCreateIndexWithTagField()

public function testGetTagValues()
{
$expectedTagCount = 2;
$blue = 'blue';
$red = 'red';
$this->subject->create();
$this->subject->add([
new TextField('title', 'How to be awesome.'),
new TextField('author', 'Jack'),
new NumericField('price', 9.99),
new NumericField('stock', 231),
new TagField('color', 'red'),
new TagField('color', $red),
]);
$this->subject->add([
new TextField('title', 'F.O.W.L'),
new TextField('author', 'Jill'),
new NumericField('price', 19.99),
new NumericField('stock', 31),
new TagField('color', 'blue'),
new TagField('color', $blue),
]);
$expected = ['red', 'blue'];

$actual = $this->subject->tagValues('color');

$this->assertEquals($expected, $actual);
$this->assertContains($blue, $actual);
$this->assertContains($red, $actual);
$this->assertEquals($expectedTagCount, count($actual));
}

public function testAddDocumentWithZeroScore()
Expand Down Expand Up @@ -381,7 +385,7 @@ public function testAddDocumentFromHash()
$this->assertTrue($result);
}

public function testFindDocumentAddedWithHash ()
public function testFindDocumentAddedWithHash()
{
$this->subject->create();
$title = 'How to be awesome';
Expand Down
2 changes: 2 additions & 0 deletions tests/Stubs/TestIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Ehann\Tests\Stubs;

use AllowDynamicProperties;
use Ehann\RediSearch\Index;

#[AllowDynamicProperties]
class TestIndex extends Index
{
}

0 comments on commit ddce4cd

Please sign in to comment.