Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
Ref #49: Add unit test for Account Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
hundrex committed Mar 8, 2018
1 parent 33e6747 commit 31c7623
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/AppBundle/Entity/AccountTest.php
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');
}


}


0 comments on commit 31c7623

Please sign in to comment.