diff --git a/composer.lock b/composer.lock
index fb79cd21..b085b329 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "5f53c98916a1a98d47190e78c4bd4a7b",
+ "hash": "1cfa8fc4b867d0e6dd4a2884476316d1",
"packages": [
{
"name": "evandotpro/edp-github",
@@ -163,16 +163,16 @@
},
{
"name": "monolog/monolog",
- "version": "1.12.0",
+ "version": "1.13.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
- "reference": "1fbe8c2641f2b163addf49cc5e18f144bec6b19f"
+ "reference": "c41c218e239b50446fd883acb1ecfd4b770caeae"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1fbe8c2641f2b163addf49cc5e18f144bec6b19f",
- "reference": "1fbe8c2641f2b163addf49cc5e18f144bec6b19f",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c41c218e239b50446fd883acb1ecfd4b770caeae",
+ "reference": "c41c218e239b50446fd883acb1ecfd4b770caeae",
"shasum": ""
},
"require": {
@@ -189,6 +189,7 @@
"phpunit/phpunit": "~4.0",
"raven/raven": "~0.5",
"ruflin/elastica": "0.90.*",
+ "swiftmailer/swiftmailer": "~5.3",
"videlalvaro/php-amqplib": "~2.4"
},
"suggest": {
@@ -205,7 +206,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.12.x-dev"
+ "dev-master": "1.13.x-dev"
}
},
"autoload": {
@@ -231,7 +232,7 @@
"logging",
"psr-3"
],
- "time": "2014-12-29 21:29:35"
+ "time": "2015-03-05 01:12:12"
},
{
"name": "phing/phing",
diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php
index bcd59b61..32fb9141 100644
--- a/module/Application/config/module.config.php
+++ b/module/Application/config/module.config.php
@@ -95,6 +95,9 @@
],
],
'view_helpers' => [
+ 'invokables' => [
+ 'FlashMessenger' => View\Helper\FlashMessenger::class,
+ ],
'factories' => [
'gitHubRepositoryUrl' => View\Helper\GitHubRepositoryUrlFactory::class,
'sanitizeHtml' => View\Helper\SanitizeHtmlFactory::class,
diff --git a/module/Application/src/Application/Exception/ViewableUserException.php b/module/Application/src/Application/Exception/ViewableUserException.php
new file mode 100644
index 00000000..b0aac34d
--- /dev/null
+++ b/module/Application/src/Application/Exception/ViewableUserException.php
@@ -0,0 +1,26 @@
+publicMessage = (string) $publicMessage;
+ parent::__construct($message, $code, $previous);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPublicMessage()
+ {
+ return $this->publicMessage;
+ }
+}
diff --git a/module/Application/src/Application/Exception/ViewableUserExceptionInterface.php b/module/Application/src/Application/Exception/ViewableUserExceptionInterface.php
new file mode 100644
index 00000000..8b2ec7d5
--- /dev/null
+++ b/module/Application/src/Application/Exception/ViewableUserExceptionInterface.php
@@ -0,0 +1,20 @@
+classOptions = [
+ PluginFlashMessenger::NAMESPACE_INFO => [
+ 'name' => 'Information',
+ 'class' => 'alert alert-info',
+ ],
+ PluginFlashMessenger::NAMESPACE_ERROR => [
+ 'name' => 'Error',
+ 'class' => 'alert alert-danger',
+ ],
+ PluginFlashMessenger::NAMESPACE_SUCCESS => [
+ 'name' => 'Success',
+ 'class' => 'alert alert-success',
+ ],
+ PluginFlashMessenger::NAMESPACE_DEFAULT => [
+ 'name' => 'Message',
+ 'class' => 'alert alert-info',
+ ],
+ PluginFlashMessenger::NAMESPACE_WARNING => [
+ 'name' => 'Warning',
+ 'class' => 'alert alert-warning',
+ ],
+ ];
+
+ // if custom namespace handle as default message
+ if (!isset($this->classOptions[$namespace])) {
+ $this->classOptions = [
+ $namespace => $this->classOptions[PluginFlashMessenger::NAMESPACE_DEFAULT],
+ ];
+ }
+
+ $messageOutput = '';
+ $translator = $this->getTranslator();
+
+ foreach ($this->classOptions as $currentNamespace => $options) {
+ $this->classMessages[$currentNamespace] = $options['class'];
+ $openingString = sprintf('
%s', $translator->translate($options['name']));
+
+ $this->setMessageOpenFormat($openingString);
+ $this->setMessageSeparatorString(sprintf('
%s', $openingString));
+ $this->setMessageCloseString('');
+
+ $messageOutput .= $renderer($currentNamespace, $classes);
+ }
+
+ return $messageOutput;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = [])
+ {
+ $renderer = function ($namespace, $classes) {
+ return parent::render($namespace, $classes);
+ };
+
+ return $this->doRender($renderer, $namespace, $classes);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = [])
+ {
+ $renderer = function ($namespace, $classes) {
+ return parent::renderCurrent($namespace, $classes);
+ };
+
+ return $this->doRender($renderer, $namespace, $classes);
+ }
+}
diff --git a/module/Application/test/ApplicationTest/Exception/ViewableUserExceptionTest.php b/module/Application/test/ApplicationTest/Exception/ViewableUserExceptionTest.php
new file mode 100644
index 00000000..b938db22
--- /dev/null
+++ b/module/Application/test/ApplicationTest/Exception/ViewableUserExceptionTest.php
@@ -0,0 +1,26 @@
+getMock(\Exception::class);
+
+ $exception = new Exception\ViewableUserException(
+ 'fooMessage',
+ 'fooPublicMessage',
+ 666,
+ $parentExceptionMock
+ );
+
+ $this->assertSame('fooMessage', $exception->getMessage());
+ $this->assertSame('fooPublicMessage', $exception->getPublicMessage());
+ $this->assertSame(666, $exception->getCode());
+ $this->assertSame($parentExceptionMock, $exception->getPrevious());
+ }
+}
diff --git a/module/Application/test/ApplicationTest/Integration/View/Helper/FlashMessengerTest.php b/module/Application/test/ApplicationTest/Integration/View/Helper/FlashMessengerTest.php
new file mode 100644
index 00000000..d18a6c4e
--- /dev/null
+++ b/module/Application/test/ApplicationTest/Integration/View/Helper/FlashMessengerTest.php
@@ -0,0 +1,57 @@
+get('ControllerPluginManager')->get('FlashMessenger');
+
+ $flashMessengerControllerPlugin->addMessage('FooMessage');
+ $flashMessengerControllerPlugin->addSuccessMessage('FooSuccess');
+ $flashMessengerControllerPlugin->addWarningMessage('FooWarning');
+ $flashMessengerControllerPlugin->addErrorMessage('FooError');
+ $flashMessengerControllerPlugin->addInfoMessage('FooInfo');
+
+ /* @var \Application\View\Helper\FlashMessenger $flashMessengerViewHelper */
+ $flashMessengerViewHelper = $serviceManager->get('ViewHelperManager')->get('FlashMessenger');
+
+ $this->assertEquals(
+ 'InformationFooInfo
' .
+ 'ErrorFooError
' .
+ 'SuccessFooSuccess
' .
+ 'MessageFooMessage
' .
+ 'WarningFooWarning
',
+ $flashMessengerViewHelper->renderCurrent()
+ );
+ }
+
+ public function testCustomNamespaceMessageGetsRenderedAsInformationMessage()
+ {
+ $serviceManager = Bootstrap::getServiceManager();
+
+ /* @var $flashMessengerControllerPlugin \Zend\Mvc\Controller\Plugin\FlashMessenger */
+ $flashMessengerControllerPlugin = $serviceManager->get('ControllerPluginManager')->get('FlashMessenger');
+ $flashMessengerControllerPlugin->setNamespace('FooBar');
+
+ $flashMessengerControllerPlugin->addMessage('FooMessage');
+
+ /* @var \Application\View\Helper\FlashMessenger $flashMessengerViewHelper */
+ $flashMessengerViewHelper = $serviceManager->get('ViewHelperManager')->get('FlashMessenger');
+
+ $this->assertEquals(
+ 'MessageFooMessage
',
+ $flashMessengerViewHelper->renderCurrent('FooBar')
+ );
+ }
+}
diff --git a/module/Application/view/error/404.phtml b/module/Application/view/error/404.phtml
index a0faa579..5180168e 100644
--- a/module/Application/view/error/404.phtml
+++ b/module/Application/view/error/404.phtml
@@ -1,6 +1,5 @@
A 404 error occurred
-message ?>
-
+
reason) && $this->reason): ?>
-
+
controller) && $this->controller): ?>
diff --git a/module/Application/view/error/index.phtml b/module/Application/view/error/index.phtml
index f1c5ab76..cdcd879d 100644
--- a/module/Application/view/error/index.phtml
+++ b/module/Application/view/error/index.phtml
@@ -1,8 +1,21 @@
-An error occurred
-message ?>
+
+Oops. Something went wrong.
+
+
Error
+
+ exception instanceof Exception\ViewableUserException && $this->exception->getPublicMessage()): ?>
+ escapeHtml($this->exception->getPublicMessage()); ?>
+
+ Sorry, we got no more information
+
+
+
display_exceptions) && $this->display_exceptions): ?>
- exception) && $this->exception instanceof Exception): ?>
+ exception) && $this->exception instanceof \Exception): ?>
Additional information:
exception); ?>
diff --git a/module/User/src/User/GitHub/LoginListener.php b/module/User/src/User/GitHub/LoginListener.php
index 33ac330b..ea55c2c4 100644
--- a/module/User/src/User/GitHub/LoginListener.php
+++ b/module/User/src/User/GitHub/LoginListener.php
@@ -16,7 +16,7 @@ final class LoginListener implements SharedListenerAggregateInterface
protected $listeners = [];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function attachShared(SharedEventManagerInterface $events)
{
@@ -28,7 +28,7 @@ public function attachShared(SharedEventManagerInterface $events)
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function detachShared(SharedEventManagerInterface $events)
{
diff --git a/module/User/view/zfc-user/user/index.phtml b/module/User/view/zfc-user/user/index.phtml
index 0b8f73b7..8c4bd425 100644
--- a/module/User/view/zfc-user/user/index.phtml
+++ b/module/User/view/zfc-user/user/index.phtml
@@ -10,9 +10,7 @@
- flashMessenger()->getMessages() as $message): ?>
- escapeHtml($message); ?>
-
+ flashMessenger()->render(); ?>
- Registered Modules
diff --git a/module/ZfModule/src/ZfModule/Controller/Exception/InvalidDataException.php b/module/ZfModule/src/ZfModule/Controller/Exception/InvalidDataException.php
new file mode 100644
index 00000000..4de7923c
--- /dev/null
+++ b/module/ZfModule/src/ZfModule/Controller/Exception/InvalidDataException.php
@@ -0,0 +1,24 @@
+toString()),
+ (string) $publicMessage
+ );
+ }
+}
diff --git a/module/ZfModule/src/ZfModule/Controller/Exception/RepositoryException.php b/module/ZfModule/src/ZfModule/Controller/Exception/RepositoryException.php
new file mode 100644
index 00000000..9b768a8b
--- /dev/null
+++ b/module/ZfModule/src/ZfModule/Controller/Exception/RepositoryException.php
@@ -0,0 +1,75 @@
+getRequest();
if (!$request->isPost()) {
- throw new Exception\UnexpectedValueException('Something went wrong with the post values of the request...');
+ throw Exception\InvalidDataException::fromInvalidRequest(
+ 'Something went wrong with the post values of the request...',
+ $this->getRequest()
+ );
}
$postParams = $request->getPost();
@@ -168,36 +173,40 @@ public function addAction()
$repository = $this->repositoryRetriever->getUserRepositoryMetadata($owner, $repo);
if (!($repository instanceof \stdClass)) {
- throw new Exception\RuntimeException(
+ throw Exception\RepositoryException::fromNotFoundRepository(
'Not able to fetch the repository from GitHub due to an unknown error.',
- Http\Response::STATUS_CODE_500
+ $owner,
+ $repo
);
}
if ($repository->fork || !$repository->permissions->push) {
- throw new Exception\UnexpectedValueException(
- 'You have no permission to add this module. The reason might be that you are ' .
- 'neither the owner nor a collaborator of this repository.',
- Http\Response::STATUS_CODE_403
+ throw Exception\RepositoryException::fromInsufficientPermissions(
+ 'You have no permission to add this module. The reason might be that you are neither the owner nor a collaborator of this repository.',
+ $repository->full_name,
+ ['pushAccess', 'noFork']
);
}
if (!$this->moduleService->isModule($repository)) {
- throw new Exception\UnexpectedValueException(
+ throw Exception\RepositoryException::fromNonModuleRepository(
$repository->name . ' is not a Zend Framework Module',
- Http\Response::STATUS_CODE_403
+ $repository->full_name
);
}
$module = $this->moduleService->register($repository);
- $this->flashMessenger()->addMessage($module->getName() . ' has been added to ZF Modules');
+ $this->flashMessenger()->addSuccessMessage($module->getName() . ' has been added to ZF Modules');
return $this->redirect()->toRoute('zfcuser');
}
/**
- * @throws Exception\UnexpectedValueException
+ * Removes a Module
+ *
* @return Http\Response
+ * @throws Exception\InvalidDataException
+ * @throws Exception\RepositoryException
*/
public function removeAction()
{
@@ -207,7 +216,10 @@ public function removeAction()
$request = $this->getRequest();
if (!$request->isPost()) {
- throw new Exception\UnexpectedValueException('Something went wrong with the post values of the request...');
+ throw Exception\InvalidDataException::fromInvalidRequest(
+ 'Something went wrong with the post values of the request...',
+ $request
+ );
}
$postParams = $request->getPost();
@@ -218,31 +230,32 @@ public function removeAction()
$repository = $this->repositoryRetriever->getUserRepositoryMetadata($owner, $repo);
if (!$repository instanceof \stdClass) {
- throw new Exception\RuntimeException(
+ throw Exception\RepositoryException::fromNotFoundRepository(
'Not able to fetch the repository from GitHub due to an unknown error.',
- Http\Response::STATUS_CODE_500
+ $owner,
+ $repo
);
}
if ($repository->fork || !$repository->permissions->push) {
- throw new Exception\UnexpectedValueException(
- 'You have no permission to remove this module. The reason might be that you are ' .
- 'neither the owner nor a collaborator of this repository.',
- Http\Response::STATUS_CODE_403
+ throw Exception\RepositoryException::fromInsufficientPermissions(
+ 'You have no permission to remove this module. The reason might be that you are neither the owner nor a collaborator of this repository.',
+ $repository->full_name,
+ ['pushAccess', 'noFork']
);
}
$module = $this->moduleMapper->findByUrl($repository->html_url);
if (!$module) {
- throw new Exception\UnexpectedValueException(
+ throw Exception\RepositoryException::fromNotFoundRepositoryUrl(
$repository->name . ' was not found',
- Http\Response::STATUS_CODE_403
+ $repository->html_url
);
}
$this->moduleMapper->delete($module);
- $this->flashMessenger()->addMessage($repository->name . ' has been removed from ZF Modules');
+ $this->flashMessenger()->addSuccessMessage($repository->name . ' has been removed from ZF Modules');
return $this->redirect()->toRoute('zfcuser');
}
diff --git a/module/ZfModule/test/ZfModuleTest/Exception/InvalidDataExceptionTest.php b/module/ZfModule/test/ZfModuleTest/Exception/InvalidDataExceptionTest.php
new file mode 100644
index 00000000..4fc46d1a
--- /dev/null
+++ b/module/ZfModule/test/ZfModuleTest/Exception/InvalidDataExceptionTest.php
@@ -0,0 +1,29 @@
+getMock(Http\Request::class);
+ $requestMock
+ ->expects($this->once())
+ ->method('toString')
+ ->willReturn('fooRequestAsString')
+ ;
+
+ $exception = Exception\InvalidDataException::fromInvalidRequest(
+ 'fooPublicMessage',
+ $requestMock
+ );
+
+ $this->assertInstanceOf(Exception\InvalidDataException::class, $exception);
+ $this->assertSame('fooPublicMessage', $exception->getPublicMessage());
+ $this->assertSame('Invalid Request received [fooRequestAsString]', $exception->getMessage());
+ }
+}
diff --git a/module/ZfModule/test/ZfModuleTest/Exception/RepositoryExceptionTest.php b/module/ZfModule/test/ZfModuleTest/Exception/RepositoryExceptionTest.php
new file mode 100644
index 00000000..bf18c986
--- /dev/null
+++ b/module/ZfModule/test/ZfModuleTest/Exception/RepositoryExceptionTest.php
@@ -0,0 +1,64 @@
+assertInstanceOf(Exception\RepositoryException::class, $exception);
+ $this->assertSame('fooPublicMessage', $exception->getPublicMessage());
+ $this->assertSame('Invalid Repository requested [fooOwner/fooName]', $exception->getMessage());
+ $this->assertSame(Http\Response::STATUS_CODE_404, $exception->getCode());
+ }
+
+ public function testCreateExceptionFromNotFoundRepositoryUrl()
+ {
+ $exception = Exception\RepositoryException::fromNotFoundRepositoryUrl(
+ 'fooPublicMessage',
+ 'fooRepositoryUrl'
+ );
+
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
+ $this->assertSame('fooPublicMessage', $exception->getPublicMessage());
+ $this->assertSame('Invalid Repository from URL requested [fooRepositoryUrl]', $exception->getMessage());
+ $this->assertSame(Http\Response::STATUS_CODE_404, $exception->getCode());
+ }
+
+ public function testCreateExceptionFromInsufficientPermissions()
+ {
+ $exception = Exception\RepositoryException::fromInsufficientPermissions(
+ 'fooPublicMessage',
+ 'foo/name',
+ ['fooPermission', 'barPermission']
+ );
+
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
+ $this->assertSame('fooPublicMessage', $exception->getPublicMessage());
+ $this->assertSame('Invalid Repository permission [foo/name] required [fooPermission,barPermission]', $exception->getMessage());
+ $this->assertSame(Http\Response::STATUS_CODE_403, $exception->getCode());
+ }
+
+ public function testCreateExceptionFromNonModuleRepository()
+ {
+ $exception = Exception\RepositoryException::fromNonModuleRepository(
+ 'fooPublicMessage',
+ 'foo/name'
+ );
+
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
+ $this->assertSame('fooPublicMessage', $exception->getPublicMessage());
+ $this->assertSame('Invalid Repository - No ZF Module [foo/name]', $exception->getMessage());
+ $this->assertSame(Http\Response::STATUS_CODE_403, $exception->getCode());
+ }
+}
diff --git a/module/ZfModule/test/ZfModuleTest/Integration/Controller/ModuleControllerTest.php b/module/ZfModule/test/ZfModuleTest/Integration/Controller/ModuleControllerTest.php
index 989ec653..d646a01e 100644
--- a/module/ZfModule/test/ZfModuleTest/Integration/Controller/ModuleControllerTest.php
+++ b/module/ZfModule/test/ZfModuleTest/Integration/Controller/ModuleControllerTest.php
@@ -6,7 +6,6 @@
use ApplicationTest\Integration\Util\AuthenticationTrait;
use ApplicationTest\Integration\Util\Bootstrap;
use EdpGithub\Collection;
-use Exception;
use PHPUnit_Framework_MockObject_MockObject;
use stdClass;
use Zend\Http;
@@ -15,6 +14,7 @@
use Zend\View;
use ZfcUser\Entity\User;
use ZfModule\Controller;
+use ZfModule\Controller\Exception;
use ZfModule\Entity;
use ZfModule\Mapper;
use ZfModule\Service;
@@ -205,11 +205,11 @@ public function testListActionFetches100MostRecentlyUpdatedRepositoriesWhenNoOwn
->with(
$this->equalTo(null),
$this->equalTo([
- 'per_page' => 100,
- 'sort' => 'updated',
- 'direction' => 'desc',
- ]
- ))
+ 'per_page' => 100,
+ 'sort' => 'updated',
+ 'direction' => 'desc',
+ ]
+ ))
->willReturn($repositoryCollection)
;
@@ -249,11 +249,11 @@ public function testListActionDoesNotMatchOnInvalidVendor($vendor)
->with(
$this->equalTo($vendor),
$this->equalTo([
- 'per_page' => 100,
- 'sort' => 'updated',
- 'direction' => 'desc',
- ]
- ))
+ 'per_page' => 100,
+ 'sort' => 'updated',
+ 'direction' => 'desc',
+ ]
+ ))
->willReturn($repositoryCollection)
;
@@ -445,7 +445,7 @@ public function testAddActionRedirectsIfNotAuthenticated()
*
* @param string $method
*/
- public function testAddActionThrowsUnexpectedValueExceptionIfNotPostedTo($method)
+ public function testAddActionThrowsInvalidDataExceptionIfNotPostedTo($method)
{
$this->authenticatedAs(new User());
@@ -461,11 +461,11 @@ public function testAddActionThrowsUnexpectedValueExceptionIfNotPostedTo($method
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\InvalidDataException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\UnexpectedValueException::class, $exception);
- $this->assertSame('Something went wrong with the post values of the request...', $exception->getMessage());
+ $this->assertInstanceOf(Exception\InvalidDataException::class, $exception);
+ $this->assertSame('Something went wrong with the post values of the request...', $exception->getPublicMessage());
}
/**
@@ -486,7 +486,7 @@ public function providerNotPost()
];
}
- public function testAddActionThrowsRuntimeExceptionIfUnableToFetchRepositoryMetaData()
+ public function testAddActionThrowsRepositoryExceptionIfUnableToFetchRepositoryMetaData()
{
$this->authenticatedAs(new User());
@@ -532,13 +532,13 @@ public function testAddActionThrowsRuntimeExceptionIfUnableToFetchRepositoryMeta
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\RepositoryException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\RuntimeException::class, $exception);
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
$this->assertSame(
'Not able to fetch the repository from GitHub due to an unknown error.',
- $exception->getMessage()
+ $exception->getPublicMessage()
);
}
@@ -547,7 +547,7 @@ public function testAddActionThrowsRuntimeExceptionIfUnableToFetchRepositoryMeta
*
* @param stdClass $repository
*/
- public function testAddActionThrowsUnexpectedValueExceptionWhenRepositoryHasInsufficientPrivileges($repository)
+ public function testAddActionThrowsRepositoryExceptionWhenRepositoryHasInsufficientPrivileges($repository)
{
$this->authenticatedAs(new User());
@@ -593,14 +593,14 @@ public function testAddActionThrowsUnexpectedValueExceptionWhenRepositoryHasInsu
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\RepositoryException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\UnexpectedValueException::class, $exception);
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
$this->assertSame(
'You have no permission to add this module. The reason might be that you are ' .
'neither the owner nor a collaborator of this repository.',
- $exception->getMessage()
+ $exception->getPublicMessage()
);
}
@@ -618,7 +618,7 @@ public function providerRepositoryWithInsufficientPrivileges()
];
}
- public function testAddActionThrowsUnexpectedValueExceptionWhenRepositoryIsNotAModule()
+ public function testAddActionThrowsRepositoryExceptionWhenRepositoryIsNotAModule()
{
$this->authenticatedAs(new User());
@@ -682,16 +682,16 @@ public function testAddActionThrowsUnexpectedValueExceptionWhenRepositoryIsNotAM
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\RepositoryException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\UnexpectedValueException::class, $exception);
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
$this->assertSame(
sprintf(
'%s is not a Zend Framework Module',
$nonModule->name
),
- $exception->getMessage()
+ $exception->getPublicMessage()
);
}
@@ -784,7 +784,7 @@ public function testRemoveActionRedirectsIfNotAuthenticated()
*
* @param string $method
*/
- public function testRemoveActionThrowsUnexpectedValueExceptionIfNotPostedTo($method)
+ public function testRemoveActionThrowsInvalidDataExceptionIfNotPostedTo($method)
{
$this->authenticatedAs(new User());
@@ -800,14 +800,14 @@ public function testRemoveActionThrowsUnexpectedValueExceptionIfNotPostedTo($met
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\InvalidDataException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\UnexpectedValueException::class, $exception);
- $this->assertSame('Something went wrong with the post values of the request...', $exception->getMessage());
+ $this->assertInstanceOf(Exception\InvalidDataException::class, $exception);
+ $this->assertSame('Something went wrong with the post values of the request...', $exception->getPublicMessage());
}
- public function testRemoveActionThrowsRuntimeExceptionIfUnableToFetchRepositoryMetaData()
+ public function testRemoveActionThrowsRepositoryExceptionIfUnableToFetchRepositoryMetaData()
{
$this->authenticatedAs(new User());
@@ -853,13 +853,13 @@ public function testRemoveActionThrowsRuntimeExceptionIfUnableToFetchRepositoryM
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\RepositoryException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\RuntimeException::class, $exception);
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
$this->assertSame(
'Not able to fetch the repository from GitHub due to an unknown error.',
- $exception->getMessage()
+ $exception->getPublicMessage()
);
}
@@ -868,7 +868,7 @@ public function testRemoveActionThrowsRuntimeExceptionIfUnableToFetchRepositoryM
*
* @param stdClass $repository
*/
- public function testRemoveActionThrowsUnexpectedValueExceptionWhenRepositoryHasInsufficientPrivileges($repository)
+ public function testRemoveActionThrowsRepositoryExceptionWhenRepositoryHasInsufficientPrivileges($repository)
{
$this->authenticatedAs(new User());
@@ -914,18 +914,18 @@ public function testRemoveActionThrowsUnexpectedValueExceptionWhenRepositoryHasI
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\RepositoryException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\UnexpectedValueException::class, $exception);
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
$this->assertSame(
'You have no permission to remove this module. The reason might be that you are ' .
'neither the owner nor a collaborator of this repository.',
- $exception->getMessage()
+ $exception->getPublicMessage()
);
}
- public function testRemoveActionThrowsUnexpectedValueExceptionWhenRepositoryNotPreviouslyRegistered()
+ public function testRemoveActionThrowsRepositoryExceptionWhenRepositoryNotPreviouslyRegistered()
{
$this->authenticatedAs(new User());
@@ -989,16 +989,16 @@ public function testRemoveActionThrowsUnexpectedValueExceptionWhenRepositoryNotP
/* @var View\Model\ViewModel $result */
$result = $this->getApplication()->getMvcEvent()->getResult();
- /* @var Exception $exception */
+ /* @var Exception\RepositoryException $exception */
$exception = $result->getVariable('exception');
- $this->assertInstanceOf(Controller\Exception\UnexpectedValueException::class, $exception);
+ $this->assertInstanceOf(Exception\RepositoryException::class, $exception);
$this->assertSame(
sprintf(
'%s was not found',
$unregisteredModule->name
),
- $exception->getMessage()
+ $exception->getPublicMessage()
);
}
@@ -1324,6 +1324,7 @@ private function nonModule()
$repository = $this->validModule();
$repository->name = 'non-module';
+ $repository->full_name = 'foo/non-module';
return $repository;
}
@@ -1336,6 +1337,7 @@ private function forkedModule()
$repository = $this->validModule();
$repository->name = 'forked-module';
+ $repository->full_name = 'foo/forked-module';
$repository->fork = true;
return $repository;
@@ -1349,6 +1351,7 @@ private function moduleWithoutPushPermissions()
$repository = $this->validModule();
$repository->name = 'module-without-push-permissions';
+ $repository->full_name = 'foo/module-without-push-permissions';
$repository->permissions->push = false;
return $repository;