Skip to content

Commit

Permalink
tests (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Aug 13, 2021
1 parent 60e8243 commit d037be8
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
2 changes: 2 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
<env name="MAIL_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="UPTIME_API_KEY" value="b82ccdea6d2adbab345347b17c615676f46eb114"/>

</php>
</phpunit>
25 changes: 24 additions & 1 deletion tests/Unit/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

use Illuminate\Support\Facades\Notification;
use Statamic\Entries\Collection;
use Statamic\Facades\Blueprint;
use Statamic\Facades\Entry;
use Statamic\Facades\File;
use Statamic\Facades\User;
use Statamic\Facades\YAML;
use TransformStudios\Uptime\Notifications\AlertCleared;
use TransformStudios\Uptime\Tests\TestCase;

Expand Down Expand Up @@ -71,7 +74,27 @@ public function sends_alert_cleared_notification()

$user->save();

$collection = (new Collection)->handle('sites');
$blueprint = Blueprint::makeFromFields(YAML::file(__DIR__.'/../__fixtures__/blueprints/sites.yaml')->parse())
->setHandle('sites');
$userBlueprint = Blueprint::makeFromFields(YAML::file(__DIR__.'/../__fixtures__/blueprints/user.yaml')->parse())
->setHandle('user');
Blueprint::shouldReceive('in')->with('collections/sites')->andReturn(collect(['sites' => $blueprint]));
Blueprint::shouldReceive('in')->with('users')->andReturn(collect(['user' => $userBlueprint]));

// Blueprint::setDirectory(__DIR__.'/../__fixtures__/blueprints/');
// // $blueprint = Blueprint::make('sites')
// // ->setContents(YAML::file(__DIR__.'/../__fixtures__/blueprints/sites.yaml')->parse());

// // $blueprint->save();

// copy(
// __DIR__.'/../__fixtures__/blueprints/sites.yaml',
// '../__fixtures__/blueprints/collections/sites/sites.yaml'
// );
// dd('what');
$collection = (new Collection)
->handle('sites');
// ->entryBlueprint('sites');

$collection->save();

Expand Down
45 changes: 45 additions & 0 deletions tests/__fixtures__/blueprints/sites.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
title: Sites
sections:
main:
display: Main
fields:
-
handle: title
field:
type: text
required: true
validate:
- required
-
handle: content
field:
type: markdown
localizable: true
-
handle: users
field:
mode: select
display: Users
type: users
icon: users
listable: hidden
-
handle: uptime_tag
field:
max_items: 1
mode: select
display: 'Uptime Tag'
type: uptime_tag
icon: uptime_tag
listable: hidden
sidebar:
display: Sidebar
fields:
-
handle: slug
field:
type: slug
required: true
localizable: true
validate:
- required
29 changes: 29 additions & 0 deletions tests/__fixtures__/blueprints/user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
sections:
main:
display: Main
fields:
-
handle: email
field:
type: text
display: 'Email address'
width: 33
-
handle: roles
field:
type: user_roles
width: 33
-
handle: name
field:
type: text
display: 'Name'
width: 33
listable: true
input_type: text
antlers: false
-
handle: content
field:
type: textarea
display: Biography

0 comments on commit d037be8

Please sign in to comment.