This repository has been archived by the owner on May 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #49: Add unit test for Account Entity
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Tests\AppBundle\Entity; | ||
|
||
use AppBundle\Entity\Account; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AccounTest extends TestCase | ||
{ | ||
public function testIsAdmin() | ||
{ | ||
$account = new Account(); | ||
$account->setAdmin(); | ||
|
||
$result = $account->isAdmin(); | ||
$result2 = $account->isGuest(); | ||
$result3 = $account->isUser(); | ||
|
||
|
||
$this->assertTrue($result, 'An admin user should have admin privileges'); | ||
$this->assertTrue($result2, 'An admin user is also a guest user and should have guest privileges'); | ||
$this->assertTrue($result3, 'An admin user is also a common user and should have common user privileges'); | ||
} | ||
|
||
public function testIsGuest() | ||
{ | ||
$account = new Account(); | ||
$account->setGuest(); | ||
|
||
$result = $account->isAdmin(); | ||
$result2 = $account->isGuest(); | ||
$result3 = $account->isUser(); | ||
|
||
|
||
$this->assertFalse($result, 'A guest user can\'t have admin privileges'); | ||
$this->assertTrue($result2, 'A guest user should have guest privileges'); | ||
$this->assertTrue($result3, 'An guest user is also a common user and should have common user privileges'); | ||
} | ||
|
||
public function testIsUser() | ||
{ | ||
$account = new Account(); | ||
$account->setUser(); | ||
|
||
$result = $account->isAdmin(); | ||
$result2 = $account->isGuest(); | ||
$result3 = $account->isUser(); | ||
|
||
|
||
$this->assertFalse($result, 'A common user can\'t have admin privileges'); | ||
$this->assertFalse($result2, 'A common user can\'t have guest privileges'); | ||
$this->assertTrue($result3, 'A common user should have common user privileges'); | ||
} | ||
|
||
|
||
} | ||
|
||
|