diff --git a/Account/Account.php b/Account/Account.php index 68b79b519..c969c5663 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -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; diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 221fe98ba..ef32866eb 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -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. * diff --git a/Uri/Argument.php b/Uri/Argument.php index dbe139ee3..435e4ada5 100644 --- a/Uri/Argument.php +++ b/Uri/Argument.php @@ -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); } diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index 9302ded7c..2220ac948 100644 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -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() { diff --git a/tests/Account/GroupTest.php b/tests/Account/GroupTest.php index b894606d4..d1ee2343e 100644 --- a/tests/Account/GroupTest.php +++ b/tests/Account/GroupTest.php @@ -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); + } }