diff options
Diffstat (limited to 'tests')
57 files changed, 0 insertions, 1430 deletions
diff --git a/tests/allocate-failed.php b/tests/allocate-failed.php deleted file mode 100644 index 8514ecc0..00000000 --- a/tests/allocate-failed.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -if (file_exists('break')) { - throw new Exception('oops'); -} - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); - -while($rr->waitPayload()){ - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} diff --git a/tests/broken.php b/tests/broken.php deleted file mode 100644 index 413f860f..00000000 --- a/tests/broken.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -$rr = new RoadRunner\Worker($relay); - -while ($in = $rr->waitPayload()) { - echo undefined_function(); - $rr->respond(new RoadRunner\Payload((string)$in->body, null)); -} diff --git a/tests/client.php b/tests/client.php deleted file mode 100644 index d67f6937..00000000 --- a/tests/client.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -use Spiral\Goridge; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -if (count($argv) < 3) { - die("need 2 arguments"); -} - -list($test, $goridge) = [$argv[1], $argv[2]]; - -switch ($goridge) { - case "pipes": - $relay = new Goridge\StreamRelay(STDIN, STDOUT); - break; - - case "tcp": - $relay = new Goridge\SocketRelay("127.0.0.1", 9007); - break; - - case "unix": - $relay = new Goridge\SocketRelay( - "sock.unix", - null, - Goridge\SocketRelay::SOCK_UNIX - ); - break; - - default: - die("invalid protocol selection"); -} - -require_once sprintf("%s/%s.php", __DIR__, $test); diff --git a/tests/composer.json b/tests/composer.json deleted file mode 100644 index fa5925b7..00000000 --- a/tests/composer.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "minimum-stability": "beta", - "prefer-stable": true, - "require": { - "nyholm/psr7": "^1.4", - "spiral/roadrunner": "^2.0", - "spiral/roadrunner-http": "^2.0", - "temporal/sdk": ">=1.0", - "spiral/tokenizer": ">=2.7", - "spiral/roadrunner-metrics": "^2.0" - }, - "autoload": { - "psr-4": { - "Temporal\\Tests\\": "src" - } - }, - "name": "test/test", - "description": "test" -} diff --git a/tests/crc_error.php b/tests/crc_error.php deleted file mode 100644 index a769fb1e..00000000 --- a/tests/crc_error.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -fwrite(STDOUT, "warning: some weird php error"); - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); - -while($rr->waitPayload()){ - sleep(3); - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} diff --git a/tests/delay.php b/tests/delay.php deleted file mode 100644 index 2c8255ba..00000000 --- a/tests/delay.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -$rr = new RoadRunner\Worker($relay); - -while ($in = $rr->waitPayload()) { - try { - usleep($in->body * 1000); - $rr->respond(new RoadRunner\Payload('')); - } catch (\Throwable $e) { - $rr->error((string)$e); - } -} diff --git a/tests/echo.php b/tests/echo.php deleted file mode 100644 index 64510465..00000000 --- a/tests/echo.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -$rr = new RoadRunner\Worker($relay); - -while ($in = $rr->waitPayload()) { - try { - $rr->respond(new RoadRunner\Payload((string)$in->body)); - } catch (\Throwable $e) { - $rr->error((string)$e); - } -} diff --git a/tests/error.php b/tests/error.php deleted file mode 100644 index c77e6817..00000000 --- a/tests/error.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -$rr = new RoadRunner\Worker($relay); - -while ($in = $rr->waitPayload()) { - $rr->error((string)$in->body); -} diff --git a/tests/exec_ttl.php b/tests/exec_ttl.php deleted file mode 100644 index fb5c9df2..00000000 --- a/tests/exec_ttl.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); - -while($rr->waitPayload()){ - sleep(3); - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} diff --git a/tests/failboot.php b/tests/failboot.php deleted file mode 100644 index d59462cd..00000000 --- a/tests/failboot.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php -ini_set('display_errors', 'stderr'); -throw new Error("failboot error"); diff --git a/tests/gzip-large-file.txt b/tests/gzip-large-file.txt deleted file mode 100644 index 4c3eef8f..00000000 --- a/tests/gzip-large-file.txt +++ /dev/null @@ -1,19 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sodales consectetur fringilla. Phasellus rhoncus lectus nec diam vehicula euismod. Proin eget mollis libero, at ullamcorper ex. Proin sollicitudin, ligula vitae efficitur iaculis, est arcu iaculis ex, in finibus dolor lorem sit amet orci. Pellentesque placerat fermentum est, sed aliquam nulla aliquam non. Donec non tellus vitae elit iaculis ullamcorper. Sed ultricies arcu vel nunc maximus, nec iaculis eros varius. Duis iaculis a mi sed rutrum. Aliquam aliquet ornare arcu id pulvinar. Maecenas luctus orci at efficitur mollis. Aliquam eu placerat magna, id blandit libero. - -Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque mattis nibh in sagittis dictum. Ut eu neque mollis, pharetra nunc in, sodales neque. Aenean viverra commodo arcu, sit amet egestas magna interdum non. Sed pulvinar ornare urna quis sagittis. Duis tempor at augue sed laoreet. Curabitur aliquam at arcu a semper. Sed eu sem ante. Praesent pellentesque magna lacus, eget ultricies elit pharetra et. Sed ut nisl ultricies orci ultricies porttitor nec id dui. Etiam eu ipsum sagittis, maximus lectus non, semper justo. Fusce orci tellus, congue et consequat nec, facilisis accumsan enim. Proin facilisis quis libero a viverra. Curabitur neque magna, euismod in lacinia nec, scelerisque nec ex. - -Donec nec ullamcorper turpis. Praesent ultrices nunc non dignissim auctor. Morbi at congue lacus. Ut ut diam nec magna finibus ullamcorper. Donec auctor est ut tempor euismod. Proin tincidunt ipsum ac leo aliquet finibus. Curabitur laoreet turpis id enim rutrum, quis tincidunt sem maximus. Vivamus quis diam at lorem viverra pretium. Quisque eget diam scelerisque, hendrerit purus at, blandit lacus. Sed quis consectetur lectus, vitae molestie neque. Quisque in nisi augue. - -Proin ultricies maximus tellus, sed malesuada metus posuere at. Vestibulum a purus ut libero tincidunt dictum et vel sapien. In auctor a metus in ullamcorper. Nullam pharetra pharetra ipsum, non gravida massa tempus non. Proin et varius nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque ullamcorper porttitor gravida. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Donec sit amet rhoncus turpis. Cras vel dui non felis consectetur varius vitae id turpis. Sed vitae hendrerit diam. Aenean neque turpis, laoreet eget libero a, pellentesque malesuada ipsum. Praesent bibendum ultrices nisi eu ornare. Nulla dignissim eu ipsum non iaculis. - -Ut eget lacus porta, posuere neque a, feugiat mi. Sed vehicula sed dui non imperdiet. Nulla quis fringilla nunc. Nunc ipsum dui, hendrerit eu diam sit amet, vehicula convallis libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque vel diam id felis ornare lobortis a in metus. Mauris feugiat tellus sit amet felis pellentesque ornare sit amet ac augue. Phasellus ut porta purus. Morbi vestibulum, nunc sed pellentesque rhoncus, nibh turpis varius justo, vel mollis ipsum risus at libero. Praesent eget convallis arcu. Donec placerat justo et odio dignissim interdum. Vestibulum rhoncus faucibus tempor. Quisque ipsum tortor, ullamcorper ut sagittis quis, elementum eget metus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; - -Suspendisse in mi non eros fermentum euismod a a tortor. Morbi tincidunt sagittis arcu, ut cursus urna luctus vel. Curabitur malesuada, dui at rutrum pretium, turpis sem vulputate urna, eget suscipit odio ipsum vitae enim. Nunc pellentesque nibh sed facilisis aliquam. Sed ac est sit amet dolor aliquam volutpat in ac risus. Nulla facilisi. Etiam gravida tincidunt metus vitae consectetur. Phasellus rutrum metus ut porttitor varius. Nullam sollicitudin orci ac vehicula accumsan. Maecenas vitae malesuada est. Nam viverra ante ante, id mollis justo sagittis sed. Ut facilisis, lectus id dignissim volutpat, nisl elit fringilla elit, vel facilisis neque lectus et neque. Etiam erat justo, interdum quis neque at, mattis tristique lorem. Mauris malesuada nibh ante, eget eleifend sapien condimentum efficitur. Suspendisse metus turpis, viverra vitae tortor eget, porttitor scelerisque leo. Aenean ac fermentum tortor, ut dapibus mi. - -Fusce semper velit ac tempor lobortis. Suspendisse venenatis eros est, quis sollicitudin dolor consequat vitae. Vivamus tristique erat quis eros laoreet, et dictum nibh sagittis. Integer iaculis pretium orci non venenatis. Aenean ultricies purus ac dui tempor, ut fringilla turpis feugiat. Suspendisse sodales vestibulum aliquet. Donec elit lectus, porta sit amet mollis eu, porttitor eu sem. Vivamus sit amet nisi vel leo commodo suscipit faucibus porttitor orci. Quisque ut sollicitudin quam, luctus pharetra risus. Ut tempus diam odio, elementum porttitor lacus sollicitudin non. Curabitur eget eleifend nisi. Nullam porttitor sagittis gravida. Donec sodales a lorem vel fermentum. Aliquam ac rhoncus quam. - -Fusce pulvinar imperdiet diam et sollicitudin. Quisque a urna id ex porttitor venenatis sit amet id ligula. In fringilla euismod orci vitae pulvinar. In facilisis non nibh ac rutrum. Quisque aliquam sem sit amet pharetra pellentesque. Donec imperdiet libero sed sapien consequat vehicula. Integer vitae ornare sapien. Vivamus pretium felis at urna gravida, quis luctus sem feugiat. Fusce nisl metus, dictum vitae maximus in, interdum id nunc. Phasellus sodales nibh at mi porta egestas quis nec nisl. - -Fusce vel suscipit erat, quis vulputate quam. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam a odio nulla. Suspendisse ac tincidunt erat. Duis tortor sem, blandit sed arcu vehicula, faucibus vehicula eros. Sed gravida faucibus quam sed condimentum. Donec sed imperdiet sem. Quisque purus mauris, ultrices sit amet nisl ut, luctus convallis enim. Quisque sit amet nisi ut lacus ullamcorper placerat et id dolor. Mauris tincidunt quam id posuere sodales. Integer tristique efficitur varius. Nulla facilisi. Morbi sed odio eget neque ornare congue. Duis dui massa, maximus ac ullamcorper nec, tempus ut magna. Morbi dictum nisl sagittis orci hendrerit, ac consequat odio pulvinar. Ut mollis sodales egestas. - -Maecenas ante libero, aliquam in enim quis, aliquet malesuada mauris. Quisque porta massa id sem lacinia, id blandit diam mollis. Donec rhoncus vestibulum ante. Aliquam id ligula a erat bibendum condimentum congue non eros. Praesent ac lectus convallis, laoreet quam vitae, viverra arcu. Morbi finibus ligula risus, et ornare turpis iaculis eget. Donec placerat metus vel ex mattis tristique. Donec varius dapibus leo eu pulvinar. Fusce et diam mauris. Duis consequat pharetra urna id malesuada.
\ No newline at end of file diff --git a/tests/head.php b/tests/head.php deleted file mode 100644 index 80733166..00000000 --- a/tests/head.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -$rr = new RoadRunner\Worker($relay); - -while ($in = $rr->waitPayload()) { - try { - $rr->respond(new RoadRunner\Payload("", (string)$in->header)); - } catch (\Throwable $e) { - $rr->error((string)$e); - } -} diff --git a/tests/http/client.php b/tests/http/client.php deleted file mode 100644 index 90b5c2b5..00000000 --- a/tests/http/client.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require dirname(__DIR__) . "/vendor/autoload.php"; - -if (count($argv) < 3) { - die("need 2 arguments"); -} - -list($test, $goridge) = [$argv[1], $argv[2]]; - -switch ($goridge) { - case "pipes": - $relay = new Goridge\StreamRelay(STDIN, STDOUT); - break; - - case "tcp": - $relay = new Goridge\SocketRelay("127.0.0.1", 9007); - break; - - case "unix": - $relay = new Goridge\SocketRelay( - "sock.unix", - null, - Goridge\SocketRelay::SOCK_UNIX - ); - break; - - default: - die("invalid protocol selection"); -} - -$psr7 = new RoadRunner\Http\PSR7Worker( - new RoadRunner\Worker($relay), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -require_once sprintf("%s/%s.php", __DIR__, $test); - -while ($req = $psr7->waitRequest()) { - try { - $psr7->respond(handleRequest($req, new \Nyholm\Psr7\Response())); - } catch (\Throwable $e) { - $psr7->getWorker()->error((string)$e); - } -} diff --git a/tests/http/cookie.php b/tests/http/cookie.php deleted file mode 100644 index 97673ef5..00000000 --- a/tests/http/cookie.php +++ /dev/null @@ -1,334 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write(strtoupper($req->getCookieParams()['input'])); - - return $resp->withAddedHeader( - "Set-Cookie", - (new Cookie('output', 'cookie-output'))->createHeader() - ); -} - -final class Cookie -{ - /** - * The name of the cookie. - * - * @var string - */ - private $name = ''; - /** - * The value of the cookie. This value is stored on the clients computer; do not store sensitive - * information. - * - * @var string|null - */ - private $value = null; - /** - * Cookie lifetime. This value specified in seconds and declares period of time in which cookie - * will expire relatively to current time() value. - * - * @var int|null - */ - private $lifetime = null; - /** - * The path on the server in which the cookie will be available on. - * - * If set to '/', the cookie will be available within the entire domain. If set to '/foo/', - * the cookie will only be available within the /foo/ directory and all sub-directories such as - * /foo/bar/ of domain. The default value is the current directory that the cookie is being set - * in. - * - * @var string|null - */ - private $path = null; - /** - * The domain that the cookie is available. To make the cookie available on all subdomains of - * example.com then you'd set it to '.example.com'. The . is not required but makes it - * compatible with more browsers. Setting it to www.example.com will make the cookie only - * available in the www subdomain. Refer to tail matching in the spec for details. - * - * @var string|null - */ - private $domain = null; - /** - * Indicates that the cookie should only be transmitted over a secure HTTPS connection from the - * client. When set to true, the cookie will only be set if a secure connection exists. - * On the server-side, it's on the programmer to send this kind of cookie only on secure - * connection - * (e.g. with respect to $_SERVER["HTTPS"]). - * - * @var bool|null - */ - private $secure = null; - /** - * When true the cookie will be made accessible only through the HTTP protocol. This means that - * the cookie won't be accessible by scripting languages, such as JavaScript. This setting can - * effectively help to reduce identity theft through XSS attacks (although it is not supported - * by all browsers). - * - * @var bool - */ - private $httpOnly = true; - - /** - * New Cookie instance, cookies used to schedule cookie set while dispatching Response. - * - * @link http://php.net/manual/en/function.setcookie.php - * - * @param string $name The name of the cookie. - * @param string $value The value of the cookie. This value is stored on the clients - * computer; do not store sensitive information. - * @param int $lifetime Cookie lifetime. This value specified in seconds and declares period - * of time in which cookie will expire relatively to current time() - * value. - * @param string $path The path on the server in which the cookie will be available on. - * If set to '/', the cookie will be available within the entire - * domain. - * If set to '/foo/', the cookie will only be available within the - * /foo/ - * directory and all sub-directories such as /foo/bar/ of domain. The - * default value is the current directory that the cookie is being set - * in. - * @param string $domain The domain that the cookie is available. To make the cookie - * available - * on all subdomains of example.com then you'd set it to - * '.example.com'. - * The . is not required but makes it compatible with more browsers. - * Setting it to www.example.com will make the cookie only available in - * the www subdomain. Refer to tail matching in the spec for details. - * @param bool $secure Indicates that the cookie should only be transmitted over a secure - * HTTPS connection from the client. When set to true, the cookie will - * only be set if a secure connection exists. On the server-side, it's - * on the programmer to send this kind of cookie only on secure - * connection (e.g. with respect to $_SERVER["HTTPS"]). - * @param bool $httpOnly When true the cookie will be made accessible only through the HTTP - * protocol. This means that the cookie won't be accessible by - * scripting - * languages, such as JavaScript. This setting can effectively help to - * reduce identity theft through XSS attacks (although it is not - * supported by all browsers). - */ - public function __construct( - string $name, - string $value = null, - int $lifetime = null, - string $path = null, - string $domain = null, - bool $secure = false, - bool $httpOnly = true - ) { - $this->name = $name; - $this->value = $value; - $this->lifetime = $lifetime; - $this->path = $path; - $this->domain = $domain; - $this->secure = $secure; - $this->httpOnly = $httpOnly; - } - - /** - * The name of the cookie. - * - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * The value of the cookie. This value is stored on the clients computer; do not store sensitive - * information. - * - * @return string|null - */ - public function getValue() - { - return $this->value; - } - - /** - * The time the cookie expires. This is a Unix timestamp so is in number of seconds since the - * epoch. In other words, you'll most likely set this with the time function plus the number of - * seconds before you want it to expire. Or you might use mktime. - * - * Will return null if lifetime is not specified. - * - * @return int|null - */ - public function getExpires() - { - if ($this->lifetime === null) { - return null; - } - - return time() + $this->lifetime; - } - - /** - * The path on the server in which the cookie will be available on. - * - * If set to '/', the cookie will be available within the entire domain. If set to '/foo/', - * the cookie will only be available within the /foo/ directory and all sub-directories such as - * /foo/bar/ of domain. The default value is the current directory that the cookie is being set - * in. - * - * @return string|null - */ - public function getPath() - { - return $this->path; - } - - /** - * The domain that the cookie is available. To make the cookie available on all subdomains of - * example.com then you'd set it to '.example.com'. The . is not required but makes it - * compatible with more browsers. Setting it to www.example.com will make the cookie only - * available in the www subdomain. Refer to tail matching in the spec for details. - * - * @return string|null - */ - public function getDomain() - { - return $this->domain; - } - - /** - * Indicates that the cookie should only be transmitted over a secure HTTPS connection from the - * client. When set to true, the cookie will only be set if a secure connection exists. - * On the server-side, it's on the programmer to send this kind of cookie only on secure - * connection - * (e.g. with respect to $_SERVER["HTTPS"]). - * - * @return bool - */ - public function isSecure(): bool - { - return $this->secure; - } - - /** - * When true the cookie will be made accessible only through the HTTP protocol. This means that - * the cookie won't be accessible by scripting languages, such as JavaScript. This setting can - * effectively help to reduce identity theft through XSS attacks (although it is not supported - * by all browsers). - * - * @return bool - */ - public function isHttpOnly(): bool - { - return $this->httpOnly; - } - - /** - * Get new cookie with altered value. Original cookie object should not be changed. - * - * @param string $value - * - * @return Cookie - */ - public function withValue(string $value): self - { - $cookie = clone $this; - $cookie->value = $value; - - return $cookie; - } - - /** - * Convert cookie instance to string. - * - * @link http://www.w3.org/Protocols/rfc2109/rfc2109 - * @return string - */ - public function createHeader(): string - { - $header = [ - rawurlencode($this->name) . '=' . rawurlencode($this->value) - ]; - if ($this->lifetime !== null) { - $header[] = 'Expires=' . gmdate(\DateTime::COOKIE, $this->getExpires()); - $header[] = 'Max-Age=' . $this->lifetime; - } - if (!empty($this->path)) { - $header[] = 'Path=' . $this->path; - } - if (!empty($this->domain)) { - $header[] = 'Domain=' . $this->domain; - } - if ($this->secure) { - $header[] = 'Secure'; - } - if ($this->httpOnly) { - $header[] = 'HttpOnly'; - } - - return join('; ', $header); - } - - /** - * New Cookie instance, cookies used to schedule cookie set while dispatching Response. - * Static constructor. - * - * @link http://php.net/manual/en/function.setcookie.php - * - * @param string $name The name of the cookie. - * @param string $value The value of the cookie. This value is stored on the clients - * computer; do not store sensitive information. - * @param int $lifetime Cookie lifetime. This value specified in seconds and declares period - * of time in which cookie will expire relatively to current time() - * value. - * @param string $path The path on the server in which the cookie will be available on. - * If set to '/', the cookie will be available within the entire - * domain. - * If set to '/foo/', the cookie will only be available within the - * /foo/ - * directory and all sub-directories such as /foo/bar/ of domain. The - * default value is the current directory that the cookie is being set - * in. - * @param string $domain The domain that the cookie is available. To make the cookie - * available - * on all subdomains of example.com then you'd set it to - * '.example.com'. - * The . is not required but makes it compatible with more browsers. - * Setting it to www.example.com will make the cookie only available in - * the www subdomain. Refer to tail matching in the spec for details. - * @param bool $secure Indicates that the cookie should only be transmitted over a secure - * HTTPS connection from the client. When set to true, the cookie will - * only be set if a secure connection exists. On the server-side, it's - * on the programmer to send this kind of cookie only on secure - * connection (e.g. with respect to $_SERVER["HTTPS"]). - * @param bool $httpOnly When true the cookie will be made accessible only through the HTTP - * protocol. This means that the cookie won't be accessible by - * scripting - * languages, such as JavaScript. This setting can effectively help to - * reduce identity theft through XSS attacks (although it is not - * supported by all browsers). - * - * @return Cookie - */ - public static function create( - string $name, - string $value = null, - int $lifetime = null, - string $path = null, - string $domain = null, - bool $secure = false, - bool $httpOnly = true - ): self { - return new self($name, $value, $lifetime, $path, $domain, $secure, $httpOnly); - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->createHeader(); - } -} diff --git a/tests/http/data.php b/tests/http/data.php deleted file mode 100644 index 6570936a..00000000 --- a/tests/http/data.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $data = $req->getParsedBody(); - - ksort($data); - ksort($data['arr']); - ksort($data['arr']['x']['y']); - - $resp->getBody()->write(json_encode($data)); - - return $resp; -} diff --git a/tests/http/echo.php b/tests/http/echo.php deleted file mode 100644 index 08e29a26..00000000 --- a/tests/http/echo.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -use \Psr\Http\Message\ServerRequestInterface; -use \Psr\Http\Message\ResponseInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write(strtoupper($req->getQueryParams()['hello'])); - return $resp->withStatus(201); -} diff --git a/tests/http/echoDelay.php b/tests/http/echoDelay.php deleted file mode 100644 index 78e85477..00000000 --- a/tests/http/echoDelay.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use \Psr\Http\Message\ServerRequestInterface; -use \Psr\Http\Message\ResponseInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - sleep(1); - $resp->getBody()->write(strtoupper($req->getQueryParams()['hello'])); - return $resp->withStatus(201); -} diff --git a/tests/http/echoerr.php b/tests/http/echoerr.php deleted file mode 100644 index 7e1d05e7..00000000 --- a/tests/http/echoerr.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -use \Psr\Http\Message\ServerRequestInterface; -use \Psr\Http\Message\ResponseInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - error_log(strtoupper($req->getQueryParams()['hello'])); - - $resp->getBody()->write(strtoupper($req->getQueryParams()['hello'])); - return $resp->withStatus(201); -} diff --git a/tests/http/env.php b/tests/http/env.php deleted file mode 100644 index 3755bdea..00000000 --- a/tests/http/env.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write($_SERVER['ENV_KEY']); - return $resp; -} diff --git a/tests/http/error.php b/tests/http/error.php deleted file mode 100644 index 527e4068..00000000 --- a/tests/http/error.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - throw new Error("error"); -} diff --git a/tests/http/error2.php b/tests/http/error2.php deleted file mode 100644 index 12a672ac..00000000 --- a/tests/http/error2.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - exit(); -} diff --git a/tests/http/header.php b/tests/http/header.php deleted file mode 100644 index 393d9623..00000000 --- a/tests/http/header.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write(strtoupper($req->getHeaderLine('input'))); - - return $resp->withAddedHeader("Header", $req->getQueryParams()['hello']); -} diff --git a/tests/http/headers.php b/tests/http/headers.php deleted file mode 100644 index b6f3967a..00000000 --- a/tests/http/headers.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write(json_encode($req->getHeaders())); - - return $resp; -} diff --git a/tests/http/ip.php b/tests/http/ip.php deleted file mode 100644 index 49eb9285..00000000 --- a/tests/http/ip.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write($req->getServerParams()['REMOTE_ADDR']); - - return $resp; -} diff --git a/tests/http/memleak.php b/tests/http/memleak.php deleted file mode 100644 index 197a7fb1..00000000 --- a/tests/http/memleak.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $mem = ''; - $mem .= str_repeat(" ", 1024*1024); - return $resp; -} diff --git a/tests/http/payload.php b/tests/http/payload.php deleted file mode 100644 index b7a0311f..00000000 --- a/tests/http/payload.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - if ($req->getHeaderLine("Content-Type") != 'application/json') { - $resp->getBody()->write("invalid content-type"); - return $resp; - } - - // we expect json body - $p = json_decode($req->getBody(), true); - $resp->getBody()->write(json_encode(array_flip($p))); - - return $resp; -} diff --git a/tests/http/pid.php b/tests/http/pid.php deleted file mode 100644 index f22d8e23..00000000 --- a/tests/http/pid.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write((string)getmypid()); - - return $resp; -} diff --git a/tests/http/push.php b/tests/http/push.php deleted file mode 100644 index d88fc076..00000000 --- a/tests/http/push.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -use \Psr\Http\Message\ServerRequestInterface; -use \Psr\Http\Message\ResponseInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write(strtoupper($req->getQueryParams()['hello'])); - return $resp->withAddedHeader("Http2-Push", __FILE__)->withStatus(201); -} diff --git a/tests/http/request-uri.php b/tests/http/request-uri.php deleted file mode 100644 index d4c87551..00000000 --- a/tests/http/request-uri.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write($_SERVER['REQUEST_URI']); - return $resp; -} diff --git a/tests/http/server.php b/tests/http/server.php deleted file mode 100644 index 393d9623..00000000 --- a/tests/http/server.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write(strtoupper($req->getHeaderLine('input'))); - - return $resp->withAddedHeader("Header", $req->getQueryParams()['hello']); -} diff --git a/tests/http/slow-client.php b/tests/http/slow-client.php deleted file mode 100644 index 1eaa7bc8..00000000 --- a/tests/http/slow-client.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require dirname(__DIR__) . "/vendor/autoload.php"; - -if (count($argv) < 3) { - die("need 2 arguments"); -} - -[$test, $goridge, $bootDelay] = [$argv[1], $argv[2], $argv[3]]; -usleep($bootDelay * 1000); - -switch ($goridge) { - case "pipes": - $relay = new Goridge\StreamRelay(STDIN, STDOUT); - break; - - case "tcp": - $relay = new Goridge\SocketRelay("127.0.0.1", 9007); - break; - - case "unix": - $relay = new Goridge\SocketRelay( - "sock.unix", - null, - Goridge\SocketRelay::SOCK_UNIX - ); - break; - - default: - die("invalid protocol selection"); -} - -$psr7 = new RoadRunner\Http\PSR7Worker( - new RoadRunner\Worker($relay), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -require_once sprintf("%s/%s.php", __DIR__, $test); - -while ($req = $psr7->waitRequest()) { - try { - $psr7->respond(handleRequest($req, new \Nyholm\Psr7\Response())); - } catch (\Throwable $e) { - $psr7->getWorker()->error((string) $e); - } -} diff --git a/tests/http/stuck.php b/tests/http/stuck.php deleted file mode 100644 index 2dea0572..00000000 --- a/tests/http/stuck.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -use \Psr\Http\Message\ServerRequestInterface; -use \Psr\Http\Message\ResponseInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - sleep(10); - $resp->getBody()->write(strtoupper($req->getQueryParams()['hello'])); - return $resp->withStatus(201); -} diff --git a/tests/http/upload.php b/tests/http/upload.php deleted file mode 100644 index 57526246..00000000 --- a/tests/http/upload.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $files = $req->getUploadedFiles(); - array_walk_recursive($files, function (&$v) { - /** - * @var \Psr\Http\Message\UploadedFileInterface $v - */ - - if ($v->getError()) { - $v = [ - 'name' => $v->getClientFilename(), - 'size' => $v->getSize(), - 'mime' => $v->getClientMediaType(), - 'error' => $v->getError(), - ]; - } else { - $v = [ - 'name' => $v->getClientFilename(), - 'size' => $v->getSize(), - 'mime' => $v->getClientMediaType(), - 'error' => $v->getError(), - 'sha512' => hash('sha512', $v->getStream()->__toString()), - ]; - } - }); - - $resp->getBody()->write(json_encode($files, JSON_UNESCAPED_SLASHES)); - - return $resp; -} diff --git a/tests/http/user-agent.php b/tests/http/user-agent.php deleted file mode 100644 index 03d7a2c8..00000000 --- a/tests/http/user-agent.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface -{ - $resp->getBody()->write($_SERVER['HTTP_USER_AGENT']); - return $resp; -} diff --git a/tests/idle.php b/tests/idle.php deleted file mode 100644 index fb5c9df2..00000000 --- a/tests/idle.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); - -while($rr->waitPayload()){ - sleep(3); - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} diff --git a/tests/issue659.php b/tests/issue659.php deleted file mode 100644 index 2a0e4f19..00000000 --- a/tests/issue659.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT)); -$psr7 = new RoadRunner\Http\PSR7Worker( - $worker, - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -while ($req = $psr7->waitRequest()) { - $psr7->getWorker()->error("test_error"); -} diff --git a/tests/memleak.php b/tests/memleak.php deleted file mode 100644 index 96ed5006..00000000 --- a/tests/memleak.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); -$mem = ''; -while($rr->waitPayload()){ - $mem .= str_repeat("a", 1024*1024*10); - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} diff --git a/tests/metrics-issue-571.php b/tests/metrics-issue-571.php deleted file mode 100644 index 947ae1f7..00000000 --- a/tests/metrics-issue-571.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -use Spiral\Goridge; -use Spiral\RoadRunner; -use Nyholm\Psr7\Factory; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = new RoadRunner\Http\PSR7Worker( - RoadRunner\Worker::create(), - new Factory\Psr17Factory(), - new Factory\Psr17Factory(), - new Factory\Psr17Factory() -); - -$metrics = new RoadRunner\Metrics\Metrics( - Goridge\RPC\RPC::create(RoadRunner\Environment::fromGlobals()->getRPCAddress()) -); - -$metrics->declare( - 'test', - RoadRunner\Metrics\Collector::counter()->withHelp('Test counter') -); - -while ($req = $worker->waitRequest()) { - try { - $rsp = new \Nyholm\Psr7\Response(); - $rsp->getBody()->write("hello world"); - - $metrics->add('test', 1); - - $worker->respond($rsp); - } catch (\Throwable $e) { - $worker->getWorker()->error((string)$e); - } -} diff --git a/tests/pid.php b/tests/pid.php deleted file mode 100644 index 962b609a..00000000 --- a/tests/pid.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - /** - * @var Goridge\RelayInterface $relay - */ - - use Spiral\Goridge; - use Spiral\RoadRunner; - - $rr = new RoadRunner\Worker($relay); - - while ($in = $rr->waitPayload()) { - try { - $rr->respond(new RoadRunner\Payload((string)getmypid())); - } catch (\Throwable $e) { - $rr->error((string)$e); - } - } diff --git a/tests/pipes_test_script.sh b/tests/pipes_test_script.sh deleted file mode 100755 index c759b0a6..00000000 --- a/tests/pipes_test_script.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -php ../../tests/client.php echo pipes diff --git a/tests/psr-worker-bench.php b/tests/psr-worker-bench.php deleted file mode 100644 index e809f380..00000000 --- a/tests/psr-worker-bench.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = RoadRunner\Worker::create(); -$psr7 = new RoadRunner\Http\PSR7Worker( - $worker, - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -while ($req = $psr7->waitRequest()) { - try { - $resp = new \Nyholm\Psr7\Response(); - $resp->getBody()->write("hello world"); - - $psr7->respond($resp); - } catch (\Throwable $e) { - $psr7->getWorker()->error((string)$e); - } -} diff --git a/tests/psr-worker-post.php b/tests/psr-worker-post.php deleted file mode 100644 index 2f54af5b..00000000 --- a/tests/psr-worker-post.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = RoadRunner\Worker::create(); -$psr7 = new RoadRunner\Http\PSR7Worker( - $worker, - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -while ($req = $psr7->waitRequest()) { - try { - $resp = new \Nyholm\Psr7\Response(); - $resp->getBody()->write((string) $req->getBody()); - - $psr7->respond($resp); - } catch (\Throwable $e) { - $psr7->getWorker()->error((string)$e); - } -} diff --git a/tests/psr-worker-slow.php b/tests/psr-worker-slow.php deleted file mode 100644 index 153dff68..00000000 --- a/tests/psr-worker-slow.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT)); -$psr7 = new RoadRunner\Http\PSR7Worker( - $worker, - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -while ($req = $psr7->waitRequest()) { - try { - $resp = new \Nyholm\Psr7\Response(); - sleep(mt_rand(1,20)); - $resp->getBody()->write("hello world"); - - $psr7->respond($resp); - } catch (\Throwable $e) { - $psr7->getWorker()->error((string)$e); - } -} diff --git a/tests/psr-worker.php b/tests/psr-worker.php deleted file mode 100644 index db53eee2..00000000 --- a/tests/psr-worker.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT)); -$psr7 = new RoadRunner\Http\PSR7Worker( - $worker, - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -while ($req = $psr7->waitRequest()) { - try { - $resp = new \Nyholm\Psr7\Response(); - $resp->getBody()->write(str_repeat("hello world", 1000)); - - $psr7->respond($resp); - } catch (\Throwable $e) { - $psr7->getWorker()->error((string)$e); - } -} diff --git a/tests/raw-error.php b/tests/raw-error.php deleted file mode 100644 index 3caf46c5..00000000 --- a/tests/raw-error.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ -use Spiral\Goridge; -use Spiral\RoadRunner; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT)); -$psr7 = new RoadRunner\Http\PSR7Worker( - $worker, - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory(), - new \Nyholm\Psr7\Factory\Psr17Factory() -); - -error_log('{"field": "value"}'); - -while ($req = $psr7->waitRequest()) {} diff --git a/tests/sample.txt b/tests/sample.txt deleted file mode 100644 index d64a3d96..00000000 --- a/tests/sample.txt +++ /dev/null @@ -1 +0,0 @@ -sample diff --git a/tests/sleep-ttl.php b/tests/sleep-ttl.php deleted file mode 100644 index 2230e615..00000000 --- a/tests/sleep-ttl.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); - -while($rr->waitPayload()){ - sleep(10); - $rr->respond(new \Spiral\RoadRunner\Payload("hello world")); -} diff --git a/tests/sleep.php b/tests/sleep.php deleted file mode 100644 index d36ae3e3..00000000 --- a/tests/sleep.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); - -while($rr->waitPayload()){ - sleep(300); - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} diff --git a/tests/slow-client.php b/tests/slow-client.php deleted file mode 100644 index c21b45d2..00000000 --- a/tests/slow-client.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -use Spiral\Goridge; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -if (count($argv) < 3) { - die("need 2 arguments"); -} - -list($test, $goridge, $bootDelay, $shutdownDelay) = [$argv[1], $argv[2], $argv[3], $argv[4]]; - -switch ($goridge) { - case "pipes": - $relay = new Goridge\StreamRelay(STDIN, STDOUT); - break; - - case "tcp": - $relay = new Goridge\SocketRelay("127.0.0.1", 9007); - break; - - case "unix": - $relay = new Goridge\SocketRelay( - "sock.unix", - null, - Goridge\SocketRelay::SOCK_UNIX - ); - - break; - - default: - die("invalid protocol selection"); -} - -usleep($bootDelay * 1000); -require_once sprintf("%s/%s.php", __DIR__, $test); -usleep($shutdownDelay * 1000); diff --git a/tests/slow-destroy.php b/tests/slow-destroy.php deleted file mode 100644 index 2edbc0db..00000000 --- a/tests/slow-destroy.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -use Spiral\Goridge; - -ini_set('display_errors', 'stderr'); -require __DIR__ . "/vendor/autoload.php"; - -if (count($argv) < 3) { - die("need 2 arguments"); -} - -list($test, $goridge) = [$argv[1], $argv[2]]; - -switch ($goridge) { - case "pipes": - $relay = new Goridge\StreamRelay(STDIN, STDOUT); - break; - - case "tcp": - $relay = new Goridge\SocketRelay("127.0.0.1", 9007); - break; - - case "unix": - $relay = new Goridge\SocketRelay( - "sock.unix", - null, - Goridge\SocketRelay::SOCK_UNIX - ); - break; - - default: - die("invalid protocol selection"); -} - -require_once sprintf("%s/%s.php", __DIR__, $test); - -sleep(10); diff --git a/tests/slow-pid.php b/tests/slow-pid.php deleted file mode 100644 index 82785610..00000000 --- a/tests/slow-pid.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - /** - * @var Goridge\RelayInterface $relay - */ - - use Spiral\Goridge; - use Spiral\RoadRunner; - - $rr = new RoadRunner\Worker($relay); - - while ($in = $rr->waitPayload()) { - try { - sleep(1); - $rr->respond(new RoadRunner\Payload((string)getmypid())); - } catch (\Throwable $e) { - $rr->error((string)$e); - } - } diff --git a/tests/socket_test_script.sh b/tests/socket_test_script.sh deleted file mode 100755 index 3948c4fb..00000000 --- a/tests/socket_test_script.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -php ../../tests/client.php echo tcp diff --git a/tests/src/Activity/SimpleActivity.php b/tests/src/Activity/SimpleActivity.php deleted file mode 100644 index 576b126e..00000000 --- a/tests/src/Activity/SimpleActivity.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -namespace Temporal\Tests\Activity; - -use Temporal\Activity\ActivityInterface; -use Temporal\Activity\ActivityMethod; -use Temporal\Api\Common\V1\WorkflowExecution; -use Temporal\DataConverter\Bytes; -use Temporal\Tests\DTO\Message; -use Temporal\Tests\DTO\User; - -#[ActivityInterface(prefix: "SimpleActivity.")] -class SimpleActivity -{ - #[ActivityMethod] - public function echo( - string $input - ): string { - return strtoupper($input); - } - - #[ActivityMethod] - public function lower( - string $input - ): string { - return strtolower($input); - } - - #[ActivityMethod] - public function greet( - User $user - ): Message { - return new Message(sprintf("Hello %s <%s>", $user->name, $user->email)); - } - - #[ActivityMethod] - public function slow( - string $input - ): string { - sleep(2); - - return strtolower($input); - } - - #[ActivityMethod] - public function sha512( - Bytes $input - ): string { - return hash("sha512", ($input->getData())); - } - - public function updateRunID(WorkflowExecution $e): WorkflowExecution - { - $e->setRunId('updated'); - return $e; - } - - #[ActivityMethod] - public function fail() - { - throw new \Error("failed activity"); - } -}
\ No newline at end of file diff --git a/tests/src/Client/StartNewWorkflow.php b/tests/src/Client/StartNewWorkflow.php deleted file mode 100644 index 67bc1d01..00000000 --- a/tests/src/Client/StartNewWorkflow.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - - -namespace Temporal\Tests\Client; - -use Temporal\Client; -use Temporal\Tests\Workflow\SimpleDTOWorkflow; - -use function Symfony\Component\String\s; - -class StartNewWorkflow -{ - private $stub; - - public function __construct(Client\ClientInterface $client) - { - $this->stub = $client->newWorkflowStub(SimpleDTOWorkflow::class); - } - - public function __invoke() - { - } -} diff --git a/tests/src/Workflow/SagaWorkflow.php b/tests/src/Workflow/SagaWorkflow.php deleted file mode 100644 index e47c0203..00000000 --- a/tests/src/Workflow/SagaWorkflow.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -/** - * This file is part of Temporal package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Temporal\Tests\Workflow; - -use Temporal\Activity\ActivityOptions; -use Temporal\Common\RetryOptions; -use Temporal\Tests\Activity\SimpleActivity; -use Temporal\Workflow; - -#[Workflow\WorkflowInterface] -class SagaWorkflow -{ - #[Workflow\WorkflowMethod(name: 'SagaWorkflow')] - public function run() - { - $simple = Workflow::newActivityStub( - SimpleActivity::class, - ActivityOptions::new() - ->withStartToCloseTimeout(60) - ->withRetryOptions(RetryOptions::new()->withMaximumAttempts(1)) - ); - - $saga = new Workflow\Saga(); - $saga->setParallelCompensation(true); - - try { - yield $simple->echo('test'); - $saga->addCompensation( - function () use ($simple) { - yield $simple->echo('compensate echo'); - } - ); - - yield $simple->lower('TEST'); - $saga->addCompensation( - function () use ($simple) { - yield $simple->lower('COMPENSATE LOWER'); - } - ); - - yield $simple->fail(); - } catch (\Throwable $e) { - yield $saga->compensate(); - throw $e; - } - } -} diff --git a/tests/stop.php b/tests/stop.php deleted file mode 100644 index 93263821..00000000 --- a/tests/stop.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * @var Goridge\RelayInterface $relay - */ - -use Spiral\Goridge; -use Spiral\RoadRunner; - -$rr = new RoadRunner\Worker($relay); - -$used = false; -while ($in = $rr->waitPayload()) { - try { - if ($used) { - // kill on second attempt - $rr->stop(); - continue; - } - - $used = true; - $rr->respond(new RoadRunner\Payload((string)getmypid())); - } catch (\Throwable $e) { - $rr->error((string)$e); - } -} diff --git a/tests/supervised.php b/tests/supervised.php deleted file mode 100644 index 74f8c994..00000000 --- a/tests/supervised.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -declare(strict_types=1); - -use Spiral\Goridge\StreamRelay; -use Spiral\RoadRunner\Worker as RoadRunner; - -require __DIR__ . "/vendor/autoload.php"; - -$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); -$mem = ''; -while($rr->waitPayload()){ - $rr->respond(new \Spiral\RoadRunner\Payload("")); -} |