Skip to content

Commit 1873c2a

Browse files
authored
Merge pull request #49 from mrsombre/fix-tests-on-win
Fix tests for running on Windows host
2 parents 91fad73 + ce302db commit 1873c2a

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

tests/ServerTest.php

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ class ServerTest extends TestCase
77
public function testGetProtos()
88
{
99
$protos = static::$_client->server()->getProtos();
10-
$this->assertInternalType('array', $protos);
10+
$this->assertIsArray($protos);
1111
$this->assertContains('1.6.3.0', $protos);
1212
}
1313

1414
public function testGetGenInfo()
1515
{
1616
$generalInfo = static::$_client->server()->getGeneralInfo();
1717
$this->assertGreaterThan(0, strlen($generalInfo->serverName));
18-
$this->assertRegExp('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $generalInfo->serverGuid);
18+
$this->assertRegExp('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', strtolower($generalInfo->serverGuid));
1919
$this->assertEquals('standard', $generalInfo->mode);
2020
}
2121

2222
public function testGetPreferences()
2323
{
2424
$preferences = static::$_client->server()->getPreferences();
25-
$this->assertInternalType('integer', $preferences->statTtl);
25+
$this->assertIsNumeric($preferences->statTtl);
2626
$this->assertGreaterThan(0, $preferences->statTtl);
2727
$this->assertEquals(0, $preferences->restartApacheInterval);
2828
}
@@ -37,7 +37,7 @@ public function testGetAdmin()
3737
public function testGetKeyInfo()
3838
{
3939
$keyInfo = static::$_client->server()->getKeyInfo();
40-
$this->assertInternalType('array', $keyInfo);
40+
$this->assertIsArray($keyInfo);
4141
$this->assertGreaterThan(0, count($keyInfo));
4242
$this->assertArrayHasKey('plesk_key_id', $keyInfo);
4343
$this->assertArrayHasKey('lim_date', $keyInfo);
@@ -46,70 +46,65 @@ public function testGetKeyInfo()
4646
public function testGetComponents()
4747
{
4848
$components = static::$_client->server()->getComponents();
49-
$this->assertInternalType('array', $components);
49+
$this->assertIsArray($components);
5050
$this->assertGreaterThan(0, count($components));
5151
$this->assertArrayHasKey('psa', $components);
52-
$this->assertArrayHasKey('php', $components);
5352
}
5453

5554
public function testGetServiceStates()
5655
{
5756
$serviceStates = static::$_client->server()->getServiceStates();
58-
$this->assertInternalType('array', $serviceStates);
57+
58+
$this->assertIsArray($serviceStates);
5959
$this->assertGreaterThan(0, count($serviceStates));
60-
$this->assertArrayHasKey('web', $serviceStates);
61-
62-
$webService = $serviceStates['web'];
63-
$this->assertInternalType('array', $webService);
64-
$this->assertArrayHasKey('id', $webService);
65-
$this->assertArrayHasKey('title', $webService);
66-
$this->assertArrayHasKey('state', $webService);
67-
$this->assertEquals('running', $webService['state']);
60+
61+
$service = current($serviceStates);
62+
$this->assertIsArray($service);
63+
$this->assertArrayHasKey('id', $service);
64+
$this->assertArrayHasKey('title', $service);
65+
$this->assertArrayHasKey('state', $service);
6866
}
6967

7068
public function testGetSessionPreferences()
7169
{
7270
$preferences = static::$_client->server()->getSessionPreferences();
73-
$this->assertInternalType('integer', $preferences->loginTimeout);
71+
$this->assertIsNumeric($preferences->loginTimeout);
7472
$this->assertGreaterThan(0, $preferences->loginTimeout);
7573
}
7674

7775
public function testGetShells()
7876
{
7977
$shells = static::$_client->server()->getShells();
80-
$this->assertInternalType('array', $shells);
81-
$this->assertGreaterThan(0, count($shells));
82-
$this->assertArrayHasKey('/bin/bash', $shells);
8378

84-
$bash = $shells['/bin/bash'];
85-
$this->assertEquals('/bin/bash', $bash);
79+
$this->assertIsArray($shells);
80+
$this->assertGreaterThan(0, count($shells));
8681
}
8782

8883
public function testGetNetworkInterfaces()
8984
{
9085
$netInterfaces = static::$_client->server()->getNetworkInterfaces();
91-
$this->assertInternalType('array', $netInterfaces);
86+
$this->assertIsArray($netInterfaces);
9287
$this->assertGreaterThan(0, count($netInterfaces));
9388
}
9489

9590
public function testGetStatistics()
9691
{
9792
$stats = static::$_client->server()->getStatistics();
98-
$this->assertInternalType('integer', $stats->objects->clients);
93+
$this->assertIsNumeric($stats->objects->clients);
9994
$this->assertEquals('psa', $stats->version->internalName);
10095
}
10196

10297
public function testGetSiteIsolationConfig()
10398
{
10499
$config = static::$_client->server()->getSiteIsolationConfig();
105-
$this->assertInternalType('array', $config);
100+
$this->assertIsArray($config);
106101
$this->assertGreaterThan(0, count($config));
107102
$this->assertArrayHasKey('php', $config);
108103
}
109104

110105
public function testGetUpdatesInfo()
111106
{
112107
$updatesInfo = static::$_client->server()->getUpdatesInfo();
113-
$this->assertInternalType('boolean', $updatesInfo->installUpdatesAutomatically);
108+
$this->assertIsBool($updatesInfo->installUpdatesAutomatically);
114109
}
115110
}

tests/SiteTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testCreate()
3434
{
3535
$site = $this->_createSite('addon.dom');
3636

37-
$this->assertInternalType('integer', $site->id);
37+
$this->assertIsNumeric($site->id);
3838
$this->assertGreaterThan(0, $site->id);
3939

4040
static::$_client->site()->delete('id', $site->id);
@@ -79,7 +79,7 @@ public function testGetHostingWithHosting()
7979

8080
$siteHosting = static::$_client->site()->getHosting('id', $site->id);
8181
$this->assertArrayHasKey('www_root', $siteHosting->properties);
82-
$this->assertEquals('addon.dom', basename($siteHosting->properties['www_root']));
82+
$this->assertStringEndsWith('addon.dom', $siteHosting->properties['www_root']);
8383

8484
static::$_client->site()->delete('id', $site->id);
8585
}

0 commit comments

Comments
 (0)