Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
feat: Back to conversations links (#75)
Browse files Browse the repository at this point in the history
* feat: Back to conversations links

* fix: Controller unit test
  • Loading branch information
wadedvsa authored Mar 5, 2024
1 parent 859fbe3 commit 9a81483
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/Olcs/src/Controller/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function addAction(): ViewModel

$view = new ViewModel();
$view->setVariable('form', $form);
$view->setVariable('backUrl', $this->url()->fromRoute('conversations'));
$view->setTemplate('messages-new');

return $view;
Expand Down Expand Up @@ -203,6 +204,7 @@ public function viewAction()
'openReply' => false,
'canUploadFiles' => $canUploadFiles,
'subject' => $subject,
'backUrl' => $this->url()->fromRoute('conversations'),
],
);
$view->setTemplate('messages-view');
Expand Down
8 changes: 8 additions & 0 deletions module/Olcs/view/messages-new.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ echo $this->partial(
->setPartial('partials/tabs-nav');
?>

<div class="govuk-footer__heading">
<a href="<?php echo $this->backUrl; ?>" class="govuk-back-link">
<?php echo $this->translate('Back to conversations'); ?>
</a>
</div>

<h2><?php echo $this->translate('Start a new conversation'); ?></h2>

<div>
<?php
echo $this->formErrors($this->form);
Expand Down
6 changes: 6 additions & 0 deletions module/Olcs/view/messages-view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ echo $this->partial(
->setPartial('partials/tabs-nav');
?>

<div class="govuk-footer__heading">
<a href="<?php echo $this->backUrl; ?>" class="govuk-back-link">
<?php echo $this->translate('Back to conversations'); ?>
</a>
</div>

<h3><?php echo $this->subject; ?></h3>

<?php if ($this->canReply): ?>
Expand Down
11 changes: 11 additions & 0 deletions test/Olcs/src/Controller/ConversationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Laminas\Http\Response as HttpResponse;
use Laminas\Mvc\Controller\Plugin\Params;
use Dvsa\Olcs\Transfer\Command\Messaging\Message\Create as CreateMessageCommand;
use Laminas\Mvc\Controller\Plugin\Url;
use Laminas\Navigation\Navigation;
use Laminas\View\Model\ViewModel;
use Mockery as m;
Expand Down Expand Up @@ -136,14 +137,24 @@ public function testViewAction(): void
],
);

$mockUrl = m::mock(Url::class);
$mockUrl->shouldReceive('fromRoute')
->once()
->with('conversations');

$this->sut->shouldReceive('params')
->andReturn($this->mockParams);
$this->sut->shouldReceive('plugin')
->with('handleQuery')
->once()
->andReturn($mockHandleQuery);
$this->sut->shouldReceive('plugin')
->with('currentUser')
->andReturn($mockUser);
$this->sut->shouldReceive('plugin')
->with('url')
->once()
->andReturn($mockUrl);

$table = '<table/>';

Expand Down

0 comments on commit 9a81483

Please sign in to comment.