/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Foundation/Console/ServeCommandLogParserTest.php
72 строки
2 KB
Lucas Michot
[13.x] Simplify most of the exceptions expectations (#61049)
05 авг 2026, 18:34
Не верифицирован
05 авг 2026, 18:34
910cd94
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Foundation\Console; use Illuminate\Foundation\Console\ServeCommand; use InvalidArgumentException; use PHPUnit\Framework\TestCase; class ServeCommandLogParserTest extends TestCase { public function testExtractRequestPortWithValidLogLine() { $line = '[Mon Nov 19 10:30:45 2024] :8080 Info'; $this->assertEquals(8080, ServeCommand::getRequestPortFromLine($line)); } public function testExtractRequestPortWithValidLogLineAndExtraData() { $line = '[Mon Nov 19 10:30:45 2024] :3000 [Client Connected]'; $this->assertEquals(3000, ServeCommand::getRequestPortFromLine($line)); } public function testExtractRequestPortWithValidLogLineWithoutDate() { $line = ':5000 [Server Started]'; $this->assertEquals(5000, ServeCommand::getRequestPortFromLine($line)); } public function testExtractRequestPortWithMissingPort() { $line = '[Mon Nov 19 10:30:45 2024] Info'; $this->expectExceptionObject(new InvalidArgumentException('Failed to extract the request port. Ensure the log line contains a valid port: [Mon Nov 19 10:30:45 2024] Info')); ServeCommand::getRequestPortFromLine($line); } public function testExtractRequestPortWithInvalidPortFormat() { $line = '[Mon Nov 19 10:30:45 2024] :abcd Info'; $this->expectExceptionObject(new InvalidArgumentException('Failed to extract the request port. Ensure the log line contains a valid port: [Mon Nov 19 10:30:45 2024] :abcd Info')); ServeCommand::getRequestPortFromLine($line); } public function testExtractRequestPortWithEmptyLogLine() { $this->expectExceptionObject(new InvalidArgumentException('Failed to extract the request port. Ensure the log line contains a valid port: ')); ServeCommand::getRequestPortFromLine(''); } public function testExtractRequestPortWithWhitespaceOnlyLine() { $this->expectExceptionObject(new InvalidArgumentException('Failed to extract the request port. Ensure the log line contains a valid port: ')); ServeCommand::getRequestPortFromLine(' '); } public function testExtractRequestPortWithRandomString() { $line = 'Random log entry without port'; $this->expectExceptionObject(new InvalidArgumentException('Failed to extract the request port. Ensure the log line contains a valid port: Random log entry without port')); ServeCommand::getRequestPortFromLine($line); } }