baseUrl = $baseUrl; $this->adminUser = $admin; $this->regularUser = $regular_user_password; $this->localBaseUrl = $this->baseUrl; $this->remoteBaseUrl = $this->baseUrl; $this->currentServer = 'LOCAL'; $this->cookieJar = new CookieJar(); // in case of ci deployment we take the server url from the environment $testServerUrl = getenv('TEST_SERVER_URL'); if ($testServerUrl !== false) { $this->baseUrl = $testServerUrl; $this->localBaseUrl = $testServerUrl; } // federated server url from the environment $testRemoteServerUrl = getenv('TEST_SERVER_FED_URL'); if ($testRemoteServerUrl !== false) { $this->remoteBaseUrl = $testRemoteServerUrl; } } /** * @Given /^using api version "(\d+)"$/ * @param string $version */ public function usingApiVersion($version) { $this->apiVersion = (int)$version; } /** * @Given /^As an "([^"]*)"$/ * @param string $user */ public function asAn($user) { $this->currentUser = $user; } /** * @Given /^Using server "(LOCAL|REMOTE)"$/ * @param string $server * @return string Previous used server */ public function usingServer($server) { $previousServer = $this->currentServer; if ($server === 'LOCAL') { $this->baseUrl = $this->localBaseUrl; $this->currentServer = 'LOCAL'; return $previousServer; } else { $this->baseUrl = $this->remoteBaseUrl; $this->currentServer = 'REMOTE'; return $previousServer; } } /** * @When /^sending "([^"]*)" to "([^"]*)"$/ * @param string $verb * @param string $url */ public function sendingTo($verb, $url) { $this->sendingToWith($verb, $url, null); } /** * Parses the xml answer to get ocs response which doesn't match with * http one in v1 of the api. * * @param ResponseInterface $response * @return string */ public function getOCSResponse($response) { return simplexml_load_string($response->getBody())->meta[0]->statuscode; } /** * This function is needed to use a vertical fashion in the gherkin tables. * * @param array $arrayOfArrays * @return array */ public function simplifyArray($arrayOfArrays) { $a = array_map(function ($subArray) { return $subArray[0]; }, $arrayOfArrays); return $a; } /** * @When /^sending "([^"]*)" to "([^"]*)" with$/ * @param string $verb * @param string $url * @param TableNode $body */ public function sendingToWith($verb, $url, $body) { $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php" . $url; $client = new Client(); $options = []; if ($this->currentUser === 'admin') { $options['auth'] = $this->adminUser; } elseif (strpos($this->currentUser, 'anonymous') !== 0) { $options['auth'] = [$this->currentUser, $this->regularUser]; } $options['headers'] = [ 'OCS-APIRequest' => 'true' ]; if ($body instanceof TableNode) { $fd = $body->getRowsHash(); $options['form_params'] = $fd; } // TODO: Fix this hack! if ($verb === 'PUT' && $body === null) { $options['form_params'] = [ 'foo' => 'bar', ]; } try { $this->response = $client->request($verb, $fullUrl, $options); } catch (ClientException $ex) { $this->response = $ex->getResponse(); } } /** * @param string $verb * @param string $url * @param TableNode|array|null $body * @param array $headers */ protected function sendRequestForJSON(string $verb, string $url, $body = null, array $headers = []): void { $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php" . $url; $client = new Client(); $options = []; if ($this->currentUser === 'admin') { $options['auth'] = ['admin', 'admin']; } elseif (strpos($this->currentUser, 'guest') !== 0) { $options['auth'] = [$this->currentUser, self::TEST_PASSWORD]; } if ($body instanceof TableNode) { $fd = $body->getRowsHash(); $options['form_params'] = $fd; } elseif (is_array($body)) { $options['form_params'] = $body; } $options['headers'] = array_merge($headers, [ 'OCS-ApiRequest' => 'true', 'Accept' => 'application/json', ]); try { $this->response = $client->{$verb}($fullUrl, $options); } catch (ClientException $ex) { $this->response = $ex->getResponse(); } } /** * @When /^sending "([^"]*)" with exact url to "([^"]*)"$/ * @param string $verb * @param string $url */ public function sendingToDirectUrl($verb, $url) { $this->sendingToWithDirectUrl($verb, $url, null); } public function sendingToWithDirectUrl($verb, $url, $body) { $fullUrl = substr($this->baseUrl, 0, -5) . $url; $client = new Client(); $options = []; if ($this->currentUser === 'admin') { $options['auth'] = $this->adminUser; } elseif (strpos($this->currentUser, 'anonymous') !== 0) { $options['auth'] = [$this->currentUser, $this->regularUser]; } if ($body instanceof TableNode) { $fd = $body->getRowsHash(); $options['form_params'] = $fd; } try { $this->response = $client->request($verb, $fullUrl, $options); } catch (ClientException $ex) { $this->response = $ex->getResponse(); } } public function isExpectedUrl($possibleUrl, $finalPart) { $baseUrlChopped = substr($this->baseUrl, 0, -4); $endCharacter = strlen($baseUrlCh
<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>jQuery UI Spinner Demos</title>
</head>
<body>

<ul>
	<li><a href="default.html">Default functionality</a></li>
	<li><a href="decimal.html">Decimal</a></li>
	<li><a href="currency.html">Currency</a></li>
	<li><a href="latlong.html">Map</a></li>
	<li><a href="time.html">Time</a></li>
	<li><a href="overflow.html">Overflow</a></li>
</ul>

</body>
</html>