HTML; $meta = (new OpenGraphExtractor)->extract($html, 'https://example.com/post'); expect($meta['title'])->toBe('Hello OG') ->and($meta['description'])->toBe('A description') ->and($meta['image'])->toBe('https://example.com/img/card.png'); }); test('falls back to title tag and meta description', function () { $html = 'Plain Title' .''; $meta = (new OpenGraphExtractor)->extract($html, 'https://example.com'); expect($meta['title'])->toBe('Plain Title') ->and($meta['description'])->toBe('Meta desc') ->and($meta['image'])->toBeNull(); }); test('returns nulls when nothing is present', function () { $meta = (new OpenGraphExtractor)->extract('no meta', 'https://example.com'); expect($meta)->toBe(['title' => null, 'description' => null, 'image' => null]); });