Skip to content

Commit 4faa736

Browse files
committed
ci
1 parent 7689436 commit 4faa736

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

src/Platform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,4 @@ public static function getBinaryPath(): string
214214

215215
return $binaryPath;
216216
}
217-
}
217+
}

src/ProcessManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ protected function closeProcess($process): int
170170

171171
return proc_close($process);
172172
}
173-
}
173+
}

tests/VoltTestTest.php

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,55 @@ protected function tearDown(): void
2121
ErrorHandler::unregister();
2222
parent::tearDown();
2323
}
24+
2425
public function testVoltTest()
2526
{
2627
$voltTest = new VoltTest("test");
2728
$voltTest->setVirtualUsers(10);
29+
30+
// Create first scenario
2831
$scenario1 = $voltTest->scenario("Test Scenario")->setWeight(10);
29-
$scenario1->step("Step 1")->get('https://www.google.com');
32+
$scenario1->step("Step 1")
33+
->get('https://www.google.com')
34+
->validateStatus('success', 200);
35+
36+
// Create second scenario
3037
$scenario2 = $voltTest->scenario("Test Scenario 2")->setWeight(90);
31-
$scenario2->step("Step 1")->get('https://www.google.com');
38+
$scenario2->step("Step 1")
39+
->get('https://www.google.com')
40+
->validateStatus('success', 200);
41+
42+
// Run test and get results
3243
$result = $voltTest->run(true);
33-
var_dump($result->getDuration());
34-
$this->assertNotEquals('0', $result->getDuration(), "Duration should not be 0");
35-
$this->assertNotNull($result->getAvgResponseTime(), "Average response time should not be null");
36-
37-
$this->assertIsFloat($result->getSuccessRate(), "Success rate should be a float");
38-
$this->assertIsInt($result->getTotalRequests(), "Total requests should be an integer");
39-
$this->assertIsInt($result->getSuccessRequests(), "Success requests should be an integer");
40-
$this->assertIsInt($result->getFailedRequests(), "Failed requests should be an integer");
44+
45+
// Basic assertions about test execution
46+
$this->assertNotEmpty($result->getRawOutput(), "Raw output should not be empty");
47+
48+
// Get duration and remove any 's' suffix if present
49+
$duration = str_replace('s', '', $result->getDuration());
50+
$this->assertNotEquals(0, (float)$duration, "Duration should not be 0");
51+
52+
// Verify response time metrics
53+
$avgResponseTime = $result->getAvgResponseTime();
54+
if ($avgResponseTime !== null) {
55+
$this->assertStringContainsString('ms', $avgResponseTime, "Average response time should contain 'ms'");
56+
}
57+
58+
// Test rate metrics
59+
$this->assertGreaterThan(0, $result->getSuccessRate(), "Success rate should be greater than 0");
60+
$this->assertGreaterThanOrEqual(0, $result->getRequestsPerSecond(), "Requests per second should be non-negative");
61+
62+
// Request counts
63+
$this->assertGreaterThan(0, $result->getTotalRequests(), "Total requests should be greater than 0");
64+
$this->assertGreaterThanOrEqual(0, $result->getSuccessRequests(), "Success requests should be non-negative");
65+
$this->assertGreaterThanOrEqual(0, $result->getFailedRequests(), "Failed requests should be non-negative");
66+
67+
// Total requests should equal success + failed requests
68+
$this->assertEquals(
69+
$result->getTotalRequests(),
70+
$result->getSuccessRequests() + $result->getFailedRequests(),
71+
"Total requests should equal sum of success and failed requests"
72+
);
73+
4174
}
4275
}

0 commit comments

Comments
 (0)