Skip to content

Commit 1b9a669

Browse files
committed
Speed up unit tests execution.
1 parent a9684ac commit 1b9a669

20 files changed

+237
-205
lines changed

tests/ApiClientTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class ApiClientTest extends TestCase
1010
*/
1111
public function testWrongProtocol()
1212
{
13-
$packet = $this->_client->getPacket('100.0.0');
13+
$packet = static::$_client->getPacket('100.0.0');
1414
$packet->addChild('server')->addChild('get_protos');
15-
$this->_client->request($packet);
15+
static::$_client->request($packet);
1616
}
1717

1818
/**
@@ -21,9 +21,9 @@ public function testWrongProtocol()
2121
*/
2222
public function testUnknownOperator()
2323
{
24-
$packet = $this->_client->getPacket();
24+
$packet = static::$_client->getPacket();
2525
$packet->addChild('unknown');
26-
$this->_client->request($packet);
26+
static::$_client->request($packet);
2727
}
2828

2929
/**
@@ -32,7 +32,7 @@ public function testUnknownOperator()
3232
*/
3333
public function testInvalidXmlRequest()
3434
{
35-
$this->_client->request('<packet><wrongly formatted xml</packet>');
35+
static::$_client->request('<packet><wrongly formatted xml</packet>');
3636
}
3737

3838
/**
@@ -41,12 +41,12 @@ public function testInvalidXmlRequest()
4141
*/
4242
public function testInvalidCredentials()
4343
{
44-
$host = $this->_client->getHost();
45-
$port = $this->_client->getPort();
46-
$protocol = $this->_client->getProtocol();
44+
$host = static::$_client->getHost();
45+
$port = static::$_client->getPort();
46+
$protocol = static::$_client->getProtocol();
4747
$client = new PleskX\Api\Client($host, $port, $protocol);
4848
$client->setCredentials('bad-login', 'bad-password');
49-
$packet = $this->_client->getPacket();
49+
$packet = static::$_client->getPacket();
5050
$packet->addChild('server')->addChild('get_protos');
5151
$client->request($packet);
5252
}
@@ -57,46 +57,46 @@ public function testInvalidCredentials()
5757
*/
5858
public function testInvalidSecretKey()
5959
{
60-
$host = $this->_client->getHost();
61-
$port = $this->_client->getPort();
62-
$protocol = $this->_client->getProtocol();
60+
$host = static::$_client->getHost();
61+
$port = static::$_client->getPort();
62+
$protocol = static::$_client->getProtocol();
6363
$client = new PleskX\Api\Client($host, $port, $protocol);
6464
$client->setSecretKey('bad-key');
65-
$packet = $this->_client->getPacket();
65+
$packet = static::$_client->getPacket();
6666
$packet->addChild('server')->addChild('get_protos');
6767
$client->request($packet);
6868
}
6969

7070
public function testLatestMajorProtocol()
7171
{
72-
$packet = $this->_client->getPacket('1.6');
72+
$packet = static::$_client->getPacket('1.6');
7373
$packet->addChild('server')->addChild('get_protos');
74-
$this->_client->request($packet);
74+
static::$_client->request($packet);
7575
}
7676

7777
public function testLatestMinorProtocol()
7878
{
79-
$packet = $this->_client->getPacket('1.6.5');
79+
$packet = static::$_client->getPacket('1.6.5');
8080
$packet->addChild('server')->addChild('get_protos');
81-
$this->_client->request($packet);
81+
static::$_client->request($packet);
8282
}
8383

8484
public function testRequestShortSyntax()
8585
{
86-
$response = $this->_client->request('server.get.gen_info');
86+
$response = static::$_client->request('server.get.gen_info');
8787
$this->assertGreaterThan(0, strlen($response->gen_info->server_name));
8888
}
8989

9090
public function testOperatorPlainRequest()
9191
{
92-
$response = $this->_client->server()->request('get.gen_info');
92+
$response = static::$_client->server()->request('get.gen_info');
9393
$this->assertGreaterThan(0, strlen($response->gen_info->server_name));
9494
$this->assertEquals(36, strlen($response->getValue('server_guid')));
9595
}
9696

9797
public function testRequestArraySyntax()
9898
{
99-
$response = $this->_client->request([
99+
$response = static::$_client->request([
100100
'server' => [
101101
'get' => [
102102
'gen_info' => '',
@@ -108,13 +108,13 @@ public function testRequestArraySyntax()
108108

109109
public function testOperatorArraySyntax()
110110
{
111-
$response = $this->_client->server()->request(['get' => ['gen_info' => '']]);
111+
$response = static::$_client->server()->request(['get' => ['gen_info' => '']]);
112112
$this->assertGreaterThan(0, strlen($response->gen_info->server_name));
113113
}
114114

115115
public function testMultiRequest()
116116
{
117-
$responses = $this->_client->multiRequest([
117+
$responses = static::$_client->multiRequest([
118118
'server.get_protos',
119119
'server.get.gen_info',
120120
]);

tests/CertificateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class CertificateTest extends TestCase
66

77
public function testGenerate()
88
{
9-
$certificate = $this->_client->certificate()->generate([
9+
$certificate = static::$_client->certificate()->generate([
1010
'bits' => 2048,
1111
'country' => 'RU',
1212
'state' => 'NSO',

tests/CustomerTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,54 @@ class CustomerTest extends TestCase
1616

1717
public function testCreate()
1818
{
19-
$customer = $this->_client->customer()->create($this->_customerProperties);
19+
$customer = static::$_client->customer()->create($this->_customerProperties);
2020
$this->assertInternalType('integer', $customer->id);
2121
$this->assertGreaterThan(0, $customer->id);
2222

23-
$this->_client->customer()->delete('id', $customer->id);
23+
static::$_client->customer()->delete('id', $customer->id);
2424
}
2525

2626
public function testDelete()
2727
{
28-
$customer = $this->_client->customer()->create($this->_customerProperties);
29-
$result = $this->_client->customer()->delete('id', $customer->id);
28+
$customer = static::$_client->customer()->create($this->_customerProperties);
29+
$result = static::$_client->customer()->delete('id', $customer->id);
3030
$this->assertTrue($result);
3131
}
3232

3333
public function testGet()
3434
{
35-
$customer = $this->_client->customer()->create($this->_customerProperties);
36-
$customerInfo = $this->_client->customer()->get('id', $customer->id);
35+
$customer = static::$_client->customer()->create($this->_customerProperties);
36+
$customerInfo = static::$_client->customer()->get('id', $customer->id);
3737
$this->assertEquals('Plesk', $customerInfo->company);
3838
$this->assertEquals('John Smith', $customerInfo->personalName);
3939
$this->assertEquals('john-unit-test', $customerInfo->login);
4040
$this->assertEquals('[email protected]', $customerInfo->email);
4141
$this->assertEquals('Good guy', $customerInfo->description);
4242
$this->assertEquals('link:12345', $customerInfo->externalId);
4343

44-
$this->_client->customer()->delete('id', $customer->id);
44+
static::$_client->customer()->delete('id', $customer->id);
4545
}
4646

4747
public function testGetAll()
4848
{
49-
$this->_client->customer()->create([
49+
static::$_client->customer()->create([
5050
'pname' => 'John Smith',
5151
'login' => 'customer-a',
5252
'passwd' => 'simple-password',
5353
]);
54-
$this->_client->customer()->create([
54+
static::$_client->customer()->create([
5555
'pname' => 'Mike Black',
5656
'login' => 'customer-b',
5757
'passwd' => 'simple-password',
5858
]);
5959

60-
$customersInfo = $this->_client->customer()->getAll();
60+
$customersInfo = static::$_client->customer()->getAll();
6161
$this->assertCount(2, $customersInfo);
6262
$this->assertEquals('John Smith', $customersInfo[0]->personalName);
6363
$this->assertEquals('customer-a', $customersInfo[0]->login);
6464

65-
$this->_client->customer()->delete('login', 'customer-a');
66-
$this->_client->customer()->delete('login', 'customer-b');
65+
static::$_client->customer()->delete('login', 'customer-a');
66+
static::$_client->customer()->delete('login', 'customer-b');
6767
}
6868

6969
}

tests/DatabaseServerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ class DatabaseServerTest extends TestCase
66

77
public function testGetSupportedTypes()
88
{
9-
$types = $this->_client->databaseServer()->getSupportedTypes();
9+
$types = static::$_client->databaseServer()->getSupportedTypes();
1010
$this->assertGreaterThan(0, count($types));
1111
$this->assertContains('mysql', $types);
1212
}
1313

1414
public function testGet()
1515
{
16-
$dbServer = $this->_client->databaseServer()->get('id', 1);
16+
$dbServer = static::$_client->databaseServer()->get('id', 1);
1717
$this->assertEquals('localhost', $dbServer->host);
1818
$this->assertGreaterThan(0, $dbServer->port);
1919
}
2020

2121
public function testGetAll()
2222
{
23-
$dbServers = $this->_client->databaseServer()->getAll();
23+
$dbServers = static::$_client->databaseServer()->getAll();
2424
$this->assertInternalType('array', $dbServers);
2525
$this->assertGreaterThan(0, count($dbServers));
2626
$this->assertEquals('localhost', $dbServers[0]->host);

0 commit comments

Comments
 (0)