Browse Source

Speed up tests by only hashing passwords when needed

microsub
J. King 7 years ago
parent
commit
44c2ff5b07
  1. 18
      tests/User/TestUser.php
  2. 18
      tests/User/TestUserExternal.php

18
tests/User/TestUser.php

@ -32,29 +32,29 @@ class TestUser extends \PHPUnit\Framework\TestCase {
} }
function testAddAUser() { function testAddAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertCount(1,$this->data->user->list()); $this->assertCount(1,$this->data->user->list());
} }
function testCheckIfAUserDoesExist() { function testCheckIfAUserDoesExist() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertTrue($this->data->user->exists(self::USER1)); $this->assertTrue($this->data->user->exists(self::USER1));
} }
function testAddADuplicateUser() { function testAddADuplicateUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertException("alreadyExists", "User"); $this->assertException("alreadyExists", "User");
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
} }
function testAddMultipleUsers() { function testAddMultipleUsers() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->data->user->add(self::USER2, "secret"); $this->data->user->add(self::USER2, "");
$this->assertCount(2,$this->data->user->list()); $this->assertCount(2,$this->data->user->list());
} }
function testRemoveAUser() { function testRemoveAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertCount(1,$this->data->user->list()); $this->assertCount(1,$this->data->user->list());
$this->data->user->remove(self::USER1); $this->data->user->remove(self::USER1);
$this->assertCount(0,$this->data->user->list()); $this->assertCount(0,$this->data->user->list());
@ -118,12 +118,12 @@ class TestUser extends \PHPUnit\Framework\TestCase {
} }
function testGetTheRightsOfAUser() { function testGetTheRightsOfAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertEquals(User\Driver::RIGHTS_NONE, $this->data->user->rightsGet(self::USER1)); $this->assertEquals(User\Driver::RIGHTS_NONE, $this->data->user->rightsGet(self::USER1));
} }
function testSetTheRightsOfAUser() { function testSetTheRightsOfAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->data->user->rightsSet(self::USER1, User\Driver::RIGHTS_GLOBAL_ADMIN); $this->data->user->rightsSet(self::USER1, User\Driver::RIGHTS_GLOBAL_ADMIN);
$this->assertEquals(User\Driver::RIGHTS_GLOBAL_ADMIN, $this->data->user->rightsGet(self::USER1)); $this->assertEquals(User\Driver::RIGHTS_GLOBAL_ADMIN, $this->data->user->rightsGet(self::USER1));
} }

18
tests/User/TestUserExternal.php

@ -33,29 +33,29 @@ class TestUserExternal extends \PHPUnit\Framework\TestCase {
} }
function testAddAUser() { function testAddAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertCount(1,$this->data->user->list()); $this->assertCount(1,$this->data->user->list());
} }
function testCheckIfAUserDoesExist() { function testCheckIfAUserDoesExist() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertTrue($this->data->user->exists(self::USER1)); $this->assertTrue($this->data->user->exists(self::USER1));
} }
function testAddADuplicateUser() { function testAddADuplicateUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertException("alreadyExists", "User"); $this->assertException("alreadyExists", "User");
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
} }
function testAddMultipleUsers() { function testAddMultipleUsers() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->data->user->add(self::USER2, "secret"); $this->data->user->add(self::USER2, "");
$this->assertCount(2,$this->data->user->list()); $this->assertCount(2,$this->data->user->list());
} }
function testRemoveAUser() { function testRemoveAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertCount(1,$this->data->user->list()); $this->assertCount(1,$this->data->user->list());
$this->data->user->remove(self::USER1); $this->data->user->remove(self::USER1);
$this->assertCount(0,$this->data->user->list()); $this->assertCount(0,$this->data->user->list());
@ -119,12 +119,12 @@ class TestUserExternal extends \PHPUnit\Framework\TestCase {
} }
function testGetTheRightsOfAUser() { function testGetTheRightsOfAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->assertEquals(User\Driver::RIGHTS_NONE, $this->data->user->rightsGet(self::USER1)); $this->assertEquals(User\Driver::RIGHTS_NONE, $this->data->user->rightsGet(self::USER1));
} }
function testSetTheRightsOfAUser() { function testSetTheRightsOfAUser() {
$this->data->user->add(self::USER1, "secret"); $this->data->user->add(self::USER1, "");
$this->data->user->rightsSet(self::USER1, User\Driver::RIGHTS_GLOBAL_ADMIN); $this->data->user->rightsSet(self::USER1, User\Driver::RIGHTS_GLOBAL_ADMIN);
$this->assertEquals(User\Driver::RIGHTS_GLOBAL_ADMIN, $this->data->user->rightsGet(self::USER1)); $this->assertEquals(User\Driver::RIGHTS_GLOBAL_ADMIN, $this->data->user->rightsGet(self::USER1));
} }

Loading…
Cancel
Save