Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Sep 9, 2024
1 parent a64453c commit 9165a16
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/framework/tests/Unit/Facades/AuthorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,31 @@ public function testCreate()
$this->assertSame('https://johndoe.com', $author->website);
}

public function testCreateWithOnlyRequiredFields()
{
$author = Author::create('john_doe');

$this->assertSame('john_doe', $author->username);
$this->assertSame('john_doe', $author->name);
$this->assertNull($author->website);
}

public function testGet()
{
$author = Author::get('mr_hyde');

$this->assertSame('mr_hyde', $author->username);
$this->assertSame('Mr. Hyde', $author->name);
$this->assertSame('https://hydephp.com', $author->website);
}

public function testGetWithNotSetUsername()
{
$this->assertEquals(Author::create('foo'), Author::get('foo'));
}

public function testGetAliasesPostAuthor()
{
$this->assertEquals(PostAuthor::get('foo'), Author::get('foo'));
}

Expand All @@ -45,5 +62,12 @@ public function testAll()
$authors = Author::all();
$this->assertCount(1, $authors);
$this->assertContainsOnlyInstancesOf(PostAuthor::class, $authors);
$this->assertEquals(Author::get('mr_hyde'), $authors->first());
}

public function testAllWithNoAuthors()
{
self::mockConfig(['hyde.authors' => []]);
$this->assertEmpty(Author::all());
}
}

0 comments on commit 9165a16

Please sign in to comment.