Passed
Pull Request — master (#224)
by Kai
03:05
created
tests/Unit/UnitTestCase.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@
 block discarded – undo
28 28
 
29 29
 abstract class UnitTestCase extends PHPUnit_Framework_TestCase {
30 30
 
31
-	/** @var FactoryMuffin */
32
-	protected $fm;
31
+    /** @var FactoryMuffin */
32
+    protected $fm;
33 33
 
34
-	/**
35
-	 * {@inheritDoc}
36
-	 */
37
-	public function setUp() {
38
-		parent::setUp();
39
-		$this->fm = new FactoryMuffin();
40
-		$this->fm->loadFactories(__DIR__ . '/Factories');
41
-	}
34
+    /**
35
+     * {@inheritDoc}
36
+     */
37
+    public function setUp() {
38
+        parent::setUp();
39
+        $this->fm = new FactoryMuffin();
40
+        $this->fm->loadFactories(__DIR__ . '/Factories');
41
+    }
42 42
 }
Please login to merge, or discard this patch.
lib/Db/Model.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
 use OCP\AppFramework\Db\Entity;
27 27
 
28 28
 abstract class Model extends Entity {
29
-	/**
30
-	 * FactoryMuffin checks for the existence of setters with method_exists($obj, $attr) but that returns false.
31
-	 * By overwriting the __set() magic method we can trigger the changed flag on $obj->attr assignment.
32
-	 *
33
-	 * @param $name
34
-	 * @param $value
35
-	 */
36
-	public function __set($name, $value) {
37
-		$this->setter($name, [$value]);
38
-	}
29
+    /**
30
+     * FactoryMuffin checks for the existence of setters with method_exists($obj, $attr) but that returns false.
31
+     * By overwriting the __set() magic method we can trigger the changed flag on $obj->attr assignment.
32
+     *
33
+     * @param $name
34
+     * @param $value
35
+     */
36
+    public function __set($name, $value) {
37
+        $this->setter($name, [$value]);
38
+    }
39 39
 }
Please login to merge, or discard this patch.
lib/AppInfo/Application.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -37,130 +37,130 @@
 block discarded – undo
37 37
 
38 38
 class Application extends App {
39 39
 
40
-	/**
41
-	 * Application constructor.
42
-	 * @param array $urlParams
43
-	 */
44
-	public function __construct(array $urlParams = array()) {
45
-		parent::__construct('polls', $urlParams);
46
-
47
-		$container = $this->getContainer();
48
-		$server = $container->getServer();
49
-
50
-		/**
51
-		 * Controllers
52
-		 */
53
-		$container->registerService('PageController', function ($c) use ($server) {
54
-			/** @var SimpleContainer $c */
55
-			return new PageController(
56
-				$c->query('AppName'),
57
-				$c->query('Request'),
58
-				$c->query('UserManager'),
59
-				$c->query('GroupManager'),
60
-				$c->query('AvatarManager'),
61
-				$c->query('Logger'),
62
-				$c->query('L10N'),
63
-				$c->query('ServerContainer')->getURLGenerator(),
64
-				$c->query('UserId'),
65
-				$c->query('CommentMapper'),
66
-				$c->query('DateMapper'),
67
-				$c->query('EventMapper'),
68
-				$c->query('NotificationMapper'),
69
-				$c->query('ParticipationMapper'),
70
-				$c->query('ParticipationTextMapper'),
71
-				$c->query('TextMapper')
72
-			);
73
-		});
74
-
75
-		$container->registerService('UserManager', function ($c) {
76
-			/** @var SimpleContainer $c */
77
-			return $c->query('ServerContainer')->getUserManager();
78
-		});
79
-
80
-		$container->registerService('GroupManager', function ($c) {
81
-			/** @var SimpleContainer $c */
82
-			return $c->query('ServerContainer')->getGroupManager();
83
-		});
84
-
85
-		$container->registerService('AvatarManager', function ($c) {
86
-			/** @var SimpleContainer $c */
87
-			return $c->query('ServerContainer')->getAvatarManager();
88
-		});
89
-
90
-		$container->registerService('Logger', function ($c) {
91
-			/** @var SimpleContainer $c */
92
-			return $c->query('ServerContainer')->getLogger();
93
-		});
94
-
95
-		$container->registerService('L10N', function ($c) {
96
-			return $c->query('ServerContainer')->getL10N($c->query('AppName'));
97
-		});
98
-
99
-		$container->registerService('CommentMapper', function ($c) use ($server) {
100
-			/** @var SimpleContainer $c */
101
-			return new CommentMapper(
102
-				$server->getDatabaseConnection()
103
-			);
104
-		});
105
-
106
-		$container->registerService('DateMapper', function ($c) use ($server) {
107
-			/** @var SimpleContainer $c */
108
-			return new DateMapper(
109
-				$server->getDatabaseConnection()
110
-			);
111
-		});
112
-
113
-		$container->registerService('EventMapper', function ($c) use ($server) {
114
-			/** @var SimpleContainer $c */
115
-			return new EventMapper(
116
-				$server->getDatabaseConnection()
117
-			);
118
-		});
119
-
120
-		$container->registerService('NotificationMapper', function ($c) use ($server) {
121
-			/** @var SimpleContainer $c */
122
-			return new NotificationMapper(
123
-				$server->getDatabaseConnection()
124
-			);
125
-		});
126
-
127
-		$container->registerService('ParticipationMapper', function ($c) use ($server) {
128
-			/** @var SimpleContainer $c */
129
-			return new ParticipationMapper(
130
-				$server->getDatabaseConnection()
131
-			);
132
-		});
133
-
134
-		$container->registerService('ParticipationTextMapper', function ($c) use ($server) {
135
-			/** @var SimpleContainer $c */
136
-			return new ParticipationTextMapper(
137
-				$server->getDatabaseConnection()
138
-			);
139
-		});
140
-
141
-		$container->registerService('TextMapper', function ($c) use ($server) {
142
-			/** @var SimpleContainer $c */
143
-			return new TextMapper(
144
-				$server->getDatabaseConnection()
145
-			);
146
-		});
147
-	}
148
-
149
-	/**
150
-	 * Register navigation entry for main navigation.
151
-	 */
152
-	public function registerNavigationEntry() {
153
-		$container = $this->getContainer();
154
-		$container->query('OCP\INavigationManager')->add(function () use ($container) {
155
-			$urlGenerator = $container->query('OCP\IURLGenerator');
156
-			$l10n = $container->query('OCP\IL10N');
157
-			return [
158
-				'id' => 'polls',
159
-				'order' => 77,
160
-				'href' => $urlGenerator->linkToRoute('polls.page.index'),
161
-				'icon' => $urlGenerator->imagePath('polls', 'app.svg'),
162
-				'name' => $l10n->t('Polls')
163
-			];
164
-		});
165
-	}
40
+    /**
41
+     * Application constructor.
42
+     * @param array $urlParams
43
+     */
44
+    public function __construct(array $urlParams = array()) {
45
+        parent::__construct('polls', $urlParams);
46
+
47
+        $container = $this->getContainer();
48
+        $server = $container->getServer();
49
+
50
+        /**
51
+         * Controllers
52
+         */
53
+        $container->registerService('PageController', function ($c) use ($server) {
54
+            /** @var SimpleContainer $c */
55
+            return new PageController(
56
+                $c->query('AppName'),
57
+                $c->query('Request'),
58
+                $c->query('UserManager'),
59
+                $c->query('GroupManager'),
60
+                $c->query('AvatarManager'),
61
+                $c->query('Logger'),
62
+                $c->query('L10N'),
63
+                $c->query('ServerContainer')->getURLGenerator(),
64
+                $c->query('UserId'),
65
+                $c->query('CommentMapper'),
66
+                $c->query('DateMapper'),
67
+                $c->query('EventMapper'),
68
+                $c->query('NotificationMapper'),
69
+                $c->query('ParticipationMapper'),
70
+                $c->query('ParticipationTextMapper'),
71
+                $c->query('TextMapper')
72
+            );
73
+        });
74
+
75
+        $container->registerService('UserManager', function ($c) {
76
+            /** @var SimpleContainer $c */
77
+            return $c->query('ServerContainer')->getUserManager();
78
+        });
79
+
80
+        $container->registerService('GroupManager', function ($c) {
81
+            /** @var SimpleContainer $c */
82
+            return $c->query('ServerContainer')->getGroupManager();
83
+        });
84
+
85
+        $container->registerService('AvatarManager', function ($c) {
86
+            /** @var SimpleContainer $c */
87
+            return $c->query('ServerContainer')->getAvatarManager();
88
+        });
89
+
90
+        $container->registerService('Logger', function ($c) {
91
+            /** @var SimpleContainer $c */
92
+            return $c->query('ServerContainer')->getLogger();
93
+        });
94
+
95
+        $container->registerService('L10N', function ($c) {
96
+            return $c->query('ServerContainer')->getL10N($c->query('AppName'));
97
+        });
98
+
99
+        $container->registerService('CommentMapper', function ($c) use ($server) {
100
+            /** @var SimpleContainer $c */
101
+            return new CommentMapper(
102
+                $server->getDatabaseConnection()
103
+            );
104
+        });
105
+
106
+        $container->registerService('DateMapper', function ($c) use ($server) {
107
+            /** @var SimpleContainer $c */
108
+            return new DateMapper(
109
+                $server->getDatabaseConnection()
110
+            );
111
+        });
112
+
113
+        $container->registerService('EventMapper', function ($c) use ($server) {
114
+            /** @var SimpleContainer $c */
115
+            return new EventMapper(
116
+                $server->getDatabaseConnection()
117
+            );
118
+        });
119
+
120
+        $container->registerService('NotificationMapper', function ($c) use ($server) {
121
+            /** @var SimpleContainer $c */
122
+            return new NotificationMapper(
123
+                $server->getDatabaseConnection()
124
+            );
125
+        });
126
+
127
+        $container->registerService('ParticipationMapper', function ($c) use ($server) {
128
+            /** @var SimpleContainer $c */
129
+            return new ParticipationMapper(
130
+                $server->getDatabaseConnection()
131
+            );
132
+        });
133
+
134
+        $container->registerService('ParticipationTextMapper', function ($c) use ($server) {
135
+            /** @var SimpleContainer $c */
136
+            return new ParticipationTextMapper(
137
+                $server->getDatabaseConnection()
138
+            );
139
+        });
140
+
141
+        $container->registerService('TextMapper', function ($c) use ($server) {
142
+            /** @var SimpleContainer $c */
143
+            return new TextMapper(
144
+                $server->getDatabaseConnection()
145
+            );
146
+        });
147
+    }
148
+
149
+    /**
150
+     * Register navigation entry for main navigation.
151
+     */
152
+    public function registerNavigationEntry() {
153
+        $container = $this->getContainer();
154
+        $container->query('OCP\INavigationManager')->add(function () use ($container) {
155
+            $urlGenerator = $container->query('OCP\IURLGenerator');
156
+            $l10n = $container->query('OCP\IL10N');
157
+            return [
158
+                'id' => 'polls',
159
+                'order' => 77,
160
+                'href' => $urlGenerator->linkToRoute('polls.page.index'),
161
+                'icon' => $urlGenerator->imagePath('polls', 'app.svg'),
162
+                'name' => $l10n->t('Polls')
163
+            ];
164
+        });
165
+    }
166 166
 }
Please login to merge, or discard this patch.
tests/Unit/Factories/TextFactory.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,5 +27,5 @@
 block discarded – undo
27 27
  * General factory for the text model.
28 28
  */
29 29
 $fm->define('OCA\Polls\Db\Text')->setDefinitions([
30
-	'text' => Faker::paragraph()
30
+    'text' => Faker::paragraph()
31 31
 ]);
Please login to merge, or discard this patch.
tests/Unit/Factories/ParticipationTextFactory.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
  * General factory for the participation text model.
28 28
  */
29 29
 $fm->define('OCA\Polls\Db\ParticipationText')->setDefinitions([
30
-	'text' => Faker::paragraph(),
31
-	'userId' => Faker::firstNameMale(),
32
-	'type' => 0
30
+    'text' => Faker::paragraph(),
31
+    'userId' => Faker::firstNameMale(),
32
+    'type' => 0
33 33
 ]);
Please login to merge, or discard this patch.
tests/Unit/Factories/ParticipationFactory.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 participation model.
28 28
  */
29 29
 $fm->define('OCA\Polls\Db\Participation')->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
-	'type' => 0
30
+    'userId' => Faker::firstNameMale(),
31
+    'dt' => function () {
32
+        $date = new DateTime('today');
33
+        return $date->format('Y-m-d H:i:s');
34
+    },
35
+    'type' => 0
36 36
 ]);
