mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
improve unit tests
This commit is contained in:
parent
a260c776cc
commit
a748d50b0a
|
|
@ -18,6 +18,7 @@ use phpOMS\Contract\ArrayableInterface;
|
|||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Localization\NullLocalization;
|
||||
use phpOMS\Validation\Network\Email;
|
||||
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||
|
||||
/**
|
||||
* Account class.
|
||||
|
|
@ -481,12 +482,14 @@ class Account implements ArrayableInterface, \JsonSerializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidEnumValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStatus(int $status) : void
|
||||
{
|
||||
if (!AccountStatus::isValidValue($status)) {
|
||||
throw new \InvalidArgumentException();
|
||||
throw new InvalidEnumValue($status);
|
||||
}
|
||||
|
||||
$this->status = $status;
|
||||
|
|
@ -513,12 +516,14 @@ class Account implements ArrayableInterface, \JsonSerializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidEnumValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setType(int $type) : void
|
||||
{
|
||||
if (!AccountType::isValidValue($type)) {
|
||||
throw new \InvalidArgumentException();
|
||||
throw new InvalidEnumValue($type);
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
|
|
|
|||
|
|
@ -519,6 +519,44 @@ final class ModuleManager
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall module.
|
||||
*
|
||||
* @param string $module Module name
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function uninstall(string $module) : bool
|
||||
{
|
||||
$installed = $this->getInstalledModules(false);
|
||||
|
||||
if (!isset($installed[$module])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!\file_exists($this->modulePath . '/' . $module . '/Admin/Uninstaller.php')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$info = $this->loadInfo($module);
|
||||
|
||||
$this->installed[$module] = $info;
|
||||
// uninstall dependencies if not used by others
|
||||
// uninstall providing for
|
||||
// uninstall receiving from? no?
|
||||
// uninstall module
|
||||
|
||||
return true;
|
||||
} catch (PathException $e) {
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Install module dependencies.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -130,11 +130,11 @@ final class Argument implements UriInterface
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $uri Root path for subdirectory
|
||||
* @param string $uri Uri
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $uri)
|
||||
public function __construct(string $uri = '')
|
||||
{
|
||||
$this->set($uri);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedException \phpOMS\Stdlib\Base\Exception\InvalidEnumValue
|
||||
*/
|
||||
public function testStatusException()
|
||||
{
|
||||
|
|
@ -181,7 +181,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedException \phpOMS\Stdlib\Base\Exception\InvalidEnumValue
|
||||
*/
|
||||
public function testTypeException()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,4 +72,13 @@ class GroupTest extends \PHPUnit\Framework\TestCase
|
|||
$group->setStatus(GroupStatus::ACTIVE);
|
||||
self::assertEquals(GroupStatus::ACTIVE, $group->getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \phpOMS\Stdlib\Base\Exception\InvalidEnumValue
|
||||
*/
|
||||
public function testStatusException()
|
||||
{
|
||||
$account = new Group();
|
||||
$account->setStatus(99);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user