|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | use Astrotomic\OpenGraph\StructuredProperties\Audio; |
| 4 | +use Astrotomic\OpenGraph\StructuredProperties\Image; |
4 | 5 | use Astrotomic\OpenGraph\Types\Article; |
5 | 6 | use Astrotomic\OpenGraph\Types\Book; |
6 | 7 | use Astrotomic\OpenGraph\Types\Profile; |
@@ -35,13 +36,41 @@ public function __toString() |
35 | 36 | assertMatchesHtmlSnapshot((string) $og); |
36 | 37 | })->group('global', 'website'); |
37 | 38 |
|
| 39 | +it('can generate website tags with structured image', function () { |
| 40 | + $og = Website::make('Title | Example') |
| 41 | + ->url('http://www.example.com') |
| 42 | + ->description('Description') |
| 43 | + ->locale('en_US') |
| 44 | + ->alternateLocale('en_GB') |
| 45 | + ->siteName('Example') |
| 46 | + ->image(Image::make('http://www.example.com/image1.jpg')->mimeType('image/jpeg')); |
| 47 | + |
| 48 | + assertMatchesHtmlSnapshot((string) $og); |
| 49 | +})->group('global', 'website'); |
| 50 | + |
| 51 | +it('can generate website tags with structured image without url suffix', function () { |
| 52 | + $og = Website::make('Title | Example') |
| 53 | + ->url('http://www.example.com') |
| 54 | + ->description('Description') |
| 55 | + ->locale('en_US') |
| 56 | + ->alternateLocale('en_GB') |
| 57 | + ->siteName('Example') |
| 58 | + ->image(Image::make('http://www.example.com/image1.jpg', false)->mimeType('image/jpeg')); |
| 59 | + |
| 60 | + assertMatchesHtmlSnapshot((string) $og); |
| 61 | +})->group('global', 'website'); |
| 62 | + |
38 | 63 | it('can generate website tags with conditional callbacks', function () { |
39 | 64 | $og = Website::make('Title | Example') |
40 | 65 | ->url('http://www.example.com') |
41 | 66 | ->description('Description') |
42 | 67 | ->locale('en_US') |
43 | | - ->when(false, fn (Website $og) => $og->alternateLocale('de_DE')) |
44 | | - ->when(true, fn (Website $og) => $og->alternateLocale('en_GB')) |
| 68 | + ->when(false, function (Website $og) { |
| 69 | + $og->alternateLocale('de_DE'); |
| 70 | + }) |
| 71 | + ->when(true, function (Website $og) { |
| 72 | + $og->alternateLocale('en_GB'); |
| 73 | + }) |
45 | 74 | ->siteName('Example') |
46 | 75 | ->image('http://www.example.com/image1.jpg'); |
47 | 76 |
|
|
0 commit comments