Please login to merge, or discard this patch.
tests/Unit/Factories/NotificationFactory.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,5 +27,5 @@
 block discarded – undo
27 27
  * General factory for the notification model.
28 28
  */
29 29
 $fm->define('OCA\Polls\Db\Notification')->setDefinitions([
30
-	'userId' => Faker::firstNameMale(),
30
+    'userId' => Faker::firstNameMale(),
31 31
 ]);
Please login to merge, or discard this patch.
tests/Unit/Factories/DateFactory.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@
 block discarded – undo
25 25
  * General factory for the date model.
26 26
  */
27 27
 $fm->define('OCA\Polls\Db\Date')->setDefinitions([
28
-	'dt' => function () {
29
-		$date = new DateTime('today');
30
-		return $date->format('Y-m-d H:i:s');
31
-	}
28
+    'dt' => function () {
29
+        $date = new DateTime('today');
30
+        return $date->format('Y-m-d H:i:s');
31
+    }
32 32
 ]);
Please login to merge, or discard this patch.
tests/Unit/Db/CommentMapperTest.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -33,65 +33,65 @@
 block discarded – undo
33 33
 
34 34
 class CommentMapperTest extends UnitTestCase {
35 35
 
36
-	/** @var IDBConnection */
37
-	private $con;
38
-	/** @var CommentMapper */
39
-	private $commentMapper;
40
-	/** @var EventMapper */
41
-	private $eventMapper;
36
+    /** @var IDBConnection */
37
+    private $con;
38
+    /** @var CommentMapper */
39
+    private $commentMapper;
40
+    /** @var EventMapper */
41
+    private $eventMapper;
42 42
 
43
-	/**
44
-	 * {@inheritDoc}
45
-	 */
46
-	public function setUp() {
47
-		parent::setUp();
48
-		$this->con = \OC::$server->getDatabaseConnection();
49
-		$this->commentMapper = new CommentMapper($this->con);
50
-		$this->eventMapper = new EventMapper($this->con);
51
-	}
43
+    /**
44
+     * {@inheritDoc}
45
+     */
46
+    public function setUp() {
47
+        parent::setUp();
48
+        $this->con = \OC::$server->getDatabaseConnection();
49
+        $this->commentMapper = new CommentMapper($this->con);
50
+        $this->eventMapper = new EventMapper($this->con);
51
+    }
52 52
 
53
-	/**
54
-	 * Create some fake data and persist them to the database.
55
-	 *
56
-	 * @return Comment
57
-	 */
58
-	public function testCreate() {
59
-		/** @var Event $event */
60
-		$event = $this->fm->instance('OCA\Polls\Db\Event');
61
-		$this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
53
+    /**
54
+     * Create some fake data and persist them to the database.
55
+     *
56
+     * @return Comment
57
+     */
58
+    public function testCreate() {
59
+        /** @var Event $event */
60
+        $event = $this->fm->instance('OCA\Polls\Db\Event');
61
+        $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
62 62
 
63
-		/** @var Comment $comment */
64
-		$comment = $this->fm->instance('OCA\Polls\Db\Comment');
65
-		$comment->setPollId($event->getId());
66
-		$this->assertInstanceOf(Comment::class, $this->commentMapper->insert($comment));
63
+        /** @var Comment $comment */
64
+        $comment = $this->fm->instance('OCA\Polls\Db\Comment');
65
+        $comment->setPollId($event->getId());
66
+        $this->assertInstanceOf(Comment::class, $this->commentMapper->insert($comment));
67 67
 
68
-		return $comment;
69
-	}
68
+        return $comment;
69
+    }
70 70
 
71
-	/**
72
-	 * Update the previously created entry and persist the changes.
73
-	 *
74
-	 * @depends testCreate
75
-	 * @param Comment $comment
76
-	 * @return Comment
77
-	 */
78
-	public function testUpdate(Comment $comment) {
79
-		$newComment = Faker::paragraph();
80
-		$comment->setComment($newComment());
81
-		$this->commentMapper->update($comment);
71
+    /**
72
+     * Update the previously created entry and persist the changes.
73
+     *
74
+     * @depends testCreate
75
+     * @param Comment $comment
76
+     * @return Comment
77
+     */
78
+    public function testUpdate(Comment $comment) {
79
+        $newComment = Faker::paragraph();
80
+        $comment->setComment($newComment());
81
+        $this->commentMapper->update($comment);
82 82
 
83
-		return $comment;
84
-	}
83
+        return $comment;
84
+    }
85 85
 
86
-	/**
87
-	 * Delete the previously created entries from the database.
88
-	 *
89
-	 * @depends testUpdate
90
-	 * @param Comment $comment
91
-	 */
92
-	public function testDelete(Comment $comment) {
93
-		$event = $this->eventMapper->find($comment->getPollId());
94
-		$this->commentMapper->delete($comment);
95
-		$this->eventMapper->delete($event);
96
-	}
86
+    /**
87
+     * Delete the previously created entries from the database.
88
+     *
89
+     * @depends testUpdate
90
+     * @param Comment $comment
91
+     */
92
+    public function testDelete(Comment $comment) {
93
+        $event = $this->eventMapper->find($comment->getPollId());
94
+        $this->commentMapper->delete($comment);
95
+        $this->eventMapper->delete($event);
96
+    }
97 97
 }
Please login to merge, or discard this patch.