where('group', 'global')->where('key', 'contact')->firstOrFail(); return (string) ($row->getTranslation('value', $locale)['whatsapp'] ?? ''); } it('creates the contact entry with the business number when it is missing', function () { $this->seed(WhatsappNumberSeeder::class); expect(contactWhatsapp('de'))->toBe('+49 521 986 20 100') ->and(contactWhatsapp('en'))->toBe('+49 521 986 20 100') ->and(whatsapp_link())->toBe('https://wa.me/4952198620100'); }); it('replaces the placeholder number from the first setup', function () { CmsContent::create([ 'group' => 'global', 'key' => 'contact', 'type' => 'json', 'value' => ['de' => ['whatsapp' => '+49 151 00000000'], 'en' => ['whatsapp' => '+49 151 00000000']], 'order' => 0, ]); $this->seed(WhatsappNumberSeeder::class); expect(contactWhatsapp('de'))->toBe('+49 521 986 20 100') ->and(contactWhatsapp('en'))->toBe('+49 521 986 20 100'); }); it('corrects the wrong number that was seeded on 23.09.', function () { CmsContent::create([ 'group' => 'global', 'key' => 'contact', 'type' => 'json', 'value' => ['de' => ['whatsapp' => '+49 521 98610020'], 'en' => ['whatsapp' => '+49 521 98610020']], 'order' => 0, ]); $this->seed(WhatsappNumberSeeder::class); expect(contactWhatsapp('de'))->toBe('+49 521 986 20 100') ->and(contactWhatsapp('en'))->toBe('+49 521 986 20 100'); }); it('keeps a number that was maintained in the admin', function () { CmsContent::create([ 'group' => 'global', 'key' => 'contact', 'type' => 'json', 'value' => ['de' => ['whatsapp' => '+49 170 1234567', 'phone' => '0521 1'], 'en' => []], 'order' => 0, ]); $this->seed(WhatsappNumberSeeder::class); $row = CmsContent::query()->where('group', 'global')->where('key', 'contact')->firstOrFail(); expect(contactWhatsapp('de'))->toBe('+49 170 1234567') ->and($row->getTranslation('value', 'de')['phone'])->toBe('0521 1') ->and(contactWhatsapp('en'))->toBe('+49 521 986 20 100'); }); it('is idempotent', function () { $this->seed(WhatsappNumberSeeder::class); $this->seed(WhatsappNumberSeeder::class); expect(CmsContent::query()->where('group', 'global')->where('key', 'contact')->count())->toBe(1) ->and(contactWhatsapp('de'))->toBe('+49 521 986 20 100'); }); it('shows the business number on the site after seeding', function () { $this->seed(WhatsappNumberSeeder::class); $html = $this->get('/')->assertSuccessful()->getContent(); expect($html)->toContain('4952198620100'); });