-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from asiries335/mvp-7
feat(stream): create tests
- Loading branch information
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
|
||
namespace Asiries335\redisSteamPhp\Tests; | ||
|
||
use Asiries335\redisSteamPhp\Client; | ||
use Asiries335\redisSteamPhp\ClientRedisStreamPhpInterface; | ||
use Asiries335\redisSteamPhp\Stream; | ||
use Asiries335\redisSteamPhp\StreamGroupConsumer; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ClientTest extends TestCase | ||
{ | ||
private $client; | ||
|
||
/** | ||
* setUp | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() : void | ||
{ | ||
$connector = \Mockery::mock(ClientRedisStreamPhpInterface::class); | ||
$this->client = new Client($connector); | ||
} | ||
|
||
/** | ||
* test Stream | ||
* | ||
* @return void | ||
*/ | ||
public function testStream() : void | ||
{ | ||
$result = $this->client->stream('stream-name'); | ||
|
||
$this->assertInstanceOf(Stream::class, $result); | ||
} | ||
|
||
/** | ||
* test Group | ||
* | ||
* @return void | ||
*/ | ||
public function testGroup() : void | ||
{ | ||
$result = $this->client->streamGroupConsumer('stream-name'); | ||
|
||
$this->assertInstanceOf(StreamGroupConsumer::class, $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
|
||
namespace Asiries335\redisSteamPhp\Tests; | ||
|
||
|
||
use Asiries335\redisSteamPhp\ClientRedisStreamPhpInterface; | ||
use Asiries335\redisSteamPhp\StreamGroupConsumer; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class StreamGroupConsumerTest extends TestCase | ||
{ | ||
private $client; | ||
|
||
private const TEST_NAME_STREAM = 'test_stream'; | ||
|
||
private const TEST_NAME_GROUP = 'test_group'; | ||
|
||
/** | ||
* setUp | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() : void | ||
{ | ||
$this->client = \Mockery::mock(ClientRedisStreamPhpInterface::class); | ||
} | ||
|
||
/** | ||
* Create a group | ||
* | ||
* @return void | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testCreateGroup() : void | ||
{ | ||
$this->client->shouldReceive('call')->andReturn(true); | ||
|
||
$streamGroup = new StreamGroupConsumer($this->client, self::TEST_NAME_STREAM); | ||
|
||
$result = $streamGroup->create(self::TEST_NAME_GROUP, true); | ||
|
||
$this->assertEquals(true, $result); | ||
} | ||
|
||
/** | ||
* Destroy a group | ||
* | ||
* @return void | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testDestroyGroup() : void | ||
{ | ||
$this->client->shouldReceive('call')->andReturn(true); | ||
|
||
$streamGroup = new StreamGroupConsumer($this->client, self::TEST_NAME_STREAM); | ||
|
||
$result = $streamGroup->destroy(self::TEST_NAME_GROUP); | ||
|
||
$this->assertEquals(true, $result); | ||
} | ||
|
||
/** | ||
* Test delete a consumer from group | ||
* | ||
* @return void | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testDeleteConsumerGroup() : void | ||
{ | ||
$this->client->shouldReceive('call')->andReturn(true); | ||
|
||
$streamGroup = new StreamGroupConsumer($this->client, self::TEST_NAME_STREAM); | ||
|
||
$result = $streamGroup->deleteConsumer(self::TEST_NAME_GROUP, 'consumerName'); | ||
|
||
$this->assertEquals(true, $result); | ||
} | ||
} |