Skip to content

Commit 9de8910

Browse files
committed
✅ tests for virtual pages
1 parent 4fecf0b commit 9de8910

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/APIPagesTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,35 @@
5454
'template' => 'default',
5555
]);
5656
});
57+
58+
it('can create virtual pages for catfacts (rest api from blueprint config)', function () {
59+
expect(page('cats')->children()->count())->not()->toBe(0);
60+
61+
$content = page('cats/bombay')->content()->toArray();
62+
unset($content['uuid']); // is dynamic for this example
63+
expect($content)->toBe([
64+
'title' => 'Bombay',
65+
'country' => 'developed in the United States (founding stock from Asia)',
66+
'origin' => 'Crossbred',
67+
'coat' => 'Short',
68+
'pattern' => 'Solid',
69+
]);
70+
});
71+
72+
it('can create virtual pages for rickandmorty (tokenless graphql from PHP options)', function () {
73+
expect(page('rickandmorty')->children()->count())->not()->toBe(0);
74+
75+
$content = page('rickandmorty/albert-einstein')->content()->toArray();
76+
expect($content)->toBe([
77+
'title' => 'Albert Einstein',
78+
'uuid' => md5('Albert Einstein'),
79+
'species' => 'Human',
80+
'hstatus' => 'Dead',
81+
]);
82+
});
83+
84+
it('can create virtual pages for a secret api (basic auth graphql from PHP model)', function () {
85+
expect(page('secrets')->children()->count())->not()->toBe(0);
86+
87+
expect(page('secrets/typo3')->content()->toArray())->toHaveKeys(['title', 'uuid', 'description']);
88+
})->skipOnLinux();

tests/site/config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'map' => [
2727
// kirby <=> json
2828
'title' => 'name',
29+
'uuid' => fn ($i) => md5($i['name']),
2930
'template' => fn ($i) => strtolower($i['species']), // site/blueprints/pages/alien.yml || human.yml
3031
'content' => [
3132
'species' => 'species',

0 commit comments

Comments
 (0)