Skip to content

Commit 62aa8c8

Browse files
committed
update test-suite
1 parent e4384cc commit 62aa8c8

20 files changed

+481
-119
lines changed

composer.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"php": "^7.4"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^9.0",
27+
"pestphp/pest": "^0.1.5",
28+
"spatie/pest-plugin-snapshots": "^0.1.0",
2829
"spatie/phpunit-snapshot-assertions": "^4.2"
2930
},
3031
"config": {
@@ -35,12 +36,9 @@
3536
"Astrotomic\\OpenGraph\\": "src"
3637
}
3738
},
38-
"autoload-dev": {
39-
"psr-4": {
40-
"Astrotomic\\OpenGraph\\Test\\": "tests"
41-
}
42-
},
4339
"scripts": {
44-
"test": "vendor/bin/phpunit"
45-
}
40+
"test": "vendor/bin/pest"
41+
},
42+
"minimum-stability": "dev",
43+
"prefer-stable": true
4644
}

tests/GenerateOpenGraphTest.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

tests/GlobalTypesTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
use Astrotomic\OpenGraph\Type;
4+
use Astrotomic\OpenGraph\Types\Article;
5+
use Astrotomic\OpenGraph\Types\Book;
6+
use Astrotomic\OpenGraph\Types\Profile;
7+
use Astrotomic\OpenGraph\Types\Website;
8+
9+
it('can generate website tags', function () {
10+
$og = Website::make('Title | Example')
11+
->url('http://www.example.com')
12+
->description('Description')
13+
->locale('en_US')
14+
->alternateLocale('en_GB')
15+
->siteName('Example')
16+
->image('http://www.example.com/image1.jpg')
17+
;
18+
19+
assertMatchesHtmlSnapshot((string)$og);
20+
});
21+
22+
it('can generate article tags', function () {
23+
$og = Article::make('Article | Example')
24+
->url('http://www.example.com/article')
25+
->description('Description')
26+
->locale('en_US')
27+
->alternateLocale('en_GB')
28+
->siteName('Example')
29+
->image('http://www.example.com/image1.jpg')
30+
31+
->publishedAt(new DateTime('2020-06-05 20:00:00'))
32+
->modifiedAt(new DateTime('2020-06-07 20:00:00'))
33+
->author('http://www.example.com/author')
34+
->section('Technology')
35+
->tag('PHP')
36+
;
37+
38+
assertMatchesHtmlSnapshot((string)$og);
39+
});
40+
41+
it('can generate book tags', function () {
42+
$og = Book::make('Book | Example')
43+
->url('http://www.example.com/book')
44+
->description('Description')
45+
->locale('en_US')
46+
->alternateLocale('en_GB')
47+
->siteName('Example')
48+
->image('http://www.example.com/image1.jpg')
49+
50+
->releasedAt(new DateTime('2020-06-05'))
51+
->isbn('978-3-86680-192-9')
52+
->author('http://www.example.com/author')
53+
->tag('PHP')
54+
;
55+
56+
assertMatchesHtmlSnapshot((string)$og);
57+
});
58+
59+
it('can generate profile tags', function () {
60+
$og = Profile::make('Profile | Example')
61+
->url('http://www.example.com/profile')
62+
->description('Description')
63+
->locale('en_US')
64+
->alternateLocale('en_GB')
65+
->siteName('Example')
66+
->image('http://www.example.com/image1.jpg')
67+
68+
->firstName('Jane')
69+
->lastName('Doe')
70+
->username('janedoe')
71+
->gender('female')
72+
;
73+
74+
assertMatchesHtmlSnapshot((string)$og);
75+
});

tests/MusicTypesTest.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
use Astrotomic\OpenGraph\StructuredProperties\Image;
4+
use Astrotomic\OpenGraph\Type;
5+
use Astrotomic\OpenGraph\Types\Article;
6+
use Astrotomic\OpenGraph\Types\Book;
7+
use Astrotomic\OpenGraph\Types\Music\Album;
8+
use Astrotomic\OpenGraph\Types\Music\Playlist;
9+
use Astrotomic\OpenGraph\Types\Music\RadioStation;
10+
use Astrotomic\OpenGraph\Types\Music\Song;
11+
use Astrotomic\OpenGraph\Types\Profile;
12+
use Astrotomic\OpenGraph\Types\Video\Episode;
13+
use Astrotomic\OpenGraph\Types\Video\Movie;
14+
use Astrotomic\OpenGraph\Types\Video\Other;
15+
use Astrotomic\OpenGraph\Types\Video\TvShow;
16+
use Astrotomic\OpenGraph\Types\Website;
17+
18+
it('can generate song tags', function () {
19+
$og = Song::make('Title | Example')
20+
->url('http://www.example.com/song')
21+
->description('Description')
22+
->locale('en_US')
23+
->alternateLocale('en_GB')
24+
->siteName('Example')
25+
->image('http://www.example.com/image1.jpg')
26+
->audio('http://www.example.com/song.mp3')
27+
28+
->duration(60 * 1.5)
29+
->musician('http://www.example.com/musician')
30+
->album('http://www.example.com/album', 1, 4)
31+
;
32+
33+
assertMatchesHtmlSnapshot((string)$og);
34+
});
35+
36+
it('can generate album tags', function () {
37+
$og = Album::make('Title | Example')
38+
->url('http://www.example.com/album')
39+
->description('Description')
40+
->locale('en_US')
41+
->alternateLocale('en_GB')
42+
->siteName('Example')
43+
->image('http://www.example.com/image1.jpg')
44+
45+
->musician('http://www.example.com/musician')
46+
->song('http://www.example.com/song1', 1, 1)
47+
->song('http://www.example.com/song2', 1, 2)
48+
->song('http://www.example.com/song3', 1, 3)
49+
->song('http://www.example.com/song4', 1, 4)
50+
->releasedAt(new DateTime('2020-06-05'))
51+
;
52+
53+
assertMatchesHtmlSnapshot((string)$og);
54+
});
55+
56+
it('can generate playlist tags', function () {
57+
$og = Playlist::make('Title | Example')
58+
->url('http://www.example.com/playlist')
59+
->description('Description')
60+
->locale('en_US')
61+
->alternateLocale('en_GB')
62+
->siteName('Example')
63+
->image('http://www.example.com/image1.jpg')
64+
65+
->creator('http://www.example.com/creator')
66+
->song('http://www.example.com/song1', 1, 1)
67+
->song('http://www.example.com/song2', 1, 2)
68+
->song('http://www.example.com/song3', 1, 3)
69+
->song('http://www.example.com/song4', 1, 4)
70+
;
71+
72+
assertMatchesHtmlSnapshot((string)$og);
73+
});
74+
75+
it('can generate radiostation tags', function () {
76+
$og = RadioStation::make('Title | Example')
77+
->url('http://www.example.com/radiostation')
78+
->description('Description')
79+
->locale('en_US')
80+
->alternateLocale('en_GB')
81+
->siteName('Example')
82+
->image('http://www.example.com/image1.jpg')
83+
84+
->creator('http://www.example.com/creator')
85+
;
86+
87+
assertMatchesHtmlSnapshot((string)$og);
88+
});

