Passed
Pull Request — master (#224)
by Kai
02:28
created
lib/Db/ParticipationTextMapper.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -28,50 +28,50 @@
 block discarded – undo
28 28
 
29 29
 class ParticipationTextMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * ParticipationTextMapper constructor.
33
-	 * @param IDBConnection $db
34
-	 */
35
-	public function __construct(IDBConnection $db) {
36
-		parent::__construct($db, 'polls_particip_text', '\OCA\Polls\Db\ParticipationText');
37
-	}
31
+    /**
32
+     * ParticipationTextMapper constructor.
33
+     * @param IDBConnection $db
34
+     */
35
+    public function __construct(IDBConnection $db) {
36
+        parent::__construct($db, 'polls_particip_text', '\OCA\Polls\Db\ParticipationText');
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $pollId
41
-	 * @param int $limit
42
-	 * @param int $offset
43
-	 * @return ParticipationText[]
44
-	 */
45
-	public function findByPoll($pollId, $limit = null, $offset = null) {
46
-		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
47
-		return $this->findEntities($sql, [$pollId], $limit, $offset);
48
-	}
39
+    /**
40
+     * @param string $pollId
41
+     * @param int $limit
42
+     * @param int $offset
43
+     * @return ParticipationText[]
44
+     */
45
+    public function findByPoll($pollId, $limit = null, $offset = null) {
46
+        $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
47
+        return $this->findEntities($sql, [$pollId], $limit, $offset);
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $userId
52
-	 * @param int $limit
53
-	 * @param int $offset
54
-	 * @return ParticipationText[]
55
-	 */
56
-	public function findDistinctByUser($userId, $limit = null, $offset = null) {
57
-		$sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
58
-		return $this->findEntities($sql, [$userId], $limit, $offset);
59
-	}
50
+    /**
51
+     * @param string $userId
52
+     * @param int $limit
53
+     * @param int $offset
54
+     * @return ParticipationText[]
55
+     */
56
+    public function findDistinctByUser($userId, $limit = null, $offset = null) {
57
+        $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
58
+        return $this->findEntities($sql, [$userId], $limit, $offset);
59
+    }
60 60
 
61
-	/**
62
-	 * @param string $pollId
63
-	 */
64
-	public function deleteByPoll($pollId) {
65
-		$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
66
-		$this->execute($sql, [$pollId]);
67
-	}
61
+    /**
62
+     * @param string $pollId
63
+     */
64
+    public function deleteByPoll($pollId) {
65
+        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
66
+        $this->execute($sql, [$pollId]);
67
+    }
68 68
 
69
-	/**
70
-	 * @param string $pollId
71
-	 * @param string $userId
72
-	 */
73
-	public function deleteByPollAndUser($pollId, $userId) {
74
-		$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?';
75
-		$this->execute($sql, [$pollId, $userId]);
76
-	}
69
+    /**
70
+     * @param string $pollId
71
+     * @param string $userId
72
+     */
73
+    public function deleteByPollAndUser($pollId, $userId) {
74
+        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?';
75
+        $this->execute($sql, [$pollId, $userId]);
76
+    }
77 77
 }
Please login to merge, or discard this patch.
lib/Db/DateMapper.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,30 +28,30 @@
 block discarded – undo
28 28
 
29 29
 class DateMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * DateMapper constructor.
33
-	 * @param IDBConnection $db
34
-	 */
35
-	public function __construct(IDBConnection $db) {
36
-		parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
37
-	}
31
+    /**
32
+     * DateMapper constructor.
33
+     * @param IDBConnection $db
34
+     */
35
+    public function __construct(IDBConnection $db) {
36
+        parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $pollId
41
-	 * @param int $limit
42
-	 * @param int $offset
43
-	 * @return Date[]
44
-	 */
45
-	public function findByPoll($pollId, $limit = null, $offset = null) {
46
-		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
47
-		return $this->findEntities($sql, [$pollId], $limit, $offset);
48
-	}
39
+    /**
40
+     * @param string $pollId
41
+     * @param int $limit
42
+     * @param int $offset
43
+     * @return Date[]
44
+     */
45
+    public function findByPoll($pollId, $limit = null, $offset = null) {
46
+        $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
47
+        return $this->findEntities($sql, [$pollId], $limit, $offset);
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $pollId
52
-	 */
53
-	public function deleteByPoll($pollId) {
54
-		$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
55
-		$this->execute($sql, [$pollId]);
56
-	}
50
+    /**
51
+     * @param string $pollId
52
+     */
53
+    public function deleteByPoll($pollId) {
54
+        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
55
+        $this->execute($sql, [$pollId]);
56
+    }
57 57
 }
Please login to merge, or discard this patch.
lib/Db/CommentMapper.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,41 +28,41 @@
 block discarded – undo
28 28
 
29 29
 class CommentMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * CommentMapper constructor.
33
-	 * @param IDBConnection $db
34
-	 */
35
-	public function __construct(IDBConnection $db) {
36
-		parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
37
-	}
31
+    /**
32
+     * CommentMapper constructor.
33
+     * @param IDBConnection $db
34
+     */
35
+    public function __construct(IDBConnection $db) {
36
+        parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $userId
41
-	 * @param int $limit
42
-	 * @param int $offset
43
-	 * @return Comment[]
44
-	 */
45
-	public function findDistinctByUser($userId, $limit = null, $offset = null) {
46
-		$sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
47
-		return $this->findEntities($sql, [$userId], $limit, $offset);
48
-	}
39
+    /**
40
+     * @param string $userId
41
+     * @param int $limit
42
+     * @param int $offset
43
+     * @return Comment[]
44
+     */
45
+    public function findDistinctByUser($userId, $limit = null, $offset = null) {
46
+        $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
47
+        return $this->findEntities($sql, [$userId], $limit, $offset);
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $pollId
52
-	 * @param int $limit
53
-	 * @param int $offset
54
-	 * @return Comment[]
55
-	 */
56
-	public function findByPoll($pollId, $limit = null, $offset = null) {
57
-		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC';
58
-		return $this->findEntities($sql, [$pollId], $limit, $offset);
59
-	}
50
+    /**
51
+     * @param string $pollId
52
+     * @param int $limit
53
+     * @param int $offset
54
+     * @return Comment[]
55
+     */
56
+    public function findByPoll($pollId, $limit = null, $offset = null) {
57
+        $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC';
58
+        return $this->findEntities($sql, [$pollId], $limit, $offset);
59
+    }
60 60
 
61
-	/**
62
-	 * @param string $pollId
63
-	 */
64
-	public function deleteByPoll($pollId) {
65
-		$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
66
-		$this->execute($sql, [$pollId]);
67
-	}
61
+    /**
62
+     * @param string $pollId
63
+     */
64
+    public function deleteByPoll($pollId) {
65
+        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
66
+        $this->execute($sql, [$pollId]);
67
+    }
68 68
 }
Please login to merge, or discard this patch.
templates/no.acc.tmpl.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2
-	/**
3
-	 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
-	 *
5
-	 * @author Vinzenz Rosenkranz <[email protected]>
6
-	 *
7
-	 * @license GNU AGPL version 3 or any later version
8
-	 *
9
-	 *  This program is free software: you can redistribute it and/or modify
10
-	 *  it under the terms of the GNU Affero General Public License as
11
-	 *  published by the Free Software Foundation, either version 3 of the
12
-	 *  License, or (at your option) any later version.
13
-	 *
14
-	 *  This program is distributed in the hope that it will be useful,
15
-	 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
-	 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
-	 *  GNU Affero General Public License for more details.
18
-	 *
19
-	 *  You should have received a copy of the GNU Affero General Public License
20
-	 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
-	 *
22
-	 */
2
+    /**
3
+     * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
+     *
5
+     * @author Vinzenz Rosenkranz <[email protected]>
6
+     *
7
+     * @license GNU AGPL version 3 or any later version
8
+     *
9
+     *  This program is free software: you can redistribute it and/or modify
10
+     *  it under the terms of the GNU Affero General Public License as
11
+     *  published by the Free Software Foundation, either version 3 of the
12
+     *  License, or (at your option) any later version.
13
+     *
14
+     *  This program is distributed in the hope that it will be useful,
15
+     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+     *  GNU Affero General Public License for more details.
18
+     *
19
+     *  You should have received a copy of the GNU Affero General Public License
20
+     *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+     *
22
+     */
23 23
 
24
-	\OCP\Util::addStyle('polls', 'main');
24
+    \OCP\Util::addStyle('polls', 'main');
25 25
 ?>
26 26
 <div id="app">
27 27
 	<div id="app-content">
Please login to merge, or discard this patch.
templates/main.tmpl.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,35 +1,35 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
3
-	 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
-	 *
5
-	 * @author Vinzenz Rosenkranz <[email protected]>
6
-	 *
7
-	 * @license GNU AGPL version 3 or any later version
8
-	 *
9
-	 *  This program is free software: you can redistribute it and/or modify
10
-	 *  it under the terms of the GNU Affero General Public License as
11
-	 *  published by the Free Software Foundation, either version 3 of the
12
-	 *  License, or (at your option) any later version.
13
-	 *
14
-	 *  This program is distributed in the hope that it will be useful,
15
-	 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
-	 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
-	 *  GNU Affero General Public License for more details.
18
-	 *
19
-	 *  You should have received a copy of the GNU Affero General Public License
20
-	 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
-	 *
22
-	 */
2
+    /**
3
+     * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
+     *
5
+     * @author Vinzenz Rosenkranz <[email protected]>
6
+     *
7
+     * @license GNU AGPL version 3 or any later version
8
+     *
9
+     *  This program is free software: you can redistribute it and/or modify
10
+     *  it under the terms of the GNU Affero General Public License as
11
+     *  published by the Free Software Foundation, either version 3 of the
12
+     *  License, or (at your option) any later version.
13
+     *
14
+     *  This program is distributed in the hope that it will be useful,
15
+     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+     *  GNU Affero General Public License for more details.
18
+     *
19
+     *  You should have received a copy of the GNU Affero General Public License
20
+     *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+     *
22
+     */
23 23
 
24
-	use OCP\User;
24
+    use OCP\User;
25 25
 
26
-	\OCP\Util::addStyle('polls', 'main');
27
-	\OCP\Util::addStyle('polls', 'list');
28
-	\OCP\Util::addScript('polls', 'start');
26
+    \OCP\Util::addStyle('polls', 'main');
27
+    \OCP\Util::addStyle('polls', 'list');
28
+    \OCP\Util::addScript('polls', 'start');
29 29
 
30
-	$userId = $_['userId'];
31
-	$userMgr = $_['userMgr'];
32
-	$urlGenerator = $_['urlGenerator'];
30
+    $userId = $_['userId'];
31
+    $userMgr = $_['userMgr'];
32
+    $urlGenerator = $_['urlGenerator'];
33 33
 ?>
34 34
 	<div id="app-content">
35 35
 		<div id="app-content-wrapper">
@@ -83,61 +83,61 @@  discard block
 block discarded – undo
83 83
 
84 84
 				<?php foreach ($_['polls'] as $poll) : ?>
85 85
 					<?php
86
-						if (!userHasAccess($poll, $userId)) continue;
87
-						// direct url to poll
88
-						$pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash()));
89
-						$owner = $poll->getOwner();
86
+                        if (!userHasAccess($poll, $userId)) continue;
87
+                        // direct url to poll
88
+                        $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash()));
89
+                        $owner = $poll->getOwner();
90 90
 
