1<?php
2
3declare(strict_types = 1);
4
5error_reporting(E_ALL | E_STRICT);
6
7// Set the default timezone. While this doesn't cause any tests to fail, PHP
8// complains if it is not set in 'date.timezone' of php.ini.
9date_default_timezone_set('UTC');
10
11// Ensure that composer has installed all dependencies
12if (!file_exists(dirname(__DIR__) . '/composer.lock')) {
13    die("Dependencies must be installed using composer:\n\nphp composer.phar install --dev\n\n"
14        . "See http://getcomposer.org for help with installing composer\n");
15}
16
17echo "Base directory: ". dirname(__DIR__)."\n";
18
19// Include the composer autoloader
20$autoloader = require_once(dirname(__DIR__) . '/vendor/autoload.php');
21
22$client = \Elasticsearch\ClientBuilder::fromConfig([
23	'hosts' => [$_SERVER['ES_TEST_HOST']]
24]);
25$serverInfo = $client->info();
26var_dump($serverInfo);
27
28$gitWrapper = new \GitWrapper\GitWrapper();
29echo "Git cwd: ".dirname(__DIR__) . "/util/elasticsearch\n";
30$git = $gitWrapper->workingCopy(dirname(__DIR__) . '/util/elasticsearch');
31
32echo "Update elasticsearch submodule\n";
33$git->fetchAll(array('verbose' => true));
34
35$hash = $serverInfo['version']['build_hash'];
36echo "Checkout yaml tests (hash: $hash)\n";
37$git->checkout($hash, array('force' => true, 'quiet' => true));
38