| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace Test\Depo\UniTester;
- use Depo\UniTester\TestCase;
- class PerformanceFileTest extends TestCase
- {
- protected function setUp(): void
- {
- // Create a temporary file for testing
- file_put_contents(__DIR__ . '/temp_test_file.txt', 'content');
- }
- protected function tearDown(): void
- {
- // Clean up
- if (file_exists(__DIR__ . '/temp_test_file.txt')) {
- unlink(__DIR__ . '/temp_test_file.txt');
- }
- }
- protected function execute(): void
- {
- $this->log("Testing Performance Assertions...");
-
- // Test Execution Time
- $this->assertExecutionTimeLessThan(100, function() {
- usleep(10000); // 10ms
- }, "Execution time should be less than 100ms");
- // Test Memory Usage
- $this->assertMemoryUsageLessThan(1024 * 1024, function() {
- $a = str_repeat('a', 1024); // 1KB
- }, "Memory usage should be less than 1MB");
- $this->log("Testing File Assertions...");
- $tempFile = __DIR__ . '/temp_test_file.txt';
-
- $this->assertFileExists($tempFile);
- $this->assertFileNotExists(__DIR__ . '/non_existent_file.txt');
- $this->assertDirectoryExists(__DIR__);
- $this->assertIsReadable($tempFile);
- $this->assertIsWritable($tempFile);
-
- $this->log("All new assertions passed!");
- }
- }
|