91
-						$expiry_style = '';
92
-						if ($poll->getType() == '0') {
93
-							$participated = $_['participations'];
94
-						} else {
95
-							$participated = $_['participations_text'];
96
-						}
97
-						$participated_class = 'partic_no';
98
-						$participated_title = $l->t('You did not vote');
99
-						$participated_count = count($participated);
91
+                        $expiry_style = '';
92
+                        if ($poll->getType() == '0') {
93
+                            $participated = $_['participations'];
94
+                        } else {
95
+                            $participated = $_['participations_text'];
96
+                        }
97
+                        $participated_class = 'partic_no';
98
+                        $participated_title = $l->t('You did not vote');
99
+                        $participated_count = count($participated);
100 100
 
101
-						$comments = $_['comments'];
102
-						$commented_class = 'commented_no';
103
-						$commented_title = $l->t('You did not comment');
104
-						$commented_count = count($comments);
101
+                        $comments = $_['comments'];
102
+                        $commented_class = 'commented_no';
103
+                        $commented_title = $l->t('You did not comment');
104
+                        $commented_count = count($comments);
105 105
 
106
-						if ($owner == $userId) {
107
-							$owner = $l->t('Yourself');
108
-						}
106
+                        if ($owner == $userId) {
107
+                            $owner = $l->t('Yourself');
108
+                        }
109 109
 
