diff --git a/composer.json b/composer.json index e57a957..c11d882 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/dev b/dev new file mode 100755 index 0000000..0f8f471 --- /dev/null +++ b/dev @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker compose up \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bb4b146 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3.8' + +services: + redis: + container_name: redis + image: 'redis/redis-stack' + ports: + - '6381:6379' diff --git a/phpunit.xml b/phpunit.xml index 3678eda..dd76b05 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -24,7 +24,7 @@ - + diff --git a/src/Document/Document.php b/src/Document/Document.php index 350f16c..7c39d88 100644 --- a/src/Document/Document.php +++ b/src/Document/Document.php @@ -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; diff --git a/tests/RediSearch/IndexTest.php b/tests/RediSearch/IndexTest.php index fd63d8e..e62d90b 100644 --- a/tests/RediSearch/IndexTest.php +++ b/tests/RediSearch/IndexTest.php @@ -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() @@ -381,7 +385,7 @@ public function testAddDocumentFromHash() $this->assertTrue($result); } - public function testFindDocumentAddedWithHash () + public function testFindDocumentAddedWithHash() { $this->subject->create(); $title = 'How to be awesome'; diff --git a/tests/Stubs/TestIndex.php b/tests/Stubs/TestIndex.php index 1b2d704..f61f9d1 100644 --- a/tests/Stubs/TestIndex.php +++ b/tests/Stubs/TestIndex.php @@ -2,8 +2,10 @@ namespace Ehann\Tests\Stubs; +use AllowDynamicProperties; use Ehann\RediSearch\Index; +#[AllowDynamicProperties] class TestIndex extends Index { }