diff --git a/packages/framework/tests/Unit/Facades/AuthorTest.php b/packages/framework/tests/Unit/Facades/AuthorTest.php index 9a5995975da..b4519c8d56c 100644 --- a/packages/framework/tests/Unit/Facades/AuthorTest.php +++ b/packages/framework/tests/Unit/Facades/AuthorTest.php @@ -29,6 +29,15 @@ 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'); @@ -36,7 +45,15 @@ public function testGet() $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')); } @@ -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()); } }