110
-						if ($poll->getExpire() != null) {
111
-							// $expiry_date = date('d.m.Y', strtotime($poll->getExpire()));
112
-							$expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); // does not work, because relative_modified_date seems not to recognise future time diffs
113
-							$expiry_style = ' progress';
114
-							if (date('U') > strtotime($poll->getExpire())) {
115
-								$expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire()));
116
-								$expiry_style = ' expired';
117
-							}
118
-						} else {
119
-							$expiry_style = ' endless';
120
-							$expiry_date = $l->t('Never');
121
-						}
110
+                        if ($poll->getExpire() != null) {
111
+                            // $expiry_date = date('d.m.Y', strtotime($poll->getExpire()));
112
+                            $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); // does not work, because relative_modified_date seems not to recognise future time diffs
113
+                            $expiry_style = ' progress';
114
+                            if (date('U') > strtotime($poll->getExpire())) {
115
+                                $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire()));
116
+                                $expiry_style = ' expired';
117
+                            }
118
+                        } else {
119
+                            $expiry_style = ' endless';
120
+                            $expiry_date = $l->t('Never');
121
+                        }
122 122
 
123
-						for ($i = 0; $i < count($participated); $i++) {
124
-							if ($poll->getId() == intval($participated[$i]->getPollId())) {
125
-								$participated_class = 'partic_yes';
126
-								$participated_title = $l->t('You voted');
127
-								array_splice($participated, $i, 1);
128
-								break;
129
-							}
130
-						}
123
+                        for ($i = 0; $i < count($participated); $i++) {
124
+                            if ($poll->getId() == intval($participated[$i]->getPollId())) {
125
+                                $participated_class = 'partic_yes';
126
+                                $participated_title = $l->t('You voted');
127
+                                array_splice($participated, $i, 1);
128
+                                break;
129
+                            }
130
+                        }
131 131
 
