Skip to content

Commit

Permalink
Add Author::getName() unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed May 19, 2022
1 parent e039062 commit 64616a6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Models/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function __construct(string $username, ?array $data = [])
/**
* Get the author's name.
*
* @see \Tests\Unit\AuthorGetNameTest
*
* @return string
*/
public function getName(): string
Expand Down
31 changes: 31 additions & 0 deletions tests/Unit/AuthorGetNameTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Tests\Unit;

use Hyde\Framework\Models\Author;
use Tests\TestCase;

/**
* Class HasAuthorTest.
*
* @covers \Hyde\Framework\Models\Author::getName
*/
class AuthorGetNameTest extends TestCase
{
// Test get name helper returns name if set
public function test_get_name_helper_returns_name_if_set()
{
$author = new Author('username');
$author->name = 'John Doe';

$this->assertEquals('John Doe', $author->getName());
}

// Test get name helper returns username if name is not set
public function test_get_name_helper_returns_username_if_name_is_not_set()
{
$author = new Author('username');

$this->assertEquals('username', $author->getName());
}
}

0 comments on commit 64616a6

Please sign in to comment.