summaryrefslogtreecommitdiff
path: root/plugins/broadcast/root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/broadcast/root/tests')
-rw-r--r--plugins/broadcast/root/tests/.rr.yaml2
-rw-r--r--plugins/broadcast/root/tests/Broadcast/BroadcastTest.php56
-rw-r--r--plugins/broadcast/root/tests/Broadcast/MessageTest.php24
-rw-r--r--plugins/broadcast/root/tests/bootstrap.php15
-rw-r--r--plugins/broadcast/root/tests/docker-compose.yml9
-rw-r--r--plugins/broadcast/root/tests/go-client.go78
6 files changed, 0 insertions, 184 deletions
diff --git a/plugins/broadcast/root/tests/.rr.yaml b/plugins/broadcast/root/tests/.rr.yaml
deleted file mode 100644
index c35a12fc..00000000
--- a/plugins/broadcast/root/tests/.rr.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-broadcast:
- redis.addr: "localhost:6379" \ No newline at end of file
diff --git a/plugins/broadcast/root/tests/Broadcast/BroadcastTest.php b/plugins/broadcast/root/tests/Broadcast/BroadcastTest.php
deleted file mode 100644
index d6014bf0..00000000
--- a/plugins/broadcast/root/tests/Broadcast/BroadcastTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-/**
- * Spiral Framework.
- *
- * @license MIT
- * @author Anton Titov (Wolfy-J)
- */
-
-declare(strict_types=1);
-
-namespace Spiral\Broadcast\Tests;
-
-use PHPUnit\Framework\TestCase;
-use Spiral\Broadcast\Broadcast;
-use Spiral\Broadcast\Exception\BroadcastException;
-use Spiral\Broadcast\Message;
-use Spiral\Goridge\RPC;
-use Spiral\Goridge\SocketRelay;
-
-class BroadcastTest extends TestCase
-{
- public function testBroadcast(): void
- {
- $rpc = new RPC(new SocketRelay('localhost', 6001));
- $br = new Broadcast($rpc);
-
- $br->publish(
- new Message('tests/topic', 'hello'),
- new Message('tests/123', ['key' => 'value'])
- );
-
- while (filesize(__DIR__ . '/../log.txt') < 40) {
- clearstatcache(true, __DIR__ . '/../log.txt');
- usleep(1000);
- }
-
- clearstatcache(true, __DIR__ . '/../log.txt');
- $content = file_get_contents(__DIR__ . '/../log.txt');
-
- $this->assertSame('tests/topic: "hello"
-tests/123: {"key":"value"}
-', $content);
- }
-
- public function testBroadcastException(): void
- {
- $rpc = new RPC(new SocketRelay('localhost', 6002));
- $br = new Broadcast($rpc);
-
- $this->expectException(BroadcastException::class);
- $br->publish(
- new Message('topic', 'hello')
- );
- }
-}
diff --git a/plugins/broadcast/root/tests/Broadcast/MessageTest.php b/plugins/broadcast/root/tests/Broadcast/MessageTest.php
deleted file mode 100644
index dd9e1cc3..00000000
--- a/plugins/broadcast/root/tests/Broadcast/MessageTest.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-/**
- * Spiral Framework.
- *
- * @license MIT
- * @author Anton Titov (Wolfy-J)
- */
-
-declare(strict_types=1);
-
-namespace Spiral\Broadcast\Tests;
-
-use PHPUnit\Framework\TestCase;
-use Spiral\Broadcast\Message;
-
-class MessageTest extends TestCase
-{
- public function testSerialize(): void
- {
- $m = new Message('topic', ['hello' => 'world']);
- $this->assertSame('{"topic":"topic","payload":{"hello":"world"}}', json_encode($m));
- }
-}
diff --git a/plugins/broadcast/root/tests/bootstrap.php b/plugins/broadcast/root/tests/bootstrap.php
deleted file mode 100644
index d0dfb88b..00000000
--- a/plugins/broadcast/root/tests/bootstrap.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-/**
- * Spiral Framework, SpiralScout LLC.
- *
- * @author Anton Titov (Wolfy-J)
- */
-
-declare(strict_types=1);
-
-error_reporting(E_ALL | E_STRICT);
-ini_set('display_errors', 'stderr');
-
-//Composer
-require dirname(__DIR__) . '/vendor_php/autoload.php';
diff --git a/plugins/broadcast/root/tests/docker-compose.yml b/plugins/broadcast/root/tests/docker-compose.yml
deleted file mode 100644
index 123aa9b9..00000000
--- a/plugins/broadcast/root/tests/docker-compose.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-version: '3'
-
-services:
- redis:
- image: 'bitnami/redis:latest'
- environment:
- - ALLOW_EMPTY_PASSWORD=yes
- ports:
- - "6379:6379" \ No newline at end of file
diff --git a/plugins/broadcast/root/tests/go-client.go b/plugins/broadcast/root/tests/go-client.go
deleted file mode 100644
index 21442a01..00000000
--- a/plugins/broadcast/root/tests/go-client.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package main
-
-import (
- "fmt"
- "os"
-
- "github.com/spiral/broadcast/v2"
- rr "github.com/spiral/roadrunner/cmd/rr/cmd"
- "github.com/spiral/roadrunner/service/rpc"
- "golang.org/x/sync/errgroup"
-)
-
-type logService struct {
- broadcast *broadcast.Service
- stop chan interface{}
-}
-
-func (l *logService) Init(service *broadcast.Service) (bool, error) {
- l.broadcast = service
-
- return true, nil
-}
-
-func (l *logService) Serve() error {
- l.stop = make(chan interface{})
-
- client := l.broadcast.NewClient()
- if err := client.SubscribePattern("tests/*"); err != nil {
- return err
- }
-
- logFile, _ := os.Create("log.txt")
-
- g := &errgroup.Group{}
- g.Go(func() error {
- for msg := range client.Channel() {
- _, err := logFile.Write([]byte(fmt.Sprintf(
- "%s: %s\n",
- msg.Topic,
- string(msg.Payload),
- )))
- if err != nil {
- return err
- }
-
- err = logFile.Sync()
- if err != nil {
- return err
- }
- }
- return nil
- })
-
- <-l.stop
- err := logFile.Close()
- if err != nil {
- return err
- }
-
- err = client.Close()
- if err != nil {
- return err
- }
-
- return g.Wait()
-}
-
-func (l *logService) Stop() {
- close(l.stop)
-}
-
-func main() {
- rr.Container.Register(rpc.ID, &rpc.Service{})
- rr.Container.Register(broadcast.ID, &broadcast.Service{})
- rr.Container.Register("log", &logService{})
-
- rr.Execute()
-}