Skip to content
Snippets Groups Projects
Commit 9bbb1fae authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3175917 by Xiaohua Guan, yas: Add test cases for the detailed view for a VMware host

parent d04ab80b
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,13 @@ class VmwareHostTest extends VmwareTestBase {
$this->assertSession()->pageTextContains($data[$i]['name']);
}
// Confirm detail page.
for ($i = 0; $i < self::VMWARE_HOST_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/vmware/$cloud_context/host/$num");
$this->assertSession()->pageTextContains($data[$i]['name']);
}
for ($i = 0, $num = 1; $i < self::VMWARE_HOST_REPEAT_COUNT; $i++, $num++) {
// Make sure the all host listing exists.
$this->drupalGet('/clouds/vmware/host');
......@@ -52,6 +59,9 @@ class VmwareHostTest extends VmwareTestBase {
for ($j = 0; $j < $num; $j++) {
$this->assertSession()->pageTextContains($data[$j]['name']);
$this->assertSession()->pageTextContains($data[$j]['host']);
$this->assertSession()->pageTextContains($data[$j]['power_state']);
$this->assertSession()->pageTextContains($data[$j]['connection_state']);
}
}
}
......
......@@ -125,11 +125,17 @@ trait VmwareTestFormDataTrait {
protected function createHostTestFormData($repeat_count): array {
$random = new Random();
$power_states = ['POWERED_ON', 'POWERED_OFF'];
$connection_states = ['CONNECTED', 'DISCONNECTED'];
// Input Fields.
$data = [];
for ($i = 1; $i <= $repeat_count; $i++) {
$data[] = [
'name' => sprintf('Host-%s - %s', $random->name(8, TRUE), date('Y/m/d H:i:s')),
'host' => 'host-' . rand(),
'power_state' => $power_states[array_rand($power_states)],
'connection_state' => $connection_states[array_rand($connection_states)],
];
}
......
......@@ -130,9 +130,9 @@ trait VmwareTestMockTrait {
foreach ($data ?: [] as $host_data) {
$hosts[] = [
'name' => $host_data['name'],
'connection_state' => 'CONNECTED',
'host' => 'obj-100',
'power_state' => 'POWERED_ON',
'connection_state' => $host_data['connection_state'],
'host' => $host_data['host'],
'power_state' => $host_data['power_state'],
];
}
$mock_data['describeHosts'] = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment