Fix tests

(cherry picked from commit 0661f1f889)
(cherry picked from commit bab804b8e1)

# Conflicts:
#	tests/e2e/Client.php
This commit is contained in:
Jake Barnby
2023-05-30 19:01:46 +12:00
parent fad53d3e89
commit edce3cceed
5 changed files with 51 additions and 65 deletions
+11 -23
View File
@@ -12,6 +12,12 @@ class HTTPTest extends Scope
use ProjectNone;
use SideNone;
public function setUp(): void
{
parent::setUp();
$this->client->setEndpoint('http://localhost');
}
public function testOptions()
{
/**
@@ -32,24 +38,6 @@ class HTTPTest extends Scope
$this->assertEmpty($response['body']);
}
public function testError()
{
/**
* Test for SUCCESS
*/
$this->markTestIncomplete('This test needs to be updated for the new console.');
// $response = $this->client->call(Client::METHOD_GET, '/error', \array_merge([
// 'origin' => 'http://localhost',
// 'content-type' => 'application/json',
// ]), []);
// $this->assertEquals(404, $response['headers']['status-code']);
// $this->assertEquals('Not Found', $response['body']['message']);
// $this->assertEquals(Exception::GENERAL_ROUTE_NOT_FOUND, $response['body']['type']);
// $this->assertEquals(404, $response['body']['code']);
// $this->assertEquals('dev', $response['body']['version']);
}
public function testHumans()
{
/**
@@ -57,7 +45,7 @@ class HTTPTest extends Scope
*/
$response = $this->client->call(Client::METHOD_GET, '/humans.txt', \array_merge([
'origin' => 'http://localhost',
]), []);
]));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertStringContainsString('# humanstxt.org/', $response['body']);
@@ -70,7 +58,7 @@ class HTTPTest extends Scope
*/
$response = $this->client->call(Client::METHOD_GET, '/robots.txt', \array_merge([
'origin' => 'http://localhost',
]), []);
]));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertStringContainsString('# robotstxt.org/', $response['body']);
@@ -87,7 +75,7 @@ class HTTPTest extends Scope
*/
$response = $this->client->call(Client::METHOD_GET, '/.well-known/acme-challenge/8DdIKX257k6Dih5s_saeVMpTnjPJdKO5Ase0OCiJrIg', \array_merge([
'origin' => 'http://localhost',
]), []);
]));
$this->assertEquals(404, $response['headers']['status-code']);
// 'Unknown path', but validation passed
@@ -97,9 +85,9 @@ class HTTPTest extends Scope
*/
$response = $this->client->call(Client::METHOD_GET, '/.well-known/acme-challenge/../../../../../../../etc/passwd', \array_merge([
'origin' => 'http://localhost',
]), []);
]));
$this->assertEquals(400, $response['headers']['status-code']);
$this->assertEquals(404, $response['headers']['status-code']);
// Cleanup
$this->client->setEndpoint($previousEndpoint);