File tree Expand file tree Collapse file tree 6 files changed +25
-45
lines changed Expand file tree Collapse file tree 6 files changed +25
-45
lines changed Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- use DragonCode \LaravelFeed \Console \Commands \FeedGenerateCommand ;
65use Workbench \App \Feeds \EmptyFeed ;
76
8- use function Pest \Laravel \artisan ;
9-
107test ('export ' , function (bool $ pretty ) {
118 setPrettyXml ($ pretty );
129
13- $ feed = app ()->make (EmptyFeed::class);
14-
15- artisan (FeedGenerateCommand::class)->run ();
16-
17- expect ($ feed ->path ())->toBeReadableFile ();
18- expect (file_get_contents ($ feed ->path ()))->toMatchSnapshot ();
10+ expectFeed (EmptyFeed::class);
1911})->with ('boolean ' );
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- use DragonCode \LaravelFeed \Console \Commands \FeedGenerateCommand ;
65use Workbench \App \Data \NewsFakeData ;
76use Workbench \App \Feeds \FullFeed ;
87
9- use function Pest \Laravel \artisan ;
10-
118test ('export ' , function (bool $ pretty ) {
129 setPrettyXml ($ pretty );
1310
1411 createNews (...NewsFakeData::toArray ());
1512
16- $ feed = app ()->make (FullFeed::class);
17-
18- artisan (FeedGenerateCommand::class)->run ();
19-
20- expect ($ feed ->path ())->toBeReadableFile ();
21- expect (file_get_contents ($ feed ->path ()))->toMatchSnapshot ();
13+ expectFeed (FullFeed::class);
2214})->with ('boolean ' );
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- use DragonCode \LaravelFeed \Console \Commands \FeedGenerateCommand ;
65use Workbench \App \Data \NewsFakeData ;
76use Workbench \App \Feeds \PartialFeed ;
87
9- use function Pest \Laravel \artisan ;
10-
118test ('export ' , function (bool $ pretty ) {
129 setPrettyXml ($ pretty );
1310
1714
1815 createNews (...NewsFakeData::toArray ());
1916
20- $ feed = app ()->make (PartialFeed::class);
21-
22- artisan (FeedGenerateCommand::class)->run ();
23-
24- expect ($ feed ->path ())->toBeReadableFile ();
25- expect (file_get_contents ($ feed ->path ()))->toMatchSnapshot ();
17+ expectFeed (PartialFeed::class);
2618})->with ('boolean ' );
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- use DragonCode \LaravelFeed \Console \Commands \FeedGenerateCommand ;
65use Workbench \App \Feeds \SitemapFeed ;
76
8- use function Pest \Laravel \artisan ;
9-
107test ('export ' , function () {
118 createProducts ();
129
13- $ feed = app ()->make (SitemapFeed::class);
14-
15- artisan (FeedGenerateCommand::class)->run ();
16-
17- expect ($ feed ->path ())->toBeReadableFile ();
18- expect (file_get_contents ($ feed ->path ()))->toMatchSnapshot ();
10+ expectFeed (SitemapFeed::class);
1911});
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- use DragonCode \LaravelFeed \Console \Commands \FeedGenerateCommand ;
65use Workbench \App \Feeds \YandexFeed ;
76
8- use function Pest \Laravel \artisan ;
9-
107test ('export ' , function () {
118 createProducts ();
129
13- $ feed = app ()->make (YandexFeed::class);
14-
15- artisan (FeedGenerateCommand::class)->run ();
16-
17- expect ($ feed ->path ())->toBeReadableFile ();
18- expect (file_get_contents ($ feed ->path ()))->toMatchSnapshot ();
10+ expectFeed (YandexFeed::class);
1911});
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use DragonCode \LaravelFeed \Console \Commands \FeedGenerateCommand ;
6+
7+ use function Pest \Laravel \artisan ;
8+
9+ /**
10+ * @param class-string<DragonCode\LaravelFeed\Feeds\Feed> $feed
11+ */
12+ function expectFeed (string $ feed ): void
13+ {
14+ $ instance = app ($ feed );
15+
16+ artisan (FeedGenerateCommand::class)->assertSuccessful ()->run ();
17+
18+ expect ($ instance ->path ())->toBeReadableFile ();
19+ expect (file_get_contents ($ instance ->path ()))->toMatchSnapshot ();
20+ }
You can’t perform that action at this time.
0 commit comments