tests/VideoTypesTest.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
use Astrotomic\OpenGraph\StructuredProperties\Image;
4+
use Astrotomic\OpenGraph\Type;
5+
use Astrotomic\OpenGraph\Types\Article;
6+
use Astrotomic\OpenGraph\Types\Book;
7+
use Astrotomic\OpenGraph\Types\Profile;
8+
use Astrotomic\OpenGraph\Types\Video\Episode;
9+
use Astrotomic\OpenGraph\Types\Video\Movie;
10+
use Astrotomic\OpenGraph\Types\Video\Other;
11+
use Astrotomic\OpenGraph\Types\Video\TvShow;
12+
use Astrotomic\OpenGraph\Types\Website;
13+
14+
it('can generate movie tags', function () {
15+
$og = Movie::make('Title | Example')
16+
->url('http://www.example.com/movie')
17+
->description('Description')
18+
->locale('en_US')
19+
->alternateLocale('en_GB')
20+
->siteName('Example')
21+
->image('http://www.example.com/image1.jpg')
22+
->image(
23+
Image::make('http://www.example.com/image2.jpg')
24+
->width(1920)
25+
->height(1080)
26+
->mimeType('image/jpg')
27+
->alt('Movie Wallpaper')
28+
)
29+
30+
->releasedAt(new DateTime('2020-06-05'))
31+
->actor('http://www.example.com/actor1', 'role1')
32+
->actor('http://www.example.com/actor2', 'role2')
33+
->director('http://www.example.com/director')
34+
->writer('http://www.example.com/writer')
35+
->duration(60 * 90)
36+
->tag('Crime')
37+
->tag('Thriller')
38+
;
39+
40+
assertMatchesHtmlSnapshot((string)$og);
41+
});
42+
43+
it('can generate tv show tags', function () {
44+
$og = TvShow::make('Title | Example')
45+
->url('http://www.example.com/tvshow')
46+
->description('Description')
47+
->locale('en_US')
48+
->alternateLocale('en_GB')
49+
->siteName('Example')
50+
->image('http://www.example.com/image1.jpg')
51+
52+
->releasedAt(new DateTime('2020-06-05'))
53+
->actor('http://www.example.com/actor', 'role')
54+
->director('http://www.example.com/director')
55+
->writer('http://www.example.com/writer')
56+
->tag('Crime')
57+
;
58+
59+
assertMatchesHtmlSnapshot((string)$og);
60+
});
61+
62+
it('can generate episode tags', function () {
63+
$og = Episode::make('Title | Example')
64+
->url('http://www.example.com/episode')
65+
->description('Description')
66+
->locale('en_US')
67+
->alternateLocale('en_GB')
68+
->siteName('Example')
69+
->image('http://www.example.com/image1.jpg')
70+
71+
->series('http://www.example.com/tvshow')
72+
->releasedAt(new DateTime('2020-06-05'))
73+
->duration(60 * 25)
74+
->actor('http://www.example.com/actor', 'role')
75+
->director('http://www.example.com/director')
76+
->writer('http://www.example.com/writer')
77+
->tag('Crime')
78+
;
79+
80+
assertMatchesHtmlSnapshot((string)$og);
81+
});
82+
83+
it('can generate other tags', function () {
84+
$og = Other::make('Title | Example')
85+
->url('http://www.example.com/other')
86+
->description('Description')
87+
->locale('en_US')
88+
->alternateLocale('en_GB')
89+
->siteName('Example')
90+
->image('http://www.example.com/image1.jpg')
91+
->video('http://www.example.com/video.mp4')
92+
93+
->releasedAt(new DateTime('2020-06-05'))
94+
->duration(60 * 3.5)
95+
->actor('http://www.example.com/actor', 'role')
96+
->director('http://www.example.com/director')
97+
->writer('http://www.example.com/writer')
98+
->tag('Crime')
99+
;
100+
101+
assertMatchesHtmlSnapshot((string)$og);
102+
});

tests/__snapshots__/GenerateOpenGraphTest__it_can_generate_basic_required_metadata_tags__1.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/__snapshots__/GenerateOpenGraphTest__it_can_generate_metadata_for_a_book__1.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)