Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/.* export-ignore
/tests export-ignore
/phpunit.xml* export-ignore
/testo.php export-ignore
/psalm.* export-ignore
/psalm-baseline.xml export-ignore
/infection.* export-ignore
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/phpunit.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/testo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
pull_request: null
push:
branches:
- 4.x

name: testo

jobs:
testo:
uses: spiral/gh-actions/.github/workflows/testo.yml@master
with:
os: >-
["ubuntu-latest"]
dependencies: >-
["lowest","highest"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ vendor/bin/rr get

Ensure that your server is configured with the following PHP versions and extensions:

- PHP >=8.1
- PHP >=8.2
- ext-protobuf: This extension is optional but **highly recommended for installation**.
Without it, performance may be up to 50% lower.
- RoadRunner ^3.0
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"chat": "https://discord.gg/V6EK4he"
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-json": "*",
"psr/http-factory": "^1.0.1",
"psr/http-message": "^1.0.1 || ^2.0",
Expand All @@ -48,12 +48,14 @@
},
"require-dev": {
"jetbrains/phpstorm-attributes": "^1.0",
"mockery/mockery": "^1.6.12",
"nyholm/psr7": "^1.3",
"phpunit/phpunit": "^10.5",
"spiral/code-style": "^2.3.1",
"spiral/dumper": "^3.3",
"symfony/process": "^6.2 || ^7.0",
"vimeo/psalm": "^6.13"
"testo/bridge-mockery": "^0.1.2",
"testo/testo": "^0.10.55",
"vimeo/psalm": "^6 || ^7"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -91,10 +93,12 @@
"psalm": "psalm",
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
"psalm:ci": "psalm --output-format=github --shepherd --show-info=false --stats --threads=4",
"test": "phpunit --color=always --testdox",
"test": "testo",
"test:cc": [
"@putenv XDEBUG_MODE=coverage",
"phpunit --coverage-clover=runtime/phpunit/logs/clover.xml --color=always"
]
"testo --coverage --coverage-clover=runtime/logs/clover.xml"
],
"test:unit": "testo --suite=Unit",
"test:feature": "testo --suite=Feature"
}
}
36 changes: 0 additions & 36 deletions phpunit.xml

This file was deleted.

24 changes: 24 additions & 0 deletions testo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use Testo\Application\Config\ApplicationConfig;
use Testo\Application\Config\SuiteConfig;
use Testo\Bridge\Mockery\MockeryPlugin;

return new ApplicationConfig(
src: ['src'],
suites: [
new SuiteConfig(
name: 'Unit',
location: ['tests/Unit'],
),
new SuiteConfig(
name: 'Feature',
location: ['tests/Feature'],
),
],
plugins: [
new MockeryPlugin(),
],
);
35 changes: 20 additions & 15 deletions tests/Feature/StreamResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Spiral\RoadRunner\Tests\Http\Feature;

use PHPUnit\Framework\TestCase;
use Spiral\Goridge\SocketRelay;
use Spiral\RoadRunner\Http\Exception\StreamStoppedException;
use Spiral\RoadRunner\Http\HttpWorker;
Expand All @@ -14,8 +13,14 @@
use Spiral\RoadRunner\Tests\Http\Server\Command\StreamStop;
use Spiral\RoadRunner\Tests\Http\Server\ServerRunner;
use Spiral\RoadRunner\Worker;

class StreamResponseTest extends TestCase
use Testo\Assert;
use Testo\Expect;
use Testo\Lifecycle\AfterTest;
use Testo\Lifecycle\BeforeTest;
use Testo\Test;

#[Test]
final class StreamResponseTest
{
private SocketRelay $relay;
private Worker $worker;
Expand All @@ -30,7 +35,7 @@ public function testRegularCase(): void
$worker->respond(new Payload('Hello, World!'));

\usleep(100_000);
self::assertSame('Hello, World!', \trim(ServerRunner::getBuffer()));
Assert::same(\trim(ServerRunner::getBuffer()), 'Hello, World!');
}

