diff options
Diffstat (limited to 'tests')
5 files changed, 13 insertions, 13 deletions
diff --git a/tests/PHPUnit/Extensions/ServerExtension/PostRunSubscriber.php b/tests/PHPUnit/Extensions/ServerExtension/PostRunSubscriber.php index 308394e..46b9377 100644 --- a/tests/PHPUnit/Extensions/ServerExtension/PostRunSubscriber.php +++ b/tests/PHPUnit/Extensions/ServerExtension/PostRunSubscriber.php @@ -9,7 +9,7 @@ class PostRunSubscriber implements ExecutionFinishedSubscriber { public function __construct(private readonly \stdClass $dataObject) {} - + public function notify(ExecutionFinished $event): void { if ($this->dataObject->process_id > 0) { diff --git a/tests/PHPUnit/Extensions/ServerExtension/PreRunSubscriber.php b/tests/PHPUnit/Extensions/ServerExtension/PreRunSubscriber.php index ba35ee7..db5cdb4 100644 --- a/tests/PHPUnit/Extensions/ServerExtension/PreRunSubscriber.php +++ b/tests/PHPUnit/Extensions/ServerExtension/PreRunSubscriber.php @@ -9,7 +9,7 @@ class PreRunSubscriber implements ExecutionStartedSubscriber { public function __construct(private \stdClass $dataObject) {} - + public function notify(ExecutionStarted $event): void { $this->dataObject->process_id = (int)shell_exec("php -S localhost:8080 -t public > /dev/null 2>&1 & echo $!"); diff --git a/tests/PHPUnit/Extensions/ServerExtension/ServerExtension.php b/tests/PHPUnit/Extensions/ServerExtension/ServerExtension.php index a98f593..9656a14 100644 --- a/tests/PHPUnit/Extensions/ServerExtension/ServerExtension.php +++ b/tests/PHPUnit/Extensions/ServerExtension/ServerExtension.php @@ -12,7 +12,7 @@ class ServerExtension implements Extension public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void { $dataObject = new \stdClass(); - + $facade->registerSubscriber(new PreRunSubscriber($dataObject)); $facade->registerSubscriber(new PostRunSubscriber($dataObject)); } diff --git a/tests/PHPUnit/TestCases/HttpResponseTestCase.php b/tests/PHPUnit/TestCases/HttpResponseTestCase.php index 855e594..31dc1d7 100644 --- a/tests/PHPUnit/TestCases/HttpResponseTestCase.php +++ b/tests/PHPUnit/TestCases/HttpResponseTestCase.php @@ -9,14 +9,14 @@ use PHPUnit\Framework\TestCase; class HttpResponseTestCase extends TestCase { protected Client $client; - + protected function setUp(): void { $this->client = new Client([ "base_uri" => "http://localhost:8080", ]); } - + /** * @param array $options */ @@ -28,7 +28,7 @@ class HttpResponseTestCase extends TestCase ["http_errors" => false] + $options ); } - + public function hasJsonBody(Response $response): bool { json_decode((string)$response->getBody()); diff --git a/tests/ServerImplementationTest.php b/tests/ServerImplementationTest.php index 88be7c4..a48a8b8 100644 --- a/tests/ServerImplementationTest.php +++ b/tests/ServerImplementationTest.php @@ -10,26 +10,26 @@ class ServerImplementationTest extends HttpResponseTestCase public function testVersion(): void { $response = $this->request("GET", "/_matrix/federation/v1/version"); - + $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); $this->assertTrue($this->hasJsonBody($response)); - + $body = json_decode((string)$response->getBody(), true); - + $this->assertArrayHasKey("server", $body); $this->assertArrayHasKey("name", $body["server"]); $this->assertArrayHasKey("version", $body["server"]); } - + public function testVersions(): void { $response = $this->request("GET", "/_matrix/client/versions"); - + $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); $this->assertTrue($this->hasJsonBody($response)); - + $body = json_decode((string)$response->getBody(), true); - + $this->assertIsArray($body["versions"]); $this->assertTrue(count($body["versions"]) > 0); } |