pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/REBELinBLUE/deployer/commit/b9dd4c60d20d80b19456ff2ea3467558f55ea906

3.css" /> Unit & integrations test for #332 · REBELinBLUE/deployer@b9dd4c6 · GitHub
Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit b9dd4c6

Browse files
Claudio PintoClaudio Pinto
authored andcommitted
Unit & integrations test for #332
- All test run
1 parent e203b8f commit b9dd4c6

20 files changed

+287
-77
lines changed

app/Events/Observers/ServerTemplateObserver.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
* Created by PhpStorm.
44
* User: claudiopinto
55
* Date: 11/04/2017
6-
* Time: 22:59
6+
* Time: 22:59.
77
*/
88

99
namespace REBELinBLUE\Deployer\Events\Observers;
1010

11-
1211
use REBELinBLUE\Deployer\ServerTemplate;
1312

13+
/**
14+
* Class ServerTemplateObserver.
15+
*/
1416
class ServerTemplateObserver
1517
{
16-
1718
/**
18-
* Called when model is being created
19+
* Called when model is being created.
1920
* @param ServerTemplate $template
2021
*/
2122
public function creating(ServerTemplate $template)
@@ -40,4 +41,4 @@ private function setDefaultPort(ServerTemplate $template)
4041
$template->port = 22;
4142
}
4243
}
43-
}
44+
}

app/Http/Controllers/Admin/ServerTemplateController.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
use Illuminate\Contracts\Routing\ResponseFactory;
66
use Illuminate\Contracts\Translation\Translator;
77
use Illuminate\Http\Request;
8+
use Illuminate\View\Factory as ViewFactory;
89
use REBELinBLUE\Deployer\Http\Controllers\Controller;
910
use REBELinBLUE\Deployer\Http\Requests\StoreServerTemplateRequest;
1011
use REBELinBLUE\Deployer\Repositories\Contracts\ServerTemplateRepositoryInterface;
11-
use Illuminate\View\Factory as ViewFactory;
12+
use Symfony\Component\HttpFoundation\Response;
1213

14+
/**
15+
* Class ServerTemplateController.
16+
*/
1317
class ServerTemplateController extends Controller
1418
{
19+
/**
20+
* @var ServerTemplateRepositoryInterface
21+
*/
22+
private $repository;
1523

1624
/**
1725
* ServerTemplateController constructor.
@@ -33,22 +41,35 @@ public function __construct(ServerTemplateRepositoryInterface $repository)
3341
public function index(ViewFactory $view, Request $request, Translator $translator)
3442
{
3543
return $view->make('admin.servers.listing', [
36-
'servers' => $this->repository->getAll(),
44+
'servers' => $this->repository->getAll(),
3745
'is_secure' => $request->isSecure(),
38-
'title' => $translator->trans('servers.manage')
46+
'title' => $translator->trans('servers.manage'),
3947
]);
4048
}
4149

50+
/**
51+
* @param StoreServerTemplateRequest $request
52+
* @param ResponseFactory $response
53+
*
54+
* @return \Illuminate\Http\JsonResponse
55+
*/
4256
public function store(StoreServerTemplateRequest $request, ResponseFactory $response)
4357
{
4458
return $response->json($this->repository->create($request->only([
4559
'name',
4660
'ip_address',
4761
'port',
48-
])));
62+
])), Response::HTTP_CREATED);
4963
}
5064