132
-						for ($i = 0; $i < count($comments); $i++) {
133
-							if ($poll->getId() == intval($comments[$i]->getPollId())) {
134
-								$commented_class = 'commented_yes';
135
-								$commented_title = $l->t('You commented');
136
-								array_splice($comments, $i, 1);
137
-								break;
138
-							}
139
-						}
140
-					?>
132
+                        for ($i = 0; $i < count($comments); $i++) {
133
+                            if ($poll->getId() == intval($comments[$i]->getPollId())) {
134
+                                $commented_class = 'commented_yes';
135
+                                $commented_title = $l->t('You commented');
136
+                                array_splice($comments, $i, 1);
137
+                                break;
138
+                            }
139
+                        }
140
+                    ?>
141 141
 
142 142
 
143 143
 					<div class="row table-body">
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
  * @return array with groups
214 214
  */
215 215
 function getGroups($userId) {
216
-	// $this->requireLogin();
217
-	if (class_exists('\OC_Group', true)) {
218
-		// Nextcloud <= 11, ownCloud
219
-		return \OC_Group::getUserGroups($userId);
220
-	}
221
-	// Nextcloud >= 12
222
-	$groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
223
-	return array_map(function ($group) {
224
-		return $group->getGID();
225
-	}, $groups);
216
+    // $this->requireLogin();
217
+    if (class_exists('\OC_Group', true)) {
218
+        // Nextcloud <= 11, ownCloud
219
+        return \OC_Group::getUserGroups($userId);
220
+    }
221
+    // Nextcloud >= 12
222
+    $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
223
+    return array_map(function ($group) {
224
+        return $group->getGID();
225
+    }, $groups);
226 226
 }
227 227
 
228 228
 /**
@@ -231,42 +231,42 @@  discard block
 block discarded – undo
231 231
  * @return boolean 
232 232
  */
233 233
 function userHasAccess($poll, $userId) {
234
-	if ($poll == null) {
235
-		return false;
236
-	}
237
-	$access = $poll->getAccess();
238
-	$owner = $poll->getOwner();
239
-	if (!User::isLoggedIn()) {
240
-		return false;
241
-	}
242
-	if ($access == 'public') {
243
-		return true;
244
-	}
245
-	if ($access == 'hidden') {
246
-		return true;
247
-	}
248
-	if ($access == 'registered') {
249
-		return true;
250
-	}
251
-	if ($owner == $userId) {
252
-		return true;
253
-	}
254
-	$user_groups = getGroups($userId);
234
+    if ($poll == null) {
235
+        return false;
236
+    }
237
+    $access = $poll->getAccess();
238
+    $owner = $poll->getOwner();
239
+    if (!User::isLoggedIn()) {
240
+        return false;
241
+    }
242
+    if ($access == 'public') {
243
+        return true;
244
+    }
245
+    if ($access == 'hidden') {
246
+        return true;
247
+    }
248
+    if ($access == 'registered') {
249
+        return true;
250
+    }
251
+    if ($owner == $userId) {
252
+        return true;
253
+    }
254
+    $user_groups = getGroups($userId);
255 255
 
256
-	$arr = explode(';', $access);
256
+    $arr = explode(';', $access);
257 257
 
258
-	foreach ($arr as $item) {
259
-		if (strpos($item, 'group_') == 0) {
260
-			$grp = substr($item, 6);
261
-			foreach ($user_groups as $user_group) {
262
-				if ($user_group == $grp) return true;
263
-			}
264
-		}
265
-		else if (strpos($item, 'user_') == 0) {
266
-			$usr = substr($item, 5);
267
-			if ($usr == $userId) return true;
268
-		}
269
-	}
270
-	return false;
258
+    foreach ($arr as $item) {
259
+        if (strpos($item, 'group_') == 0) {
260
+            $grp = substr($item, 6);
261
+            foreach ($user_groups as $user_group) {
262
+                if ($user_group == $grp) return true;
263
+            }
264
+        }
265
+        else if (strpos($item, 'user_') == 0) {
266
+            $usr = substr($item, 5);
267
+            if ($usr == $userId) return true;
268
+        }
269
+    }
270
+    return false;
271 271
 }
272 272
 ?>
Please login to merge, or discard this patch.
tests/Unit/Controller/PageControllerTest.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -29,83 +29,83 @@
 block discarded – undo
29 29
 
30 30
 class PageControllerTest extends PHPUnit_Framework_TestCase {
31 31
 
32
-	private $controller;
33
-	private $userId = 'john';
32
+    private $controller;
33
+    private $userId = 'john';
34 34
 
35
-	/**
36
-	 * {@inheritDoc}
37
-	 */
38
-	public function setUp() {
39
-		$request = $this->getMockBuilder('OCP\IRequest')
40
-			->disableOriginalConstructor()
41
-			->getMock();
42
-		$userManager = $this->getMockBuilder('OCP\IUserManager')
43
-			->disableOriginalConstructor()
44
-			->getMock();
45
-		$groupManager = $this->getMockBuilder('OCP\IGroupManager')
46
-			->disableOriginalConstructor()
47
-			->getMock();
48
-		$avatarManager = $this->getMockBuilder('OCP\IAvatarManager')
49
-			->disableOriginalConstructor()
50
-			->getMock();
51
-		$logger = $this->getMockBuilder('OCP\ILogger')
52
-			->disableOriginalConstructor()
53
-			->getMock();
54
-		$l10n = $this->getMockBuilder('OCP\IL10N')
55
-			->disableOriginalConstructor()
56
-			->getMock();
57
-		$urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
58
-			->disableOriginalConstructor()
59
-			->getMock();
60
-		$commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper')
61
-			->disableOriginalConstructor()
62
-			->getMock();
63
-		$dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper')
64
-			->disableOriginalConstructor()
65
-			->getMock();
66
-		$eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper')
67
-			->disableOriginalConstructor()
68
-			->getMock();
69
-		$notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper')
70
-			->disableOriginalConstructor()
71
-			->getMock();
72
-		$participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper')
73
-			->disableOriginalConstructor()
74
-			->getMock();
75
-		$participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper')
76
-			->disableOriginalConstructor()
77
-			->getMock();
78
-		$textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper')
79
-			->disableOriginalConstructor()
80
-			->getMock();
35
+    /**
36
+     * {@inheritDoc}
37
+     */
38
+    public function setUp() {
39
+        $request = $this->getMockBuilder('OCP\IRequest')
40
+            ->disableOriginalConstructor()
41
+            ->getMock();
42
+        $userManager = $this->getMockBuilder('OCP\IUserManager')
43
+            ->disableOriginalConstructor()
44
+            ->getMock();
45
+        $groupManager = $this->getMockBuilder('OCP\IGroupManager')
46
+            ->disableOriginalConstructor()
47
+            ->getMock();
48
+        $avatarManager = $this->getMockBuilder('OCP\IAvatarManager')
49
+            ->disableOriginalConstructor()
50
+            ->getMock();
51
+        $logger = $this->getMockBuilder('OCP\ILogger')
52
+            ->disableOriginalConstructor()
53
+            ->getMock();
54
+        $l10n = $this->getMockBuilder('OCP\IL10N')
55
+            ->disableOriginalConstructor()
56
+            ->getMock();
57
+        $urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
58
+            ->disableOriginalConstructor()
59
+            ->getMock();
60
+        $commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper')
61
+            ->disableOriginalConstructor()
62
+            ->getMock();
63
+        $dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper')
64
+            ->disableOriginalConstructor()
65
+            ->getMock();
66
+        $eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper')
67
+            ->disableOriginalConstructor()
68
+            ->getMock();
69
+        $notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper')
70
+            ->disableOriginalConstructor()
71
+            ->getMock();
72
+        $participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper')
73
+            ->disableOriginalConstructor()
74
+            ->getMock();
75
+        $participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper')
76
+            ->disableOriginalConstructor()
77
+            ->getMock();
78
+        $textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper')
79
+            ->disableOriginalConstructor()
80
+            ->getMock();
81 81
 
82
-		$this->controller = new PageController(
83
-			'polls',
84
-			$request,
85
-			$userManager,
86
-			$groupManager,
87
-			$avatarManager,
88
-			$logger,
89
-			$l10n,
90
-			$urlGenerator,
91
-			$this->userId,
92
-			$commentMapper,
93
-			$dateMapper,
94
-			$eventMapper,
95
-			$notificationMapper,
96
-			$participationMapper,
97
-			$participationTextMapper,
98
-			$textMapper
99
-		);
100
-	}
82
+        $this->controller = new PageController(
83
+            'polls',
84
+            $request,
85
+            $userManager,
86
+            $groupManager,
87
+            $avatarManager,
88
+            $logger,
89
+            $l10n,
90
+            $urlGenerator,
91
+            $this->userId,
92
+            $commentMapper,
93
+            $dateMapper,
94
+            $eventMapper,
95
+            $notificationMapper,
96
+            $participationMapper,
97
+            $participationTextMapper,
98
+            $textMapper
99
+        );
100
+    }
101 101
 
102
-	/**
103
-	 *
104
-	 */
105
-	public function testIndex() {
106
-		$result = $this->controller->index();
102
+    /**
103
+     *
104
+     */
105
+    public function testIndex() {
106
+        $result = $this->controller->index();
107 107
 
108
-		$this->assertEquals('main.tmpl', $result->getTemplateName());
109
-		$this->assertTrue($result instanceof TemplateResponse);
110
-	}
108
+        $this->assertEquals('main.tmpl', $result->getTemplateName());
109
+        $this->assertTrue($result instanceof TemplateResponse);
110
+    }
111 111
 }
Please login to merge, or discard this patch.
tests/Unit/Factories/EventFactory.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -27,20 +27,20 @@
 block discarded – undo
27 27
  * General factory for the event model.
28 28
  */
29 29
 $fm->define('OCA\Polls\Db\Event')->setDefinitions([
30
-	'type' => 0,
31
-	'title' => Faker::sentence(10),
32
-	'description' => Faker::paragraph(),
33
-	'owner' => Faker::firstNameMale(),
34
-	'created' => function () {
35
-		$date = new DateTime( 'today');
36
-		return $date->format('Y-m-d H:i:s');
37
-	},
38
-	'access' => 'registered',
39
-	'expire' => function () {
40
-		$date = new DateTime( 'tomorrow');
41
-		return $date->format('Y-m-d H:i:s');
42
-	},
43
-	'hash' => Faker::regexify('[A-Za-z0-9]{16}'),
44
-	'isAnonymous' => 0,
45
-	'fullAnonymous' => 0
30
+    'type' => 0,
31
+    'title' => Faker::sentence(10),
32
+    'description' => Faker::paragraph(),
33
+    'owner' => Faker::firstNameMale(),
34
+    'created' => function () {
35
+        $date = new DateTime( 'today');
36
+        return $date->format('Y-m-d H:i:s');
37
+    },
38
+    'access' => 'registered',
39
+    'expire' => function () {
40
+        $date = new DateTime( 'tomorrow');
41
+        return $date->format('Y-m-d H:i:s');
42
+    },
43
+    'hash' => Faker::regexify('[A-Za-z0-9]{16}'),
44
+    'isAnonymous' => 0,
45
+    'fullAnonymous' => 0
46 46
 ]);
Please login to merge, or discard this patch.
tests/Unit/Factories/CommentFactory.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
  * General factory for the comment model.
28 28
  */
29 29
 $fm->define('OCA\Polls\Db\Comment')->setDefinitions([
30
-	'userId' => Faker::firstNameMale(),
31
-	'dt' => function () {
32
-		$date = new DateTime( 'today');
33
-		return $date->format('Y-m-d H:i:s');
34
-	},
35
-	'comment' => Faker::paragraph()
30
+    'userId' => Faker::firstNameMale(),
31
+    'dt' => function () {
32
+        $date = new DateTime( 'today');
33
+        return $date->format('Y-m-d H:i:s');
34
+    },
35
+    'comment' => Faker::paragraph()
36 36
 ]);
Please login to merge, or discard this patch.
tests/Unit/Db/CommentMapperTest.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -35,71 +35,71 @@
 block discarded – undo
35 35
 