/**
Expand All @@ -50,7 +55,7 @@ public function testStreamResponseWithMultipleFrames(): void
);

\usleep(100_000);
self::assertSame(\implode("\n", $chunks), \trim(ServerRunner::getBuffer()));
Assert::same(\trim(ServerRunner::getBuffer()), \implode("\n", $chunks));
}

public function testStopStreamResponse(): void
Expand Down Expand Up @@ -78,14 +83,14 @@ public function testStopStreamResponse(): void


\usleep(100_000);
self::assertSame(\implode("\n", ['Hel', 'lo,']), \trim(ServerRunner::getBuffer()));
Assert::same(\trim(ServerRunner::getBuffer()), \implode("\n", ['Hel', 'lo,']));
}

public function testSend1xxWithBody(): void
{
$httpWorker = $this->makeHttpWorker();

$this->expectExceptionMessage('Unable to send a body with informational status code');
Expect::exception(\Throwable::class)->withMessageContaining('Unable to send a body with informational status code');

$httpWorker->respond(
103,
Expand Down Expand Up @@ -114,7 +119,7 @@ public function testExceptionInGenerator(): void


\usleep(100_000);
self::assertSame(\implode("\n", ['Hel', 'lo,']), \trim(ServerRunner::getBuffer()));
Assert::same(\trim(ServerRunner::getBuffer()), \implode("\n", ['Hel', 'lo,']));
}

/**
Expand All @@ -136,30 +141,30 @@ public function testStopStreamAfterStreamEnd(): void
})(),
);

$this->assertFalse($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
Assert::false($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
$this->sendCommand(new StreamStop());
\usleep(200_000);
$this->assertSame(\implode("\n", ['Hello', 'World!']), \trim(ServerRunner::getBuffer()));
$this->assertTrue($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
Assert::same(\trim(ServerRunner::getBuffer()), \implode("\n", ['Hello', 'World!']));
Assert::true($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));

$this->getWorker()->getPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class);
$this->getWorker()->getPayload(GetProcessId::class);

$this->assertFalse($this->getWorker()->hasPayload());
Assert::false($this->getWorker()->hasPayload());
}

#[BeforeTest]
protected function setUp(): void
{
parent::setUp();
ServerRunner::start();
ServerRunner::getBuffer();
}

#[AfterTest]
protected function tearDown(): void
{
unset($this->relay, $this->worker);
ServerRunner::stop();
parent::tearDown();
}

private function getRelay(): SocketRelay
Expand All @@ -177,7 +182,7 @@ private function makeHttpWorker(): HttpWorker
return new HttpWorker($this->getWorker());
}

private function sendCommand(BaseCommand $command)
private function sendCommand(BaseCommand $command): void
{
$this->getRelay()->send($command->getRequestFrame());
\usleep(500_000);
Expand Down
13 changes: 7 additions & 6 deletions tests/Unit/GlobalStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

namespace Spiral\RoadRunner\Tests\Http\Unit;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Spiral\RoadRunner\Http\GlobalState;
use Spiral\RoadRunner\Http\Request;
use Testo\Assert;
use Testo\Data\DataProvider;
use Testo\Test;

final class GlobalStateTest extends TestCase
#[Test]
final class GlobalStateTest
{
/**
* @return iterable<array{0: Request, 1: array<array-key, mixed>}>
Expand Down Expand Up @@ -60,12 +62,11 @@ public function testEnrichServerVars(Request $request, array $expected): void

$server = GlobalState::enrichServerVars($request);

$this->assertArrayHasKey('REQUEST_TIME', $server);
$this->assertArrayHasKey('REQUEST_TIME_FLOAT', $server);
Assert::array($server)->hasKeys('REQUEST_TIME', 'REQUEST_TIME_FLOAT');

unset($server['REQUEST_TIME']);
unset($server['REQUEST_TIME_FLOAT']);

$this->assertEquals($server, $expected);
Assert::equals($server, $expected);
}
}
Loading
Loading