Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson committed Sep 13, 2024
1 parent 9ef2140 commit 77fbc52
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/admin/Unit/Models/StaffTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

uses(\Lunar\Tests\Admin\Unit\Models\TestCase::class)
->group('lunar.admin.models');

test('can get full name', function () {
$staff = \Lunar\Admin\Models\Staff::factory()->create([
'firstname' => 'Joe',
'lastname' => 'Bloggs',
]);

expect($staff->full_name)->toBe('Joe Bloggs');
});

test('can search staff by name', function () {
\Lunar\Admin\Models\Staff::factory()->create([
'firstname' => 'Joe',
'lastname' => 'Bloggs',
]);

\Lunar\Admin\Models\Staff::factory()->create([
'firstname' => 'Tim',
'lastname' => 'Bloggs',
]);

\Lunar\Admin\Models\Staff::factory()->create([
'firstname' => 'Bill',
'lastname' => 'Chance',
]);

expect(\Lunar\Admin\Models\Staff::search('Bloggs')->get())->toHaveCount(2)
->and(\Lunar\Admin\Models\Staff::search('Bill')->get())->toHaveCount(1)
->and(\Lunar\Admin\Models\Staff::search('Joe Bloggs')->get())->toHaveCount(1);
});

13 changes: 13 additions & 0 deletions tests/admin/Unit/Models/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Lunar\Tests\Admin\Unit\Models;

use Lunar\Tests\Admin\TestCase as BaseTestCase;

class TestCase extends BaseTestCase
{
protected function setUp(): void
{
parent::setUp();
}
}

0 comments on commit 77fbc52

Please sign in to comment.