Skip to content

Commit

Permalink
refactor: (LAR-10) refactoring some file
Browse files Browse the repository at this point in the history
  • Loading branch information
StevyMarlino committed Oct 10, 2024
1 parent 98a7afd commit 4c3e813
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 34 deletions.
1 change: 0 additions & 1 deletion .phpunit.cache/test-results

This file was deleted.

26 changes: 10 additions & 16 deletions app/Notifications/PendingArticlesNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,17 @@ public function toTelegram(): TelegramMessage

private function content(): string
{
$message = __("Pending approval articles:\n");
$message = __("Pending approval articles:\n\n");
foreach ($this->pendingArticles as $article) {
$url = route('articles.show', $article->slug);

$message .= __("• Title: [:title](:url)\n", [
'title' => $article->title,
'url' => $url,
]);

$message .= __("• By: [@:username](:profile_url)\n", [
'username' => $article->user?->username,
'profile_url' => route('profile', $article->user?->username),
]);

$message .= __("• Submitted on: :date\n\n", [
'date' => $article->submitted_at->translatedFormat('d/m/Y'),
]);
$message .= __(
"[@:username](:profile_url) submitted the article [:title](:url) on: :date\n\n", [
'username' => $article->user?->username,
'profile_url' => route('profile', $article->user?->username),
'title' => $article->title,
'url' => route('articles.show', $article->slug),
'date' => $article->submitted_at->translatedFormat('d/m/Y')
]
);
}

return $message;
Expand Down
6 changes: 2 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
"Please click the button below to verify your email address.": "Please click the button below to verify your email address.",
"If you did not create an account, no further action is required.": "If you did not create an account, no further action is required.",
"Pending approval articles:" : "Pending approval articles:",
"• Title: [:title](:url)" : "• Title: [:title](:url)",
"• By: [@:username](:profile_url)" : "• By: [@:username](:profile_url)",
"• Submitted on: :date" : "• Submitted on: :date"
}
"[@:username](:profile_url) submitted the article [:title](:url) on: :date" : "[@:username](:profile_url) submitted the article [:title](:url) on: :date"
}
6 changes: 2 additions & 4 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
"Please click the button below to verify your email address.": "Veuillez cliquer sur le bouton ci-dessous pour vérifier votre adresse email.",
"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.",
"Pending approval articles:" : "Articles soumis en attente d'approbation:",
"• Title: [:title](:url)" : "• Titre: [:title](:url)",
"• By: [@:username](:profile_url)" : "• Par: [@:username](:profile_url)",
"• Submitted on: :date" : "• Soumis le: :date"
}
"[@:username](:profile_url) submitted the article [:title](:url) on: :date" : "[@:username](:profile_url) a soumit l'article [:title](:url) le: :date"
}
9 changes: 0 additions & 9 deletions tests/Feature/NotifyPendingArticlesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use App\Console\Commands\NotifyPendingArticles;
use App\Models\Article;
use App\Notifications\PendingArticlesNotification;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Facades\Notification;

beforeEach(fn() => Notification::fake());
Expand All @@ -26,15 +24,8 @@
]);

$this->assertDatabaseCount('articles', 3);

$this->artisan(NotifyPendingArticles::class)->assertExitCode(0);

Notification::assertSentTo(
new AnonymousNotifiable(),
PendingArticlesNotification::class,
fn($notification) => $notification->pendingArticles->count() === 1
);

Notification::assertCount(1);
});

Expand Down

0 comments on commit 4c3e813

Please sign in to comment.