Skip to content

Commit 4c3e813

Browse files
committed
refactor: (LAR-10) refactoring some file
1 parent 98a7afd commit 4c3e813

File tree

5 files changed

+14
-34
lines changed

5 files changed

+14
-34
lines changed

.phpunit.cache/test-results

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/Notifications/PendingArticlesNotification.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,17 @@ public function toTelegram(): TelegramMessage
3434

3535
private function content(): string
3636
{
37-
$message = __("Pending approval articles:\n");
37+
$message = __("Pending approval articles:\n\n");
3838
foreach ($this->pendingArticles as $article) {
39-
$url = route('articles.show', $article->slug);
40-
41-
$message .= __("• Title: [:title](:url)\n", [
42-
'title' => $article->title,
43-
'url' => $url,
44-
]);
45-
46-
$message .= __("• By: [@:username](:profile_url)\n", [
47-
'username' => $article->user?->username,
48-
'profile_url' => route('profile', $article->user?->username),
49-
]);
50-
51-
$message .= __("• Submitted on: :date\n\n", [
52-
'date' => $article->submitted_at->translatedFormat('d/m/Y'),
53-
]);
39+
$message .= __(
40+
"[@:username](:profile_url) submitted the article [:title](:url) on: :date\n\n", [
41+
'username' => $article->user?->username,
42+
'profile_url' => route('profile', $article->user?->username),
43+
'title' => $article->title,
44+
'url' => route('articles.show', $article->slug),
45+
'date' => $article->submitted_at->translatedFormat('d/m/Y')
46+
]
47+
);
5448
}
5549

5650
return $message;

lang/en.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
"Please click the button below to verify your email address.": "Please click the button below to verify your email address.",
66
"If you did not create an account, no further action is required.": "If you did not create an account, no further action is required.",
77
"Pending approval articles:" : "Pending approval articles:",
8-
"• Title: [:title](:url)" : "• Title: [:title](:url)",
9-
"• By: [@:username](:profile_url)" : "• By: [@:username](:profile_url)",
10-
"• Submitted on: :date" : "• Submitted on: :date"
11-
}
8+
"[@:username](:profile_url) submitted the article [:title](:url) on: :date" : "[@:username](:profile_url) submitted the article [:title](:url) on: :date"
9+
}

lang/fr.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
"Please click the button below to verify your email address.": "Veuillez cliquer sur le bouton ci-dessous pour vérifier votre adresse email.",
66
"If you did not create an account, no further action is required.": "Si vous n'avez pas créé de compte, aucune autre action n'est requise.",
77
"Pending approval articles:" : "Articles soumis en attente d'approbation:",
8-
"• Title: [:title](:url)" : "• Titre: [:title](:url)",
9-
"• By: [@:username](:profile_url)" : "• Par: [@:username](:profile_url)",
10-
"• Submitted on: :date" : "• Soumis le: :date"
11-
}
8+
"[@:username](:profile_url) submitted the article [:title](:url) on: :date" : "[@:username](:profile_url) a soumit l'article [:title](:url) le: :date"
9+
}

tests/Feature/NotifyPendingArticlesTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use App\Console\Commands\NotifyPendingArticles;
66
use App\Models\Article;
7-
use App\Notifications\PendingArticlesNotification;
8-
use Illuminate\Notifications\AnonymousNotifiable;
97
use Illuminate\Support\Facades\Notification;
108

119
beforeEach(fn() => Notification::fake());
@@ -26,15 +24,8 @@
2624
]);
2725

2826
$this->assertDatabaseCount('articles', 3);
29-
3027
$this->artisan(NotifyPendingArticles::class)->assertExitCode(0);
3128

32-
Notification::assertSentTo(
33-
new AnonymousNotifiable(),
34-
PendingArticlesNotification::class,
35-
fn($notification) => $notification->pendingArticles->count() === 1
36-
);
37-
3829
Notification::assertCount(1);
3930
});
4031

0 commit comments

Comments
 (0)