From 98370baf7bbbe1c23f89fa7a9d1407240396dde5 Mon Sep 17 00:00:00 2001 From: 3m1n3nc3 Date: Tue, 6 Feb 2024 06:37:45 +0100 Subject: [PATCH] Alter the factories --- src/KudiSmsChannel.php | 1 - tests/Feature/SendSmsTest.php | 2 +- tests/Models/User.php | 12 ++++++------ tests/database/factories/UserFactory.php | 3 ++- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/KudiSmsChannel.php b/src/KudiSmsChannel.php index bd09730..05c658c 100644 --- a/src/KudiSmsChannel.php +++ b/src/KudiSmsChannel.php @@ -57,7 +57,6 @@ public function send($notifiable, Notification $notification) try { $to = $this->getTo($notifiable, $notification); $message = $notification->toKudiSms($notifiable); - if (is_string($message)) { $message = new KudiSmsMessage($message); } diff --git a/tests/Feature/SendSmsTest.php b/tests/Feature/SendSmsTest.php index 9ded27f..d5ce6b5 100644 --- a/tests/Feature/SendSmsTest.php +++ b/tests/Feature/SendSmsTest.php @@ -13,7 +13,7 @@ expect(fn () => $user->notify(new SendSms("Hello {$user->name}! This is test SMS."))) ->not() ->toThrow(\Exception::class); -})->skip('Skipped for cost saving.'); +});//->skip('Skipped for cost saving.'); test('user can recieve voice call.', function () { $user = User::factory()->create(); diff --git a/tests/Models/User.php b/tests/Models/User.php index c9d331a..f1cbf18 100644 --- a/tests/Models/User.php +++ b/tests/Models/User.php @@ -33,13 +33,13 @@ class User extends Authenticatable 'remember_token', ]; - // public function routeNotificationForKudiSms(): Attribute + public function routeNotificationForKudiSms() + { + return $this->phone; + } + + // public function phoneNumber(): Attribute // { // return Attribute::make(fn () => $this->phone); // } - - public function phoneNumber(): Attribute - { - return Attribute::make(fn () => $this->phone); - } } diff --git a/tests/database/factories/UserFactory.php b/tests/database/factories/UserFactory.php index 4d71ff2..dc43012 100644 --- a/tests/database/factories/UserFactory.php +++ b/tests/database/factories/UserFactory.php @@ -13,11 +13,12 @@ class UserFactory extends Factory public function definition(): array { $phones = explode(',', config('kudi-notification.test_numbers')); + $seed = rand(0, count($phones) - 1); return [ 'name' => $this->faker->name(), 'email' => $this->faker->unique()->safeEmail(), - 'phone' => $phones[rand(0, count($phones) - 1)] ?? $this->faker->phoneNumber, + 'phone' => $phones[$seed] ?? $this->faker->phoneNumber, 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'remember_token' => Str::random(10),