protected function _case_check($uri, $expect) { $this->given($this->constant->STREAM_PF_INET6 = true, $this->function->stream_get_transports = ['tcp', 'file'])->when($result = new SUT($uri))->then->integer($result->getAddressType())->isEqualTo($expect['type'])->string($result->getTransport())->isEqualTo($expect['transport'])->string($result->getAddress())->isEqualTo($expect['address'])->integer($result->getPort())->isEqualTo($expect['port']); }
/** * Compute an HTTP GET method. * * @param Request $request HTTP request. * @param Response $response HTTP response. * @return bool * @throws Exception\Dav\Exception */ function httpGet(Request $request, Response $response) { if (System\Collection::NAME . '/' . Node::NAME !== $request->getPath()) { return; } $queries = $request->getQueryParameters(); if (isset($queries['test']) && 'mail' === $queries['test'] && isset($queries['payload'])) { $payload = @json_decode($queries['payload']); if (!$payload || !isset($payload->transport) || !isset($payload->username) || !isset($payload->password)) { throw new Exception\Dav\Exception('Payload is corrupted.'); } Mail\Message::setDefaultTransport(new Mail\Transport\Smtp(new Socket\Client('tcp://' . $payload->transport), $payload->username, $payload->password)); $message = new Mail\Message(); $message['from'] = 'sabre/katana <' . $payload->username . '>'; $message['to'] = $payload->username; $message['subject'] = 'Test mail from sabre/katana'; $message->addContent(new Mail\Content\Text('Hey!' . "\n\n" . 'If you receive this email, it means that your ' . 'sabre/katana server is able to send emails! ' . "\n\n" . 'Congratulations :-).')); $message->send(); $response->setHeader('Content-Type', 'application/json'); $response->setBody(json_encode(true)); return false; } $configuration = ['database' => ['dsn' => $this->configuration->database->dsn, 'username' => $this->configuration->database->username], 'mail' => ['address' => '', 'port' => '', 'username' => '', 'password' => '']]; if (isset($this->configuration->mail)) { $socket = new Socket('tcp://' . $this->configuration->mail->transport); $configuration['mail']['address'] = $socket->getAddress(); $configuration['mail']['port'] = $socket->hasPort() ? $socket->getPort() : 587; $configuration['mail']['username'] = $this->configuration->mail->username; $configuration['mail']['password'] = $this->configuration->mail->password; unset($socket); } $response->setHeader('Content-Type', 'application/json'); $response->setBody(json_encode($configuration)); return false; }