Skip to content
This repository was archived by the owner on May 1, 2019. It is now read-only.

Commit 86d56b3

Browse files
author
Gianluca Arbezzano
committed
Refactoring code's style and user view header
1 parent 197eafc commit 86d56b3

File tree

5 files changed

+62
-14
lines changed

5 files changed

+62
-14
lines changed

module/User/view/user/helper/new-users.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="col-md-12">
1111
<?php endif; ?>
1212
<div class="col-md-3">
13-
<a href="<?php echo $this->url("modules-for-user", ["owner" => $user->getUserName()]); ?>" data-delay="0" rel="tooltip" title="<?php echo $this->escapeHtmlAttr($user->getUserName()); ?>" class="thumbnail">
13+
<a href="<?php echo $this->url('modules-for-user', ['owner' => $user->getUserName()]); ?>" data-delay="0" rel="tooltip" title="<?php echo $this->escapeHtmlAttr($user->getUserName()); ?>" class="thumbnail">
1414
<img src="<?php echo $this->escapeHtmlAttr($user->getPhotoUrl()) ?>" alt="<?php echo $this->escapeHtmlAttr($user->getUsername()) ?>" class="img-responsive">
1515
</a>
1616
</div>

module/ZfModule/src/ZfModule/Controller/UserController.php

+9-11
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,23 @@ class UserController extends AbstractActionController
1515
/**
1616
* @param Mapper\Module $moduleMapper
1717
*/
18-
public function __construct(
19-
Mapper\Module $moduleMapper
20-
) {
18+
public function __construct(Mapper\Module $moduleMapper)
19+
{
2120
$this->moduleMapper = $moduleMapper;
2221
}
2322

2423
public function modulesForUserAction()
2524
{
26-
$query = $this->params()->fromQuery('query', null);
27-
$page = (int) $this->params()->fromQuery('page', 1);
28-
$owner = $this->params()->fromRoute('owner');
25+
$params = $this->params();
26+
$query = $params->fromQuery('query', null);
27+
$page = (int) $params->fromQuery('page', 1);
28+
$owner = $params->fromRoute('owner');
2929

30-
$modules = $this->moduleMapper->pagination($page, 10, $owner, 'created_at', "DESC");
30+
$modules = $this->moduleMapper->pagination($page, 10, $owner, 'created_at', 'DESC');
3131

32-
$viewModel = new ViewModel([
32+
return new ViewModel([
3333
'modules' => $modules,
3434
'query' => $query,
35-
]);
36-
37-
return $viewModel;
35+
]);
3836
}
3937
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace ZfModuleTest\Integration\Controller;
4+
5+
use ApplicationTest\Integration\Util\Bootstrap;
6+
use Zend\Paginator;
7+
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
8+
use ZfModule\Controller;
9+
use ZfModule\Mapper;
10+
11+
class UserControllerTest extends AbstractHttpControllerTestCase
12+
{
13+
protected function setUp()
14+
{
15+
parent::setUp();
16+
17+
$this->setApplicationConfig(Bootstrap::getConfig());
18+
}
19+
20+
public function testUserPageCanBeAccessed()
21+
{
22+
$moduleMapper = $this->getMockBuilder(Mapper\Module::class)->getMock();
23+
24+
$moduleMapper
25+
->expects($this->once())
26+
->method('pagination')
27+
->with(
28+
$this->equalTo(1),
29+
$this->equalTo(10),
30+
$this->equalTo("gianarb"),
31+
$this->equalTo('created_at'),
32+
$this->equalTo('DESC')
33+
)
34+
->willReturn(new Paginator\Paginator(new Paginator\Adapter\Null()))
35+
;
36+
37+
$this->getApplicationServiceLocator()
38+
->setAllowOverride(true)
39+
->setService(
40+
Mapper\Module::class,
41+
$moduleMapper
42+
)
43+
;
44+
45+
$this->dispatch('/user/gianarb');
46+
47+
$this->assertControllerName(Controller\UserController::class);
48+
$this->assertActionName('modulesForUser');
49+
}
50+
}

module/ZfModule/view/zf-module/index/view.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php $this->headTitle($this->escapeHtmlAttr($module) . ' module by ' . $this->escapeHtmlAttr($vendor)); ?>
22
<?php $this->headMeta()->appendName('description', $this->escapeHtmlAttr($repository->description)); ?>
33

4-
<h3><a href="<?php echo $this->url("modules-for-user", ["owner" => $vendor]); ?>"><?php echo $this->escapeHtml($vendor); ?></a> / <?php echo $this->escapeHtml($module); ?> </h3>
4+
<h3><a href="<?php echo $this->url('modules-for-user', ['owner' => $vendor]); ?>"><?php echo $this->escapeHtml($vendor); ?></a> / <?php echo $this->escapeHtml($module); ?> </h3>
55

66
<div class="row">
77
<div class="col-md-8">

module/ZfModule/view/zf-module/user/modules-for-user.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php $this->layout()->withLargeHeader = true; ?>
1+
<?php $this->layout()->withLargeHeader = false; ?>
22

33
<div class="col-xs-12 col-md-8">
44
<?php if (count($this->modules) >= 1): ?>

0 commit comments

Comments
 (0)