51-
public function update($server_template_id, StoreServerTemplateRequest $request) {
65+
/**
66+
* @param int $server_template_id
67+
* @param StoreServerTemplateRequest $request
68+
*
69+
* @return \Illuminate\Database\Eloquent\Model
70+
*/
71+
public function update($server_template_id, StoreServerTemplateRequest $request)
72+
{
5273
return $this->repository->updateById($request->only([
5374
'name',
5475
'ip_address',

app/Http/Controllers/DeploymentController.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,25 @@ public function project($project_id)
9292
});
9393

9494
return $this->view->make('projects.details', [
95-
'title' => $project->name,
96-
'deployments' => $this->deploymentRepository->getLatest($project_id),
97-
'today' => $this->deploymentRepository->getTodayCount($project_id),
98-
'last_week' => $this->deploymentRepository->getLastWeekCount($project_id),
99-
'project' => $project,
100-
'servers' => $project->servers,
95+
'title' => $project->name,
96+
'deployments' => $this->deploymentRepository->getLatest($project_id),
97+
'today' => $this->deploymentRepository->getTodayCount($project_id),
98+
'last_week' => $this->deploymentRepository->getLastWeekCount($project_id),
99+
'project' => $project,
100+
'servers' => $project->servers,
101101
'server_templates' => ServerTemplate::all(),
102-
'channels' => $project->channels,
103-
'heartbeats' => $project->heartbeats,
104-
'sharedFiles' => $project->sharedFiles,
105-
'configFiles' => $project->configFiles,
106-
'checkUrls' => $project->checkUrls,
107-
'variables' => $project->variables,
108-
'optional' => $optional,
109-
'tags' => $project->tags,
110-
'branches' => $project->branches,
111-
'route' => 'commands.step',
112-
'target_type' => 'project',
113-
'target_id' => $project->id,
102+
'channels' => $project->channels,
103+
'heartbeats' => $project->heartbeats,
104+
'sharedFiles' => $project->sharedFiles,
105+
'configFiles' => $project->configFiles,
106+
'checkUrls' => $project->checkUrls,
107+
'variables' => $project->variables,
108+
'optional' => $optional,
109+
'tags' => $project->tags,
110+
'branches' => $project->branches,
111+
'route' => 'commands.step',
112+
'target_type' => 'project',
113+
'target_id' => $project->id,
114114
]);
115115
}
116116

app/Http/Requests/StoreServerTemplateRequest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace REBELinBLUE\Deployer\Http\Requests;
44

5+
/**
6+
* Class StoreServerTemplateRequest.
7+
*/
58
class StoreServerTemplateRequest extends Request
69
{
7-
810
/**
911
* Get the validation rules that apply to the request.
1012
*

app/Providers/AppServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private function registerDependencies()
124124
}
125125

126126
/**
127-
* Registers additional information to show in the sysinfo
127+
* Registers additional information to show in the sysinfo.
128128
*/
129129
private function registerSystemInfo()
130130
{
@@ -133,7 +133,7 @@ private function registerSystemInfo()
133133
$decomposer->addServerStats([
134134
'Curl Ext' => extension_loaded('curl'),
135135
'GD Ext' => extension_loaded('gd'),
136-
'JSON Ext' => extension_loaded('json')
136+
'JSON Ext' => extension_loaded('json'),
137137
]);
138138

139139
$decomposer->addExtraStats([

app/Providers/RepositoryServiceProvider.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@
4747
class RepositoryServiceProvider extends ServiceProvider
4848
{
4949
protected $repositories = [
50-
ChannelRepositoryInterface::class => EloquentChannelRepository::class,
51-
CheckUrlRepositoryInterface::class => EloquentCheckUrlRepository::class,
52-
CommandRepositoryInterface::class => EloquentCommandRepository::class,
53-
ConfigFileRepositoryInterface::class => EloquentConfigFileRepository::class,
54-
DeploymentRepositoryInterface::class => EloquentDeploymentRepository::class,
55-
DeployStepRepositoryInterface::class => EloquentDeployStepRepository::class,
56-
GroupRepositoryInterface::class => EloquentGroupRepository::class,
57-
HeartbeatRepositoryInterface::class => EloquentHeartbeatRepository::class,
58-
NotificationRepositoryInterface::class => EloquentNotificationRepository::class,
59-
ProjectRepositoryInterface::class => EloquentProjectRepository::class,
60-
RefRepositoryInterface::class => EloquentRefRepository::class,
61-
ServerLogRepositoryInterface::class => EloquentServerLogRepository::class,
62-
ServerRepositoryInterface::class => EloquentServerRepository::class,
63-
SharedFileRepositoryInterface::class => EloquentSharedFileRepository::class,
64-
TemplateRepositoryInterface::class => EloquentTemplateRepository::class,
65-
UserRepositoryInterface::class => EloquentUserRepository::class,
66-
VariableRepositoryInterface::class => EloquentVariableRepository::class,
50+
ChannelRepositoryInterface::class => EloquentChannelRepository::class,
51+
CheckUrlRepositoryInterface::class => EloquentCheckUrlRepository::class,
52+
CommandRepositoryInterface::class => EloquentCommandRepository::class,
53+
ConfigFileRepositoryInterface::class => EloquentConfigFileRepository::class,
54+
DeploymentRepositoryInterface::class => EloquentDeploymentRepository::class,
55+
DeployStepRepositoryInterface::class => EloquentDeployStepRepository::class,
56+
GroupRepositoryInterface::class => EloquentGroupRepository::class,
57+
HeartbeatRepositoryInterface::class => EloquentHeartbeatRepository::class,
58+
NotificationRepositoryInterface::class => EloquentNotificationRepository::class,
59+
ProjectRepositoryInterface::class => EloquentProjectRepository::class,
60+
RefRepositoryInterface::class => EloquentRefRepository::class,
61+
ServerLogRepositoryInterface::class => EloquentServerLogRepository::class,
62+
ServerRepositoryInterface::class => EloquentServerRepository::class,
63+
SharedFileRepositoryInterface::class => EloquentSharedFileRepository::class,
64+
TemplateRepositoryInterface::class => EloquentTemplateRepository::class,
65+
UserRepositoryInterface::class => EloquentUserRepository::class,
66+
VariableRepositoryInterface::class => EloquentVariableRepository::class,
6767
ServerTemplateRepositoryInterface::class => EloquentServerTemplateRepository::class,
6868
];
6969

app/Repositories/EloquentServerTemplateRepository.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
namespace REBELinBLUE\Deployer\Repositories;
44

55
use REBELinBLUE\Deployer\Repositories\Contracts\ServerTemplateRepositoryInterface;
6+
use REBELinBLUE\Deployer\Server;
67
use REBELinBLUE\Deployer\ServerTemplate;
78

9+
/**
10+
* Class EloquentServerTemplateRepository.
11+
*/
812
class EloquentServerTemplateRepository extends EloquentRepository implements ServerTemplateRepositoryInterface
913
{
10-
11-
function __construct(ServerTemplate $model)
14+
/**
15+
* EloquentServerTemplateRepository constructor.
16+
*
17+
* @param ServerTemplate $model
18+
*/
19+
public function __construct(ServerTemplate $model)
1220
{
1321
$this->model = $model;
1422
}
@@ -20,6 +28,7 @@ function __construct(ServerTemplate $model)
2028
*/
2129
public function queryByName($name)
2230
{
23-
// TODO: Implement queryByName() method.
31+
/** @var ServerTemplate $model */
32+
return $this->model->where('name', '=', $name);
2433
}
2534
}

app/ServerTemplate.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
use Illuminate\Notifications\Notifiable;
88
use REBELinBLUE\Deployer\Traits\BroadcastChanges;
99

10+
/**
11+
* Class ServerTemplate.
12+
*/
1013
class ServerTemplate extends Model
1114
{
12-
1315
use BroadcastChanges, SoftDeletes, Notifiable;
1416
/**
1517
* The attributes that are mass assignable.
1618
*
1719
* @var array
1820
*/
19-
protected $fillable = ['name', 'ip_address', 'port' ];
21+
protected $fillable = ['name', 'ip_address', 'port'];
2022

2123
/**
2224
* The attributes excluded from the model's JSON form.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use Faker\Generator;
4+
use REBELinBLUE\Deployer\ServerTemplate;
5+
6+
/* @var \Illuminate\Database\Eloquent\Factory $factory */
7+
$factory->define(ServerTemplate::class, function (Generator $faker) {
8+
return [
9+
'name' => $faker->words,
10+
'ip_address' => $faker->ipv4,
11+
'port' => 22
12+
];
13+
});

database/migrations/2017_04_11_221151_add_server_template_table.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<?php
22

3-
use Illuminate\Support\Facades\Schema;
4-
use Illuminate\Database\Schema\Blueprint;
53
use Illuminate\Database\Migrations\Migration;
6-
use REBELinBLUE\Deployer\Server;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
76

87
class AddServerTemplateTable extends Migration
98
{
109
/**
1110
* Run the migrations.
12-
*
13-
* @return void
1411
*/
1512
public function up()
1613
{
@@ -26,8 +23,6 @@ public function up()
2623

2724
/**
2825
* Reverse the migrations.
29-
*
30-
* @return void
3126
*/
3227
public function down()
3328
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy