Skip to content

NOW MANAGED ON CODEBERG

Reviewed #4533, formatting and tweaks

Dan Browna452092e4011
diff --git a/app/Users/Models/User.php b/app/Users/Models/User.php
index 3efbeec70..2479521a2 100644
--- a/app/Users/Models/User.php
+++ b/app/Users/Models/User.php
@@ -345,7 +345,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
return $splitName[0];
}
- return mb_substr($this->name, 0, $chars-3) . '…';
+ return mb_substr($this->name, 0, max($chars - 2, 0)) . '…';
}
/**
diff --git a/tests/Entity/CommentTest.php b/tests/Entity/CommentTest.php
index d2ed35136..23fc68197 100644
--- a/tests/Entity/CommentTest.php
+++ b/tests/Entity/CommentTest.php
@@ -154,18 +154,14 @@ class CommentTest extends TestCase
}
public function test_comment_creator_name_truncated()
- {
- $longNamedUser = $this->users->admin();
- $longNamedUser->name = 'Wolfeschlegelsteinhausenbergerdorff';
- $longNamedUser->save();
- $this->actingAs($longNamedUser);
-
+ {
+ [$longNamedUser] = $this->users->newUserWithRole(['name' => 'Wolfeschlegelsteinhausenbergerdorff'], ['comment-create-all', 'page-view-all']);
$page = $this->entities->page();
$comment = Comment::factory()->make();
- $this->postJson("/comment/$page->id", $comment->getAttributes());
+ $this->actingAs($longNamedUser)->postJson("/comment/$page->id", $comment->getAttributes());
- $pageResp = $this->get($page->getUrl());
- $pageResp->assertSee('Wolfeschlegel…');
+ $pageResp = $this->asAdmin()->get($page->getUrl());
+ $pageResp->assertSee('Wolfeschlegels…');
}
}