Skip to content

Commit

Permalink
fixs for coveralls and travis phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
appliedrd committed Aug 17, 2016
1 parent cc32602 commit 9f268d7
Show file tree
Hide file tree
Showing 47 changed files with 216 additions and 35 deletions.
1 change: 1 addition & 0 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
Expand Down
8 changes: 8 additions & 0 deletions src/Controller/ApplicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ public function accepted($application = null)
// Check if the application has already been accepted or rejected
if ($application->getAccepted() || $application->getRejected()) {
$this->Flash->error(__('This application has already been {0}', ($application->getAccepted() ? __('accepted') : __('rejected'))) . '.');

return $this->redirect(['controller' => 'Missions', 'action' => 'view', $application->getMission()->id]);
}

// Check if the logged user is the mission mentor
if ($application->getMission()->getMentorId() != $user->getId()) {
$this->Flash->error(__('You\'re not the mentor on this mission.'));

return $this->redirect(['controller' => 'Missions', 'action' => 'view', $application->getMission()->id]);
}

Expand Down Expand Up @@ -151,6 +153,7 @@ public function accepted($application = null)
$notifications->save($notification);

$this->Flash->success(__('The application has been saved.'));

return $this->redirect(['controller' => 'Missions', 'action' => 'view', $application->getMission()->id]);
} else {
$this->Flash->error(__('The application could not be saved. Please, try again.'));
Expand Down Expand Up @@ -191,12 +194,14 @@ public function rejected($application = null)
// Check if the application has already been accepted or rejected
if ($application->getAccepted() || $application->getRejected()) {
$this->Flash->error(__('This application has already been {0}', ($application->getAccepted() ? __('accepted') : __('rejected'))) . '.');

return $this->redirect(['controller' => 'Missions', 'action' => 'view', $application->getMission()->id]);
}

// Check if the logged user is the mission mentor
if ($application->getMission()->getMentorId() != $user->getId()) {
$this->Flash->error(__('You\'re not the mentor on this mission.'));

return $this->redirect(['controller' => 'Missions', 'action' => 'view', $application->getMission()->id]);
}

Expand All @@ -216,6 +221,7 @@ public function rejected($application = null)
$notifications->save($notification);

$this->Flash->success(__('The application has been saved.'));

return $this->redirect(['controller' => 'Missions', 'action' => 'view', $application->getMission()->id]);
} else {
$this->Flash->error(__('The application could not be saved. Please, try again.'));
Expand Down Expand Up @@ -274,10 +280,12 @@ public function editArchived($id = null)
if ($user->getId() == $application->getUserId()) {
if ($this->request->is(['post'])) {
$this->_toggleArchived($application);

return $this->redirect(['controller' => 'Users', 'action' => 'view', $user->id]);
}
} else {
$this->Flash->error(__('You cannot delete an application from another user'));

return $this->redirect(['controller' => 'Users', 'action' => 'view', $user->id]);
}

Expand Down
1 change: 1 addition & 0 deletions src/Controller/Component/HashComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class HashComponent extends Component
public function hash($data)
{
$hash = hash("sha256", $data);

return $hash;
}

Expand Down
1 change: 1 addition & 0 deletions src/Controller/MembershipsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function add()
$organizationId = $this->request->data['organization_id'];
$organization = $this->Memberships->Organizations->get($organizationId, ['contain' => ['Owners', 'Members']]);
$this->_createMembership($userId, $organization);

return $this->redirect(['controller' => 'Users', 'action' => 'login']);
}