36 36
 class CommentMapperTest extends PHPUnit_Framework_TestCase {
37 37
 
38
-	/** @var IDBConnection */
39
-	private $con;
40
-	/** @var CommentMapper */
41
-	private $commentMapper;
42
-	/** @var EventMapper */
43
-	private $eventMapper;
44
-	/** @var FactoryMuffin */
45
-	private	$fm;
38
+    /** @var IDBConnection */
39
+    private $con;
40
+    /** @var CommentMapper */
41
+    private $commentMapper;
42
+    /** @var EventMapper */
43
+    private $eventMapper;
44
+    /** @var FactoryMuffin */
45
+    private	$fm;
46 46
 
47
-	/**
48
-	 * {@inheritDoc}
49
-	 */
50
-	public function setUp() {
51
-		parent::setUp();
47
+    /**
48
+     * {@inheritDoc}
49
+     */
50
+    public function setUp() {
51
+        parent::setUp();
52 52
 
53
-		$this->con = \OC::$server->getDatabaseConnection();
54
-		$this->commentMapper = new CommentMapper($this->con);
55
-		$this->eventMapper = new EventMapper($this->con);
53
+        $this->con = \OC::$server->getDatabaseConnection();
54
+        $this->commentMapper = new CommentMapper($this->con);
55
+        $this->eventMapper = new EventMapper($this->con);
56 56
 
57
-		$this->fm = new FactoryMuffin();
58
-		$this->fm->loadFactories(__DIR__ . '/../Factories');
59
-	}
57
+        $this->fm = new FactoryMuffin();
58
+        $this->fm->loadFactories(__DIR__ . '/../Factories');
59
+    }
60 60
 
61
-	/**
62
-	 * Test the creation of an event and a comment object and save them to the database.
63
-	 *
64
-	 * @return Comment
65
-	 */
66
-	public function testCreate() {
67
-		/** @var Event $event */
68
-		$event = $this->fm->instance('OCA\Polls\Db\Event');
69
-		$this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
61
+    /**
62
+     * Test the creation of an event and a comment object and save them to the database.
63
+     *
64
+     * @return Comment
65
+     */
66
+    public function testCreate() {
67
+        /** @var Event $event */
68
+        $event = $this->fm->instance('OCA\Polls\Db\Event');
69
+        $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
70 70
 
71
-		/** @var Comment $comment */
72
-		$comment = $this->fm->instance('OCA\Polls\Db\Comment');
73
-		$comment->setPollId($event->getId());
74
-		$this->assertInstanceOf(Comment::class, $this->commentMapper->insert($comment));
71
+        /** @var Comment $comment */
72
+        $comment = $this->fm->instance('OCA\Polls\Db\Comment');
73
+        $comment->setPollId($event->getId());
74
+        $this->assertInstanceOf(Comment::class, $this->commentMapper->insert($comment));
75 75
 
76
-		return $comment;
77
-	}
76
+        return $comment;
77
+    }
78 78
 
79
-	/**
80
-	 * Update the previously created comment.
81
-	 *
82
-	 * @depends testCreate
83
-	 * @param Comment $comment
84
-	 * @return Comment
85
-	 */
86
-	public function testUpdate(Comment $comment) {
87
-		$newComment = Faker::paragraph();
88
-		$comment->setComment($newComment());
89
-		$this->commentMapper->update($comment);
79
+    /**
80
+     * Update the previously created comment.
81
+     *
82
+     * @depends testCreate
83
+     * @param Comment $comment
84
+     * @return Comment
85
+     */
86
+    public function testUpdate(Comment $comment) {
87
+        $newComment = Faker::paragraph();
88
+        $comment->setComment($newComment());
89
+        $this->commentMapper->update($comment);
90 90
 
91
-		return $comment;
92
-	}
91
+        return $comment;
92
+    }
93 93
 
94
-	/**
95
-	 * Delete the previously created entries from the database.
96
-	 *
97
-	 * @depends testUpdate
98
-	 * @param Comment $comment
99
-	 */
100
-	public function testDelete(Comment $comment) {
101
-		$event = $this->eventMapper->find($comment->getPollId());
102
-		$this->commentMapper->delete($comment);
103
-		$this->eventMapper->delete($event);
104
-	}
94
+    /**
95
+     * Delete the previously created entries from the database.
96
+     *
97
+     * @depends testUpdate
98
+     * @param Comment $comment
99
+     */
100
+    public function testDelete(Comment $comment) {
101
+        $event = $this->eventMapper->find($comment->getPollId());
102
+        $this->commentMapper->delete($comment);
103
+        $this->eventMapper->delete($event);
104
+    }
105 105
 }
Please login to merge, or discard this patch.