Refactor all (except command) modules using new exceptions

This commit is contained in:
crazywhalecc
2025-08-06 20:43:23 +08:00
committed by Jerry Ma
parent 722bb31815
commit f68f060be2
47 changed files with 335 additions and 291 deletions

View File

@@ -6,8 +6,7 @@ namespace SPC\Tests\globals;
use PHPUnit\Framework\TestCase;
use Psr\Log\LogLevel;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\exception\ExecutionException;
use ZM\Logger\ConsoleLogger;
/**
@@ -64,7 +63,7 @@ class GlobalFunctionsTest extends TestCase
$this->markTestSkipped('Windows not support f_passthru');
}
$this->assertEquals(null, f_passthru('echo ""'));
$this->expectException('SPC\exception\RuntimeException');
$this->expectException(ExecutionException::class);
f_passthru('false');
}
@@ -80,16 +79,16 @@ class GlobalFunctionsTest extends TestCase
$this->markTestSkipped('Windows not support shell');
}
$shell = shell();
$this->assertInstanceOf('SPC\util\UnixShell', $shell);
$this->assertInstanceOf('SPC\util\UnixShell', $shell->cd('/'));
$this->assertInstanceOf('SPC\util\UnixShell', $shell->exec('echo ""'));
$this->assertInstanceOf('SPC\util\UnixShell', $shell->setEnv(['SPC_TEST_ENV' => '1']));
$this->assertInstanceOf('SPC\util\shell\UnixShell', $shell);
$this->assertInstanceOf('SPC\util\shell\UnixShell', $shell->cd('/'));
$this->assertInstanceOf('SPC\util\shell\UnixShell', $shell->exec('echo ""'));
$this->assertInstanceOf('SPC\util\shell\UnixShell', $shell->setEnv(['SPC_TEST_ENV' => '1']));
[$code, $out] = $shell->execWithResult('echo "_"');
$this->assertEquals(0, $code);
$this->assertEquals('_', implode('', $out));
$this->expectException('SPC\exception\RuntimeException');
$this->expectException('SPC\exception\ExecutionException');
$shell->exec('false');
}
}