Expand Down
14 changes: 13 additions & 1 deletion src/Controller/MissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public function add($projectId = null)
$mission->editTypeId($this->request->data['type_mission']);
if ($this->Missions->save($mission)) {
$this->Flash->success(__('The mission has been saved.'));

return $this->redirect(['controller' => 'Projects', 'action' => 'view', $projectId]);
} else {
$this->Flash->error(__('The mission could not be saved. Please, try again.'));
Expand Down Expand Up @@ -407,6 +408,7 @@ public function edit($id = null)

if ($this->Missions->save($mission)) {
$this->Flash->success(__('The mission has been edited.'));

return $this->redirect(['action' => 'view', $mission->id]);
} else {
$this->Flash->error(__('The mission could not be edited. Please, try again.'));
Expand Down Expand Up @@ -436,9 +438,11 @@ public function editArchived($id)
} else {
$this->Flash->success(__('The mission has been restored.'));
}

return $this->redirect(['action' => 'view', $id]);
} else {
$this->Flash->error(__('The mission could not be archived. Please, try again.'));

return $this->redirect(['action' => 'view', $id]);
}
}
Expand Down Expand Up @@ -508,30 +512,36 @@ public function apply($id)
}
} else {
$this->Flash->error(__('You have already applied on this mission.'));

return $this->redirect(['action' => 'view', $id]);
}
} else {
$this->Flash->error(__('You need to fill your profile before apply on this mission.'));

return $this->redirect(['action' => 'view', $id]);
}
} else {
$this->Flash->error(__("This mission is not seeking someone matching your profile"));

return $this->redirect(['action' => 'view', $id]);
}
$this->set(compact('mission'));
$this->set('_serialize', ['mission']);
} else {
$this->Flash->error(__('No more position available') . '.');

return $this->redirect(['action' => 'view', $id]);
}
$this->set(compact('mission', 'userEmail', 'isProfessor', 'isStudent'));
$this->set('_serialize', ['mission']);
} else {
$this->Flash->error(__("You can't apply on your mission, you are the mentor") . '.');

return $this->redirect(['action' => 'view', $id]);
}
} else {
$this->Flash->error(__("You don't have permission to access this page."));

return $this->redirect(['controller' => 'Pages', 'action' => 'home']);
}
}
Expand Down Expand Up @@ -569,6 +579,7 @@ public function editMentor($id = null)

if ($this->Missions->save($mission)) {
$this->Flash->success(__('The mentor have been modified.'));

return $this->redirect(['action' => 'view', $mission->id]);
} else {
$this->Flash->error(__('The mentor could not be modified. Please,try again.'));
Expand Down Expand Up @@ -613,6 +624,7 @@ public function editProfessor($id = null)

if ($this->Missions->save($mission)) {
$this->Flash->success(__('The professor have been modified.'));

return $this->redirect(['action' => 'view', $mission->id]);
} else {
$this->Flash->error(__('The professor could not be modified. Please,try again.'));
Expand All @@ -631,7 +643,7 @@ public function editProfessor($id = null)
*
* @param int $id id
*
* @return null
* @return void
*/
public function projectindex($id = null)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Controller/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function index()
/**
* Add method
*
* @return void Redirects on successful add, renders view otherwise.
* @return redirect
*/
public function add()
{
Expand All @@ -98,6 +98,7 @@ public function add()
$news = $this->News->patchEntity($news, $this->request->data);
if ($this->News->save($news)) {
$this->Flash->success(__('The news has been saved.'));

return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The news could not be saved. Please, try again.'));
Expand All @@ -112,7 +113,7 @@ public function add()
*
* @param string|null $id News id.
*
* @return void Redirects on successful edit, renders view otherwise.
* @return redirect
*
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
Expand All @@ -128,6 +129,7 @@ public function edit($id = null)
$news = $this->News->patchEntity($news, $this->request->data);
if ($this->News->save($news)) {
$this->Flash->success(__('The news has been saved.'));

return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The news could not be saved. Please, try again.'));
Expand Down Expand Up @@ -155,6 +157,7 @@ public function delete($id = null)
} else {
$this->Flash->error(__('The news could not be deleted. Please, try again.'));
}

return $this->redirect(['action' => 'index']);
}
}
4 changes: 4 additions & 0 deletions src/Controller/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ public function markAsRead($notificationId)
$notification->isRead = true;
if ($this->Notifications->save($notification)) {
$this->Flash->success(__('The notification has been mark as read.'));

return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The notification could not be mark as read. Please, try again.'));

return $this->redirect(['action' => 'index']);
}
}
Expand All @@ -125,11 +127,13 @@ public function markAllAsRead()
$notification->isRead = true;
if (!$this->Notifications->save($notification)) {
$this->Flash->error(__('The notification could not be mark as read. Please, try again.'));

return $this->redirect(['action' => 'index']);
}
}

