mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-10-17 13:03:12 -04:00
use a helper class to make users
This commit is contained in:
@@ -3,34 +3,35 @@
|
||||
use \PHPUnit\Framework\TestCase;
|
||||
|
||||
require_once(__DIR__ . '/../../lib/bootstrap.php');
|
||||
require_once(__DIR__ . '/../helper.php');
|
||||
|
||||
class applicantTest extends TestCase {
|
||||
protected \Gazelle\Manager\ApplicantRole $roleManager;
|
||||
protected \Gazelle\Manager\Applicant $manager;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->roleManager = new \Gazelle\Manager\ApplicantRole;
|
||||
$this->manager = new \Gazelle\Manager\Applicant;
|
||||
}
|
||||
|
||||
public function testApplicant(): void {
|
||||
$this->assertIsArray($this->roleManager->list(), 'role-manager-list-published-is-array');
|
||||
$new = $this->manager->newApplicantCount();
|
||||
$admin = (new Gazelle\Manager\User)->find('@admin');
|
||||
$user = (new Gazelle\Manager\User)->find('@user');
|
||||
$roleManager = new \Gazelle\Manager\ApplicantRole;
|
||||
$manager = new \Gazelle\Manager\Applicant;
|
||||
|
||||
$this->assertIsArray($roleManager->list(), 'role-manager-list-published-is-array');
|
||||
$new = $manager->newApplicantCount();
|
||||
$admin = Helper::makeUser('admin.' . randomString(10), 'applicant');
|
||||
$user = Helper::makeUser('user.' . randomString(10), 'applicant');
|
||||
$admin->setUpdate('PermissionID', SYSOP)->modify();
|
||||
|
||||
$role = 'published-' . randomString(6);
|
||||
$published = $this->roleManager->create($role, 'this is a published role', true, 1);
|
||||
$this->assertInstanceOf('\\Gazelle\\ApplicantRole', $published, 'applicant-role-instance');
|
||||
$published = $roleManager->create($role, 'this is a published role', true, 1);
|
||||
$this->assertInstanceOf(Gazelle\ApplicantRole::class, $published, 'applicant-role-instance');
|
||||
|
||||
$unpublished = $this->roleManager->create('unpublished-' . randomString(6), 'this is an unpublished role', false, $admin->id());
|
||||
$unpublished = $roleManager->create('unpublished-' . randomString(6), 'this is an unpublished role', false, $admin->id());
|
||||
$this->assertEquals($role, $roleManager->title($published->id()), 'role-manager-title');
|
||||
|
||||
$apply = $manager->create($user->id(), $published->id(), 'application message');
|
||||
$this->assertInstanceOf(Gazelle\Applicant::class, $apply, 'applicant-instance');
|
||||
$this->assertTrue($manager->userIsApplicant($user->id()), 'applicant-user-applied');
|
||||
$this->assertEquals($new + 1, $manager->newApplicantCount(), 'applicant-new-count');
|
||||
|
||||
$this->assertEquals($role, $this->roleManager->title($published->id()), 'role-manager-title');
|
||||
$this->assertEquals(1, $published->remove(), 'role-published-remove');
|
||||
$this->assertEquals(1, $unpublished->remove(), 'role-unpublished-remove');
|
||||
|
||||
$apply = $this->manager->create($user->id(), $published->id(), 'application message');
|
||||
$this->assertInstanceOf('\\Gazelle\\Applicant', $apply, 'applicant-instance');
|
||||
$this->assertTrue($this->manager->userIsApplicant($user->id()), 'applicant-user-applied');
|
||||
$this->assertEquals($new + 1, $this->manager->newApplicantCount(), 'applicant-new-count');
|
||||
$admin->remove();
|
||||
$user->remove();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user