forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractProxyTestCase.php
76 lines (63 loc) · 1.67 KB
/
AbstractProxyTestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Solarium\Tests\Integration\Proxy;
use PHPUnit\Framework\TestCase;
use Solarium\Core\Client\ClientInterface;
use Solarium\Core\Client\Request;
/**
* Abstract test for connecting through a proxy.
*
* @group integration
* @group proxy
*/
abstract class AbstractProxyTestCase extends TestCase
{
/**
* @var ClientInterface
*/
protected static $client;
/**
* @var array
*/
protected static $config;
/**
* @var string
*/
protected static $proxy_server;
/**
* @var int
*/
protected static $proxy_port;
abstract protected static function createClient(): void;
abstract protected static function setProxy(): void;
public static function setUpBeforeClass(): void
{
self::$config = [
'endpoint' => [
'localhost' => [
'host' => 'solr',
'port' => 8983,
'path' => '/',
'username' => 'solr',
'password' => 'SolrRocks',
],
],
];
self::$proxy_server = '127.0.0.1';
self::$proxy_port = 8080;
static::createClient();
static::setProxy();
self::assertNotNull(
self::$client->getAdapter()->getProxy(),
'Proxy test must set a proxy on the Client adapter!'
);
}
public function testConnection()
{
$query = self::$client->createApi([
'version' => Request::API_V1,
'handler' => 'admin/info/system',
]);
$result = self::$client->execute($query);
$this->assertTrue($result->getWasSuccessful());
}
}