http->get($this->script);
$this->assertEquals(200, $response->getStatusCode(), "Unexpected status code");
$body = (string) $response->getBody();
$this->assertContains("", $body);
}
public function testSetupPhase() {
$options = [
"http_errors" => false,
"form_params" => [ "command" => "setup" ]
];
$response = $this->http->post($this->script, $options);
$this->assertEquals(200, $response->getStatusCode(), "Unexpected status code");
$body = (string) $response->getBody();
$this->assertContains("", $body);
}
public function testAdduserPhase() {
$options = [
"http_errors" => false,
"form_params" => [
"command" => "adduser",
"login" => $this->testUser,
"pass" => $this->testPass,
"pass2" => $this->testPass
]
];
$response = $this->http->post($this->script, $options);
$this->assertEquals(200, $response->getStatusCode(), "Unexpected status code");
$body = (string) $response->getBody();
$this->assertContains("", $body);
$this->assertEquals(2, $this->getConnection()->getRowCount("users"), "Wrong row count");
$expected = [ "id" => 2, "login" => $this->testUser ];
$actual = $this->getConnection()->createQueryTable("users", "SELECT id, login FROM users WHERE id = 2");
$this->assertTableContains($expected, $actual, "Wrong actual table data");
$this->assertTrue(password_verify($this->testPass, $this->pdoGetColumn("SELECT password FROM users WHERE id = 2")), "Wrong actual password hash");
}
}
?>