$this->Flash->success(__('All notifications has been mark as read.'));

return $this->redirect(['action' => 'index']);
}
}
15 changes: 12 additions & 3 deletions src/Controller/OrganizationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function add()
$organization = $this->Organizations->patchEntity($organization, $this->request->data);
if ($this->Organizations->save($organization)) {
$this->Flash->success(__('The organization has been saved.'));

return $this->redirect(['action' => 'view', $organization->id]);
} else {
$this->Flash->error(__('The organization could not be saved. Please, try again.'));
Expand Down Expand Up @@ -330,6 +331,7 @@ public function submit()

if ($this->Organizations->save($organization)) {
$this->Flash->success(__('The organization has been saved.'));

return $this->redirect(['action' => 'submit', 'controller' => 'Projects']);
} else {
$this->Flash->error(__('The organization could not be saved. Please, try again.'));
Expand Down Expand Up @@ -358,6 +360,7 @@ public function edit($id = null)
$organization = $this->Organizations->patchEntity($organization, $this->request->data);
if ($this->Organizations->save($organization)) {
$this->Flash->success(__('The organization has been saved.'));

return $this->redirect(['action' => 'view', $organization->id]);
} else {
$this->Flash->error(__('The organization could not be saved. Please, try again.'));
Expand All @@ -370,7 +373,7 @@ public function edit($id = null)
/**
* Edit state method
*
* @return void
* @return int
*/
public function editStatus()
{
Expand Down Expand Up @@ -451,6 +454,7 @@ public function editValidated($id)
$notifications->save($notification);
}
$this->Flash->success(__('The organization has been approved.'));

return $this->redirect(['action' => 'view', $id]);
} else {
$this->Flash->error(__('The organization could not be saved. Please, try again.'));
Expand Down Expand Up @@ -479,6 +483,7 @@ public function editRejected($id)
$notifications->save($notification);
}
$this->Flash->success(__('The organization has been saved.'));

return $this->redirect(['action' => 'view', $id]);
} else {
$this->Flash->error(__('The organization could not be saved. Please, try again.'));
Expand All @@ -501,6 +506,7 @@ public function delete($id = null)
} else {
$this->Flash->error(__('The organization could not be deleted. Please, try again.'));
}

return $this->redirect(['action' => 'index']);
}

Expand All @@ -509,7 +515,7 @@ public function delete($id = null)
*
* @param int $id organization id
*
* @return void
* @return redirect
*/
public function addMember($id = null)
{
Expand Down Expand Up @@ -545,6 +551,7 @@ public function addMember($id = null)
if ($haveOwner) {
if ($this->Organizations->save($organization)) {
$this->Flash->success(__('The organization has been updated.'));

return $this->redirect(['action' => 'view', $organization->id]);
} else {
$this->Flash->error(__('The organization could not be updated. Please,try again.'));
Expand All @@ -563,7 +570,7 @@ public function addMember($id = null)
*
* @param int $id organization id
*
* @return void
* @return redirect
*/
public function addOwner($id = null)
{
Expand All @@ -588,6 +595,7 @@ public function addOwner($id = null)

if ($this->Organizations->save($organization)) {
$this->Flash->success(__('The user has been added.'));

return $this->redirect(['action' => 'view', $organization->id]);
} else {
$this->Flash->error(__('The user could not be added. Please,try again.'));
Expand Down Expand Up @@ -631,6 +639,7 @@ public function quit($id = null)
foreach ($project->getMentors() as $mentor) {
if ($mentor->getId() == $you) {
$this->Flash->error(__('You are a mentor of a project, you cannot leave the organization. You must remove yourself from the mentor list of the project to quit'));

return $this->redirect(['action' => 'view', $organization->id]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function home()
*
* @param null $id tv page
*
* @return redirect
* @return void
*/
public function tv($id = null)
{
Expand Down
Loading

0 comments on commit 9f268d7

Please sign in to comment.