mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-12 22:41:38 +00:00
Test some more edge cases in tests
This commit is contained in:
parent
47ab18175f
commit
112e962239
8 changed files with 690 additions and 41 deletions
|
|
@ -87,4 +87,32 @@ final class EventCommentHelperTest extends WebTestCase
|
|||
$this->service->clearMessage();
|
||||
$this->assertFalse($this->service->isMessageSet());
|
||||
}
|
||||
|
||||
public function testEmptyStringTreatedAsNotSet(): void
|
||||
{
|
||||
// Empty string is falsy in PHP, so setMessage('') stores null internally
|
||||
$this->service->setMessage('');
|
||||
$this->assertFalse($this->service->isMessageSet());
|
||||
$this->assertNull($this->service->getMessage());
|
||||
}
|
||||
|
||||
public function testSetMessageNullClearsMessage(): void
|
||||
{
|
||||
$this->service->setMessage('Hello');
|
||||
$this->service->setMessage(null);
|
||||
$this->assertFalse($this->service->isMessageSet());
|
||||
$this->assertNull($this->service->getMessage());
|
||||
}
|
||||
|
||||
public function testLongMessageIsTruncated(): void
|
||||
{
|
||||
// MAX_MESSAGE_LENGTH is 255; a longer string should be truncated with '...' suffix
|
||||
$long = str_repeat('a', 300);
|
||||
$this->service->setMessage($long);
|
||||
|
||||
$stored = $this->service->getMessage();
|
||||
$this->assertNotNull($stored);
|
||||
$this->assertLessThanOrEqual(255, mb_strlen($stored));
|
||||
$this->assertStringEndsWith('...', $stored);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue