Completed
Push — master ( aa4716...a8dc32 )
by Jacob
04:06
created
tests/unit/Domain/Blog/Introduction/MysqlIntroductionRepositoryTest.php 1 patch
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 class MysqlIntroductionRepositoryTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    protected static $connection;
12
+	protected static $connection;
13 13
 
14
-    public static function setUpBeforeClass()
15
-    {
16
-        $extendedPdo = new ExtendedPdo('sqlite::memory:');
17
-        $extendedPdo->exec("ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`");
14
+	public static function setUpBeforeClass()
15
+	{
16
+		$extendedPdo = new ExtendedPdo('sqlite::memory:');
17
+		$extendedPdo->exec("ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`");
18 18
 
19
-        $extendedPdo->exec("
19
+		$extendedPdo->exec("
20 20
             CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`introduction` (
21 21
                 `id` integer PRIMARY KEY AUTOINCREMENT,
22 22
                 `type` varchar(10) NOT NULL,
@@ -25,134 +25,134 @@  discard block
 block discarded – undo
25 25
                 `content` text NOT NULL,
26 26
                 `image` image
27 27
             )"
28
-        );
29
-
30
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
31
-            return $extendedPdo;
32
-        });
33
-    }
34
-
35
-    public function testIsInstanceOfIntroductionRepository()
36
-    {
37
-        $repository = new MysqlIntroductionRepository(self::$connection);
38
-
39
-        $this->assertInstanceOf(
40
-            'Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository',
41
-            $repository
42
-        );
43
-    }
44
-
45
-    public function testImplementsIntroductionInterface()
46
-    {
47
-        $repository = new MysqlIntroductionRepository(self::$connection);
48
-
49
-        $this->assertInstanceOf(
50
-            'Jacobemerick\Web\Domain\Blog\Introduction\IntroductionRepositoryInterface',
51
-            $repository
52
-        );
53
-    }
54
-
55
-    public function testConstructSetsConnections()
56
-    {
57
-        $respository = new MysqlIntroductionRepository(self::$connection);
58
-
59
-        $this->assertAttributeSame(
60
-            self::$connection,
61
-            'connections',
62
-            $respository
63
-        );
64
-    }
65
-
66
-    public function testFindByType()
67
-    {
68
-        $testData = [
69
-            'id' => rand(1, 100),
70
-            'type' => 'test',
71
-            'title' => 'test title',
72
-            'content' => 'test content',
73
-            'image' => rand(1, 100),
74
-        ];
75
-
76
-        $this->insertData($testData);
77
-
78
-        $repository = new MysqlIntroductionRepository(self::$connection);
79
-        $data = $repository->findByType('test');
80
-
81
-        $this->assertNotFalse($data);
82
-        $this->assertInternalType('array', $data);
83
-        $this->assertArrayHasKey('title', $data);
84
-        $this->assertEquals($testData['title'], $data['title']);
85
-        $this->assertArrayHasKey('content', $data);
86
-        $this->assertEquals($testData['content'], $data['content']);
87
-        $this->assertArrayHasKey('image', $data);
88
-        $this->assertEquals($testData['image'], $data['image']);
89
-    }
90
-
91
-    public function testFindByTypeFilterValue()
92
-    {
93
-        $testData = [
94
-            [
95
-                'id' => rand(1, 100),
96
-                'type' => 'test',
97
-                'title' => 'title a',
98
-                'value' => 'value a',
99
-            ],
100
-            [
101
-                'id' => rand(101, 200),
102
-                'type' => 'test',
103
-                'title' => 'title b',
104
-                'value' => 'value b',
105
-            ],
106
-        ];
107
-
108
-        array_walk($testData, [$this, 'insertData']);
109
-
110
-        $repository = new MysqlIntroductionRepository(self::$connection);
111
-        $data = $repository->findByType('test', reset($testData)['value']);
112
-
113
-        $this->assertNotFalse($data);
114
-        $this->assertInternalType('array', $data);
115
-        $this->assertEquals(reset($testData)['title'], $data['title']);
116
-    }
28
+		);
29
+
30
+		self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
31
+			return $extendedPdo;
32
+		});
33
+	}
34
+
35
+	public function testIsInstanceOfIntroductionRepository()
36
+	{
37
+		$repository = new MysqlIntroductionRepository(self::$connection);
38
+
39
+		$this->assertInstanceOf(
40
+			'Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository',
41
+			$repository
42
+		);
43
+	}
44
+
45
+	public function testImplementsIntroductionInterface()
46
+	{
47
+		$repository = new MysqlIntroductionRepository(self::$connection);
48
+
49
+		$this->assertInstanceOf(
50
+			'Jacobemerick\Web\Domain\Blog\Introduction\IntroductionRepositoryInterface',
51
+			$repository
52
+		);
53
+	}
54
+
55
+	public function testConstructSetsConnections()
56
+	{
57
+		$respository = new MysqlIntroductionRepository(self::$connection);
58
+
59
+		$this->assertAttributeSame(
60
+			self::$connection,
61
+			'connections',
62
+			$respository
63
+		);
64
+	}
65
+
66
+	public function testFindByType()
67
+	{
68
+		$testData = [
69
+			'id' => rand(1, 100),
70
+			'type' => 'test',
71
+			'title' => 'test title',
72
+			'content' => 'test content',
73
+			'image' => rand(1, 100),
74
+		];
75
+
76
+		$this->insertData($testData);
77
+
78
+		$repository = new MysqlIntroductionRepository(self::$connection);
79
+		$data = $repository->findByType('test');
80
+
81
+		$this->assertNotFalse($data);
82
+		$this->assertInternalType('array', $data);
83
+		$this->assertArrayHasKey('title', $data);
84
+		$this->assertEquals($testData['title'], $data['title']);
85
+		$this->assertArrayHasKey('content', $data);
86
+		$this->assertEquals($testData['content'], $data['content']);
87
+		$this->assertArrayHasKey('image', $data);
88
+		$this->assertEquals($testData['image'], $data['image']);
89
+	}
90
+
91
+	public function testFindByTypeFilterValue()
92
+	{
93
+		$testData = [
94
+			[
95
+				'id' => rand(1, 100),
96
+				'type' => 'test',
97
+				'title' => 'title a',
98
+				'value' => 'value a',
99
+			],
100
+			[
101
+				'id' => rand(101, 200),
102
+				'type' => 'test',
103
+				'title' => 'title b',
104
+				'value' => 'value b',
105
+			],
106
+		];
107
+
108
+		array_walk($testData, [$this, 'insertData']);
109
+
110
+		$repository = new MysqlIntroductionRepository(self::$connection);
111
+		$data = $repository->findByType('test', reset($testData)['value']);
112
+
113
+		$this->assertNotFalse($data);
114
+		$this->assertInternalType('array', $data);
115
+		$this->assertEquals(reset($testData)['title'], $data['title']);
116
+	}
117 117
  
118
-    public function testFindByTypeFailure()
119
-    {
120
-        $repository = new MysqlIntroductionRepository(self::$connection);
121
-        $data = $repository->findByType('empty type');
122
-
123
-        $this->assertFalse($data);
124
-    }
125
-
126
-    protected function insertData(array $data)
127
-    {
128
-        $defaultData = [
129
-            'id' => null,
130
-            'type' => '',
131
-            'value' => '',
132
-            'title' => '',
133
-            'content' => '',
134
-            'image' => null,
135
-        ];
136
-
137
-        $data = array_merge($defaultData, $data);
138
-
139
-        return self::$connection->getDefault()->perform("
118
+	public function testFindByTypeFailure()
119
+	{
120
+		$repository = new MysqlIntroductionRepository(self::$connection);
121
+		$data = $repository->findByType('empty type');
122
+
123
+		$this->assertFalse($data);
124
+	}
125
+
126
+	protected function insertData(array $data)
127
+	{
128
+		$defaultData = [
129
+			'id' => null,
130
+			'type' => '',
131
+			'value' => '',
132
+			'title' => '',
133
+			'content' => '',
134
+			'image' => null,
135
+		];
136
+
137
+		$data = array_merge($defaultData, $data);
138
+
139
+		return self::$connection->getDefault()->perform("
140 140
             INSERT INTO `jpemeric_blog`.`introduction`
141 141
                 (id, type, value, title, content, image)
142 142
             VALUES
143 143
                 (:id, :type, :value, :title, :content, :image)",
144
-            $data
145
-        );
146
-    }
147
-
148
-    protected function tearDown()
149
-    {
150
-        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_blog`.`introduction`");
151
-    }
152
-
153
-    public static function tearDownAfterClass()
154
-    {
155
-        self::$connection->getDefault()->disconnect();
156
-        unlink('jpemeric_blog.db');
157
-    }
144
+			$data
145
+		);
146
+	}
147
+
148
+	protected function tearDown()
149
+	{
150
+		self::$connection->getDefault()->perform("DELETE FROM `jpemeric_blog`.`introduction`");
151
+	}
152
+
153
+	public static function tearDownAfterClass()
154
+	{
155
+		self::$connection->getDefault()->disconnect();
156
+		unlink('jpemeric_blog.db');
157
+	}
158 158
 }
Please login to merge, or discard this patch.
tests/unit/Domain/Stream/Activity/MysqlActivityRepositoryTest.php 1 patch
Indentation   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 class MysqlActivityRepositoryTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    protected static $connection;
12
+	protected static $connection;
13 13
 
14
-    public static function setUpBeforeClass()
15
-    {
16
-        $extendedPdo = new ExtendedPdo('sqlite::memory:');
17
-        $extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`");
14
+	public static function setUpBeforeClass()
15
+	{
16
+		$extendedPdo = new ExtendedPdo('sqlite::memory:');
17
+		$extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`");
18 18
 
19
-        $extendedPdo->exec("
19
+		$extendedPdo->exec("
20 20
             CREATE TABLE IF NOT EXISTS `jpemeric_stream`.`activity` (
21 21
                 `id` integer PRIMARY KEY AUTOINCREMENT,
22 22
                 `message` text NOT NULL,
@@ -28,428 +28,428 @@  discard block
 block discarded – undo
28 28
                 `created_at` datetime,
29 29
                 `updated_at` datetime
30 30
             )"
31
-        );
32
-
33
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
34
-            return $extendedPdo;
35
-        });
36
-    }
37
-
38
-    public function testIsInstanceOfActivityRepository()
39
-    {
40
-        $repository = new MysqlActivityRepository(self::$connection);
41
-
42
-        $this->assertInstanceOf(
43
-            'Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository',
44
-            $repository
45
-        );
46
-    }
47
-
48
-    public function testImplementsActivityInterface()
49
-    {
50
-        $repository = new MysqlActivityRepository(self::$connection);
51
-
52
-        $this->assertInstanceOf(
53
-            'Jacobemerick\Web\Domain\Stream\Activity\ActivityRepositoryInterface',
54
-            $repository
55
-        );
56
-    }
57
-
58
-    public function testConstructSetsConnections()
59
-    {
60
-        $respository = new MysqlActivityRepository(self::$connection);
61
-
62
-        $this->assertAttributeSame(
63
-            self::$connection,
64
-            'connections',
65
-            $respository
66
-        );
67
-    }
68
-
69
-    public function testGetActivityById()
70
-    {
71
-        $testData = [
72
-            'id' => rand(1, 100),
73
-            'message' => 'test data',
74
-        ];
75
-
76
-        $this->insertData($testData);
77
-
78
-        $repository = new MysqlActivityRepository(self::$connection);
79
-        $data = $repository->getActivityById($testData['id']);
80
-
81
-        $this->assertNotFalse($data);
82
-        $this->assertInternalType('array', $data);
83
-        $this->assertArraySubset($testData, $data);
84
-    }
85
-
86
-    public function testGetActivityByIdFailure()
87
-    {
88
-        $testData = [
89
-            'id' => rand(1, 100),
90
-            'message' => 'test data',
91
-        ];
92
-
93
-        $this->insertData($testData);
94
-
95
-        $repository = new MysqlActivityRepository(self::$connection);
96
-        $data = $repository->getActivityById($testData['id'] + 1);
97
-
98
-        $this->assertFalse($data);
99
-    }
100
-
101
-    public function testGetActivities()
102
-    {
103
-        $testData = [
104
-            [
105
-                'id' => rand(1, 100),
106
-                'message' => 'test one',
107
-            ],
108
-            [
109
-                'id' => rand(101, 200),
110
-                'message' => 'test two',
111
-            ],
112
-        ];
113
-
114
-        array_walk($testData, [$this, 'insertData']);
115
-
116
-        $repository = new MysqlActivityRepository(self::$connection);
117
-        $data = $repository->getActivities();
118
-
119
-        $this->assertNotFalse($data);
120
-        $this->assertInternalType('array', $data);
121
-        foreach ($testData as $key => $testRow) {
122
-            $this->assertInternalType('array', $data[$key]);
123
-            $this->assertArraySubset($testRow, $data[$key]);
124
-        }
125
-    }
126
-
127
-    public function testGetActivitiesFailure()
128
-    {
129
-        $repository = new MysqlActivityRepository(self::$connection);
130
-        $data = $repository->getActivities();
131
-
132
-        $this->assertEmpty($data);
133
-        $this->assertInternalType('array', $data);
134
-    }
135
-
136
-    public function testGetActivitiesRange()
137
-    {
138
-        $testData = [
139
-            [
140
-                'id' => rand(1, 100),
141
-                'message' => 'test one',
142
-            ],
143
-            [
144
-                'id' => rand(101, 200),
145
-                'message' => 'test two',
146
-            ],
147
-            [
148
-                'id' => rand(201, 300),
149
-                'message' => 'test three',
150
-            ],
151
-        ];
152
-
153
-        array_walk($testData, [$this, 'insertData']);
154
-
155
-        $repository = new MysqlActivityRepository(self::$connection);
156
-        $data = $repository->getActivities(2, 1);
157
-
158
-        $this->assertNotFalse($data);
159
-        $this->assertInternalType('array', $data);
160
-        $this->assertCount(2, $data);
161
-
162
-        $testData = array_slice($testData, 1, 2);
163
-
164
-        foreach ($testData as $key => $testRow) {
165
-            $this->assertInternalType('array', $data[$key]);
166
-            $this->assertArraySubset($testRow, $data[$key]);
167
-        }
168
-    }
169
-
170
-    public function testGetActivitiesRangeFailure()
171
-    {
172
-        $testData = [
173
-            [
174
-                'id' => rand(1, 100),
175
-                'message' => 'test one',
176
-            ],
177
-            [
178
-                'id' => rand(101, 200),
179
-                'message' => 'test two',
180
-            ],
181
-        ];
182
-
183
-        array_walk($testData, [$this, 'insertData']);
184
-
185
-        $repository = new MysqlActivityRepository(self::$connection);
186
-        $data = $repository->getActivities(1, 3);
187
-
188
-        $this->assertEmpty($data);
189
-        $this->assertInternalType('array', $data);
190
-    }
191
-
192
-    public function testGetActivitiesCount()
193
-    {
194
-        $testData = [
195
-            [
196
-                'id' => rand(1, 100),
197
-                'message' => 'test one',
198
-            ],
199
-            [
200
-                'id' => rand(101, 200),
201
-                'message' => 'test two',
202
-            ],
203
-        ];
204
-
205
-        array_walk($testData, [$this, 'insertData']);
206
-
207
-        $repository = new MysqlActivityRepository(self::$connection);
208
-        $data = $repository->getActivitiesCount();
209
-
210
-        $this->assertNotFalse($data);
211
-        $this->assertStringMatchesFormat('%d', $data);
212
-        $this->assertEquals(count($testData), $data);
213
-    }
214
-
215
-    public function testGetActivitiesCountEmpty()
216
-    {
217
-        $repository = new MysqlActivityRepository(self::$connection);
218
-        $data = $repository->getActivitiesCount();
219
-
220
-        $this->assertNotFalse($data);
221
-        $this->assertStringMatchesFormat('%d', $data);
222
-        $this->assertEquals('0', $data);
223
-    }
224
-
225
-    public function testGetActivitiesByType()
226
-    {
227
-        $testData = [
228
-            [
229
-                'id' => rand(1, 100),
230
-                'message' => 'test one',
231
-                'type' => 'type one',
232
-            ],
233
-            [
234
-                'id' => rand(101, 200),
235
-                'message' => 'test two',
236
-                'type' => 'type two',
237
-            ],
238
-            [
239
-                'id' => rand(201, 300),
240
-                'message' => 'test three',
241
-                'type' => 'type one',
242
-            ],
243
-        ];
244
-
245
-        array_walk($testData, [$this, 'insertData']);
246
-
247
-        $repository = new MysqlActivityRepository(self::$connection);
248
-        $data = $repository->getActivitiesByType('type one');
249
-
250
-        $this->assertNotFalse($data);
251
-        $this->assertInternalType('array', $data);
252
-
253
-        $testData = array_filter($testData, function ($row) {
254
-            return ($row['type'] == 'type one');
255
-        });
256
-        $testData = array_values($testData);
257
-
258
-        foreach ($testData as $key => $testRow) {
259
-            $this->assertInternalType('array', $data[$key]);
260
-            $this->assertArraySubset($testRow, $data[$key]);
261
-        }
262
-    }
263
-
264
-    public function testGetActivitiesByTypeFailure()
265
-    {
266
-        $testData = [
267
-            [
268
-                'id' => rand(1, 100),
269
-                'message' => 'test one',
270
-                'type' => 'type one',
271
-            ],
272
-            [
273
-                'id' => rand(101, 200),
274
-                'message' => 'test two',
275
-                'type' => 'type one',
276
-            ],
277
-        ];
278
-
279
-        array_walk($testData, [$this, 'insertData']);
280
-
281
-        $repository = new MysqlActivityRepository(self::$connection);
282
-        $data = $repository->getActivitiesByType('type two');
283
-
284
-        $this->assertEmpty($data);
285
-        $this->assertInternalType('array', $data);
286
-    }
287
-
288
-    public function testGetActivitiesByTypeRange()
289
-    {
290
-        $testData = [
291
-            [
292
-                'id' => rand(1, 100),
293
-                'message' => 'test one',
294
-                'type' => 'type one',
295
-            ],
296
-            [
297
-                'id' => rand(101, 200),
298
-                'message' => 'test two',
299
-                'type' => 'type two',
300
-            ],
301
-            [
302
-                'id' => rand(201, 300),
303
-                'message' => 'test three',
304
-                'type' => 'type one',
305
-            ],
306
-            [
307
-                'id' => rand(301, 400),
308
-                'message' => 'test four',
309
-                'type' => 'type one',
310
-            ],
311
-        ];
312
-
313
-        array_walk($testData, [$this, 'insertData']);
314
-
315
-        $repository = new MysqlActivityRepository(self::$connection);
316
-        $data = $repository->getActivitiesByType('type one', 2, 1);
317
-
318
-        $this->assertNotFalse($data);
319
-        $this->assertInternalType('array', $data);
320
-        $this->assertCount(2, $data);
321
-
322
-        $testData = array_filter($testData, function ($row) {
323
-            return ($row['type'] == 'type one');
324
-        });
325
-        $testData = array_values($testData);
326
-        $testData = array_slice($testData, 1, 2);
327
-
328
-        foreach ($testData as $key => $testRow) {
329
-            $this->assertInternalType('array', $data[$key]);
330
-            $this->assertArraySubset($testRow, $data[$key]);
331
-        }
332
-    }
333
-
334
-    public function testGetActivitiesByTypeRangeFailure()
335
-    {
336
-        $testData = [
337
-            [
338
-                'id' => rand(1, 100),
339
-                'message' => 'test one',
340
-                'type' => 'type one',
341
-            ],
342
-            [
343
-                'id' => rand(101, 200),
344
-                'message' => 'test two',
345
-                'type' => 'type one',
346
-            ],
347
-            [
348
-                'id' => rand(201, 300),
349
-                'message' => 'test three',
350
-                'type' => 'type one',
351
-            ],
352
-        ];
353
-
354
-        array_walk($testData, [$this, 'insertData']);
355
-
356
-        $repository = new MysqlActivityRepository(self::$connection);
357
-        $data = $repository->getActivitiesByType('type two', 2, 1);
358
-
359
-        $this->assertEmpty($data);
360
-        $this->assertInternalType('array', $data);
361
-    }
362
-
363
-    public function testGetActivitiesByTypeCount()
364
-    {
365
-        $testData = [
366
-            [
367
-                'id' => rand(1, 100),
368
-                'message' => 'test one',
369
-                'type' => 'type one',
370
-            ],
371
-            [
372
-                'id' => rand(101, 200),
373
-                'message' => 'test two',
374
-                'type' => 'type two',
375
-            ],
376
-            [
377
-                'id' => rand(201, 300),
378
-                'message' => 'test three',
379
-                'type' => 'type one',
380
-            ],
381
-        ];
382
-
383
-        array_walk($testData, [$this, 'insertData']);
384
-
385
-        $repository = new MysqlActivityRepository(self::$connection);
386
-        $data = $repository->getActivitiesByTypeCount('type one');
387
-
388
-        $testData = array_filter($testData, function ($row) {
389
-            return ($row['type'] == 'type one');
390
-        });
391
-
392
-        $this->assertNotFalse($data);
393
-        $this->assertStringMatchesFormat('%d', $data);
394
-        $this->assertEquals(count($testData), $data);
395
-    }
396
-
397
-    public function testGetActivitiesByTypeCountEmpty()
398
-    {
399
-        $testData = [
400
-            [
401
-                'id' => rand(1, 100),
402
-                'message' => 'test one',
403
-                'type' => 'type one',
404
-            ],
405
-            [
406
-                'id' => rand(101, 200),
407
-                'message' => 'test two',
408
-                'type' => 'type one',
409
-            ],
410
-        ];
411
-
412
-        array_walk($testData, [$this, 'insertData']);
413
-
414
-        $repository = new MysqlActivityRepository(self::$connection);
415
-        $data = $repository->getActivitiesByTypeCount('type two');
416
-
417
-        $this->assertNotFalse($data);
418
-        $this->assertStringMatchesFormat('%d', $data);
419
-        $this->assertEquals('0', $data);
420
-    }
421
-
422
-    protected function insertData(array $data)
423
-    {
424
-        $defaultData = [
425
-            'id' => null,
426
-            'message' => '',
427
-            'message_long' => '',
428
-            'datetime' => '',
429
-            'metadata' => '',
430
-            'type' => '',
431
-            'type_id' => '',
432
-        ];
433
-
434
-        $data = array_merge($defaultData, $data);
435
-
436
-        return self::$connection->getDefault()->perform("
31
+		);
32
+
33
+		self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
34
+			return $extendedPdo;
35
+		});
36
+	}
37
+
38
+	public function testIsInstanceOfActivityRepository()
39
+	{
40
+		$repository = new MysqlActivityRepository(self::$connection);
41
+
42
+		$this->assertInstanceOf(
43
+			'Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository',
44
+			$repository
45
+		);
46
+	}
47
+
48
+	public function testImplementsActivityInterface()
49
+	{
50
+		$repository = new MysqlActivityRepository(self::$connection);
51
+
52
+		$this->assertInstanceOf(
53
+			'Jacobemerick\Web\Domain\Stream\Activity\ActivityRepositoryInterface',
54
+			$repository
55
+		);
56
+	}
57
+
58
+	public function testConstructSetsConnections()
59
+	{
60
+		$respository = new MysqlActivityRepository(self::$connection);
61
+
62
+		$this->assertAttributeSame(
63
+			self::$connection,
64
+			'connections',
65
+			$respository
66
+		);
67
+	}
68
+
69
+	public function testGetActivityById()
70
+	{
71
+		$testData = [
72
+			'id' => rand(1, 100),
73
+			'message' => 'test data',
74
+		];
75
+
76
+		$this->insertData($testData);
77
+
78
+		$repository = new MysqlActivityRepository(self::$connection);
79
+		$data = $repository->getActivityById($testData['id']);
80
+
81
+		$this->assertNotFalse($data);
82
+		$this->assertInternalType('array', $data);
83
+		$this->assertArraySubset($testData, $data);
84
+	}
85
+
86
+	public function testGetActivityByIdFailure()
87
+	{
88
+		$testData = [
89
+			'id' => rand(1, 100),
90
+			'message' => 'test data',
91
+		];
92
+
93
+		$this->insertData($testData);
94
+
95
+		$repository = new MysqlActivityRepository(self::$connection);
96
+		$data = $repository->getActivityById($testData['id'] + 1);
97
+
98
+		$this->assertFalse($data);
99
+	}
100
+
101
+	public function testGetActivities()
102
+	{
103
+		$testData = [
104
+			[
105
+				'id' => rand(1, 100),
106
+				'message' => 'test one',
107
+			],
108
+			[
109
+				'id' => rand(101, 200),
110
+				'message' => 'test two',
111
+			],
112
+		];
113
+
114
+		array_walk($testData, [$this, 'insertData']);
115
+
116
+		$repository = new MysqlActivityRepository(self::$connection);
117
+		$data = $repository->getActivities();
118
+
119
+		$this->assertNotFalse($data);
120
+		$this->assertInternalType('array', $data);
121
+		foreach ($testData as $key => $testRow) {
122
+			$this->assertInternalType('array', $data[$key]);
123
+			$this->assertArraySubset($testRow, $data[$key]);
124
+		}
125
+	}
126
+
127
+	public function testGetActivitiesFailure()
128
+	{
129
+		$repository = new MysqlActivityRepository(self::$connection);
130
+		$data = $repository->getActivities();
131
+
132
+		$this->assertEmpty($data);
133
+		$this->assertInternalType('array', $data);
134
+	}
135
+
136
+	public function testGetActivitiesRange()
137
+	{
138
+		$testData = [
139
+			[
140
+				'id' => rand(1, 100),
141
+				'message' => 'test one',
142
+			],
143
+			[
144
+				'id' => rand(101, 200),
145
+				'message' => 'test two',
146
+			],
147
+			[
148
+				'id' => rand(201, 300),
149
+				'message' => 'test three',
150
+			],
151
+		];
152
+
153
+		array_walk($testData, [$this, 'insertData']);
154
+
155
+		$repository = new MysqlActivityRepository(self::$connection);
156
+		$data = $repository->getActivities(2, 1);
157
+
158
+		$this->assertNotFalse($data);
159
+		$this->assertInternalType('array', $data);
160
+		$this->assertCount(2, $data);
161
+
162
+		$testData = array_slice($testData, 1, 2);
163
+
164
+		foreach ($testData as $key => $testRow) {
165
+			$this->assertInternalType('array', $data[$key]);
166
+			$this->assertArraySubset($testRow, $data[$key]);
167
+		}
168
+	}
169
+
170
+	public function testGetActivitiesRangeFailure()
171
+	{
172
+		$testData = [
173
+			[
174
+				'id' => rand(1, 100),
175
+				'message' => 'test one',
176
+			],
177
+			[
178
+				'id' => rand(101, 200),
179
+				'message' => 'test two',
180
+			],
181
+		];
182
+
183
+		array_walk($testData, [$this, 'insertData']);
184
+
185
+		$repository = new MysqlActivityRepository(self::$connection);
186
+		$data = $repository->getActivities(1, 3);
187
+
188
+		$this->assertEmpty($data);
189
+		$this->assertInternalType('array', $data);
190
+	}
191
+
192
+	public function testGetActivitiesCount()
193
+	{
194
+		$testData = [
195
+			[
196
+				'id' => rand(1, 100),
197
+				'message' => 'test one',
198
+			],
199
+			[
200
+				'id' => rand(101, 200),
201
+				'message' => 'test two',
202
+			],
203
+		];
204
+
205
+		array_walk($testData, [$this, 'insertData']);
206
+
207
+		$repository = new MysqlActivityRepository(self::$connection);
208
+		$data = $repository->getActivitiesCount();
209
+
210
+		$this->assertNotFalse($data);
211
+		$this->assertStringMatchesFormat('%d', $data);
212
+		$this->assertEquals(count($testData), $data);
213
+	}
214
+
215
+	public function testGetActivitiesCountEmpty()
216
+	{
217
+		$repository = new MysqlActivityRepository(self::$connection);
218
+		$data = $repository->getActivitiesCount();
219
+
220
+		$this->assertNotFalse($data);
221
+		$this->assertStringMatchesFormat('%d', $data);
222
+		$this->assertEquals('0', $data);
223
+	}
224
+
225
+	public function testGetActivitiesByType()
226
+	{
227
+		$testData = [
228
+			[
229
+				'id' => rand(1, 100),
230
+				'message' => 'test one',
231
+				'type' => 'type one',
232
+			],
233
+			[
234
+				'id' => rand(101, 200),
235
+				'message' => 'test two',
236
+				'type' => 'type two',
237
+			],
238
+			[
239
+				'id' => rand(201, 300),
240
+				'message' => 'test three',
241
+				'type' => 'type one',
242
+			],
243
+		];
244
+
245
+		array_walk($testData, [$this, 'insertData']);
246
+
247
+		$repository = new MysqlActivityRepository(self::$connection);
248
+		$data = $repository->getActivitiesByType('type one');
249
+
250
+		$this->assertNotFalse($data);
251
+		$this->assertInternalType('array', $data);
252
+
253
+		$testData = array_filter($testData, function ($row) {
254
+			return ($row['type'] == 'type one');
255
+		});
256
+		$testData = array_values($testData);
257
+
258
+		foreach ($testData as $key => $testRow) {
259
+			$this->assertInternalType('array', $data[$key]);
260
+			$this->assertArraySubset($testRow, $data[$key]);
261
+		}
262
+	}
263
+
264
+	public function testGetActivitiesByTypeFailure()
265
+	{
266
+		$testData = [
267
+			[
268
+				'id' => rand(1, 100),
269
+				'message' => 'test one',
270
+				'type' => 'type one',
271
+			],
272
+			[
273
+				'id' => rand(101, 200),
274
+				'message' => 'test two',
275
+				'type' => 'type one',
276
+			],
277
+		];
278
+
279
+		array_walk($testData, [$this, 'insertData']);
280
+
281
+		$repository = new MysqlActivityRepository(self::$connection);
282
+		$data = $repository->getActivitiesByType('type two');
283
+
284
+		$this->assertEmpty($data);
285
+		$this->assertInternalType('array', $data);
286
+	}
287
+
288
+	public function testGetActivitiesByTypeRange()
289
+	{
290
+		$testData = [
291
+			[
292
+				'id' => rand(1, 100),
293
+				'message' => 'test one',
294
+				'type' => 'type one',
295
+			],
296
+			[
297
+				'id' => rand(101, 200),
298
+				'message' => 'test two',
299
+				'type' => 'type two',
300
+			],
301
+			[
302
+				'id' => rand(201, 300),
303
+				'message' => 'test three',
304
+				'type' => 'type one',
305
+			],
306
+			[
307
+				'id' => rand(301, 400),
308
+				'message' => 'test four',
309
+				'type' => 'type one',
310
+			],
311
+		];
312
+
313
+		array_walk($testData, [$this, 'insertData']);
314
+
315
+		$repository = new MysqlActivityRepository(self::$connection);
316
+		$data = $repository->getActivitiesByType('type one', 2, 1);
317
+
318
+		$this->assertNotFalse($data);
319
+		$this->assertInternalType('array', $data);
320
+		$this->assertCount(2, $data);
321
+
322
+		$testData = array_filter($testData, function ($row) {
323
+			return ($row['type'] == 'type one');
324
+		});
325
+		$testData = array_values($testData);
326
+		$testData = array_slice($testData, 1, 2);
327
+
328
+		foreach ($testData as $key => $testRow) {
329
+			$this->assertInternalType('array', $data[$key]);
330
+			$this->assertArraySubset($testRow, $data[$key]);
331
+		}
332
+	}
333
+
334
+	public function testGetActivitiesByTypeRangeFailure()
335
+	{
336
+		$testData = [
337
+			[
338
+				'id' => rand(1, 100),
339
+				'message' => 'test one',
340
+				'type' => 'type one',
341
+			],
342
+			[
343
+				'id' => rand(101, 200),
344
+				'message' => 'test two',
345
+				'type' => 'type one',
346
+			],
347
+			[
348
+				'id' => rand(201, 300),
349
+				'message' => 'test three',
350
+				'type' => 'type one',
351
+			],
352
+		];
353
+
354
+		array_walk($testData, [$this, 'insertData']);
355
+
356
+		$repository = new MysqlActivityRepository(self::$connection);
357
+		$data = $repository->getActivitiesByType('type two', 2, 1);
358
+
359
+		$this->assertEmpty($data);
360
+		$this->assertInternalType('array', $data);
361
+	}
362
+
363
+	public function testGetActivitiesByTypeCount()
364
+	{
365
+		$testData = [
366
+			[
367
+				'id' => rand(1, 100),
368
+				'message' => 'test one',
369
+				'type' => 'type one',
370
+			],
371
+			[
372
+				'id' => rand(101, 200),
373
+				'message' => 'test two',
374
+				'type' => 'type two',
375
+			],
376
+			[
377
+				'id' => rand(201, 300),
378
+				'message' => 'test three',
379
+				'type' => 'type one',
380
+			],
381
+		];
382
+
383
+		array_walk($testData, [$this, 'insertData']);
384
+
385
+		$repository = new MysqlActivityRepository(self::$connection);
386
+		$data = $repository->getActivitiesByTypeCount('type one');
387
+
388
+		$testData = array_filter($testData, function ($row) {
389
+			return ($row['type'] == 'type one');
390
+		});
391
+
392
+		$this->assertNotFalse($data);
393
+		$this->assertStringMatchesFormat('%d', $data);
394
+		$this->assertEquals(count($testData), $data);
395
+	}
396
+
397
+	public function testGetActivitiesByTypeCountEmpty()
398
+	{
399
+		$testData = [
400
+			[
401
+				'id' => rand(1, 100),
402
+				'message' => 'test one',
403
+				'type' => 'type one',
404
+			],
405
+			[
406
+				'id' => rand(101, 200),
407
+				'message' => 'test two',
408
+				'type' => 'type one',
409
+			],
410
+		];
411
+
412
+		array_walk($testData, [$this, 'insertData']);
413
+
414
+		$repository = new MysqlActivityRepository(self::$connection);
415
+		$data = $repository->getActivitiesByTypeCount('type two');
416
+
417
+		$this->assertNotFalse($data);
418
+		$this->assertStringMatchesFormat('%d', $data);
419
+		$this->assertEquals('0', $data);
420
+	}
421
+
422
+	protected function insertData(array $data)
423
+	{
424
+		$defaultData = [
425
+			'id' => null,
426
+			'message' => '',
427
+			'message_long' => '',
428
+			'datetime' => '',
429
+			'metadata' => '',
430
+			'type' => '',
431
+			'type_id' => '',
432
+		];
433
+
434
+		$data = array_merge($defaultData, $data);
435
+
436
+		return self::$connection->getDefault()->perform("
437 437
             INSERT INTO `jpemeric_stream`.`activity`
438 438
                 (id, message, message_long, datetime, metadata, type, type_id)
439 439
             VALUES
440 440
                 (:id, :message, :message_long, :datetime, :metadata, :type, :type_id)",
441
-            $data
442
-        );
443
-    }
444
-
445
-    protected function tearDown()
446
-    {
447
-        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`activity`");
448
-    }
449
-
450
-    public static function tearDownAfterClass()
451
-    {
452
-        self::$connection->getDefault()->disconnect();
453
-        unlink('jpemeric_stream.db');
454
-    }
441
+			$data
442
+		);
443
+	}
444
+
445
+	protected function tearDown()
446
+	{
447
+		self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`activity`");
448
+	}
449
+
450
+	public static function tearDownAfterClass()
451
+	{
452
+		self::$connection->getDefault()->disconnect();
453
+		unlink('jpemeric_stream.db');
454
+	}
455 455
 }
Please login to merge, or discard this patch.
tests/unit/Domain/Stream/Changelog/MysqlChangelogRepositoryTest.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 class MysqlChangelogRepositoryTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    protected static $connection;
12
+	protected static $connection;
13 13
 
14
-    public static function setUpBeforeClass()
15
-    {
16
-        $extendedPdo = new ExtendedPdo('sqlite::memory:');
17
-        $extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`");
14
+	public static function setUpBeforeClass()
15
+	{
16
+		$extendedPdo = new ExtendedPdo('sqlite::memory:');
17
+		$extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`");
18 18
 
19
-        $extendedPdo->exec("
19
+		$extendedPdo->exec("
20 20
             CREATE TABLE IF NOT EXISTS `jpemeric_stream`.`changelog` (
21 21
                 `id` integer PRIMARY KEY AUTOINCREMENT,
22 22
                 `hash` char(40) NOT NULL,
@@ -28,171 +28,171 @@  discard block
 block discarded – undo
28 28
                 `created_at` datetime,
29 29
                 `updated_at` datetime
30 30
             )"
31
-        );
32
-
33
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
34
-            return $extendedPdo;
35
-        });
36
-    }
37
-
38
-    public function testIsInstanceOfChangelogRepository()
39
-    {
40
-        $repository = new MysqlChangelogRepository(self::$connection);
41
-
42
-        $this->assertInstanceOf(
43
-            'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository',
44
-            $repository
45
-        );
46
-    }
47
-
48
-    public function testImplementsChangelogInterface()
49
-    {
50
-        $repository = new MysqlChangelogRepository(self::$connection);
51
-
52
-        $this->assertInstanceOf(
53
-            'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface',
54
-            $repository
55
-        );
56
-    }
57
-
58
-    public function testConstructSetsConnections()
59
-    {
60
-        $respository = new MysqlChangelogRepository(self::$connection);
61
-
62
-        $this->assertAttributeSame(
63
-            self::$connection,
64
-            'connections',
65
-            $respository
66
-        );
67
-    }
68
-
69
-    public function testGetChanges()
70
-    {
71
-        $testData = [
72
-            [
73
-                'id' => rand(1, 100),
74
-                'message' => 'test one',
75
-            ],
76
-            [
77
-                'id' => rand(101, 200),
78
-                'message' => 'test two',
79
-            ],
80
-        ];
81
-
82
-        array_walk($testData, [$this, 'insertData']);
83
-
84
-        $repository = new MysqlChangelogRepository(self::$connection);
85
-        $data = $repository->getChanges();
86
-
87
-        $this->assertNotFalse($data);
88
-        $this->assertInternalType('array', $data);
89
-        foreach ($testData as $key => $testRow) {
90
-            $this->assertInternalType('array', $data[$key]);
91
-            $this->assertArraySubset($testRow, $data[$key]);
92
-            $this->assertArrayHasKey('id', $data[$key]);
93
-            $this->assertArrayHasKey('message', $data[$key]);
94
-            $this->assertArrayHasKey('message_short', $data[$key]);
95
-            $this->assertArrayHasKey('datetime', $data[$key]);
96
-            $this->assertArrayHasKey('commit_link', $data[$key]);
97
-        }
98
-    }
99
-
100
-    public function testGetChangesFailure()
101
-    {
102
-        $repository = new MysqlChangelogRepository(self::$connection);
103
-        $data = $repository->getChanges();
104
-
105
-        $this->assertEmpty($data);
106
-        $this->assertInternalType('array', $data);
107
-    }
108
-
109
-    public function testGetChangesRange()
110
-    {
111
-        $testData = [
112
-            [
113
-                'id' => rand(1, 100),
114
-                'message' => 'test one',
115
-            ],
116
-            [
117
-                'id' => rand(101, 200),
118
-                'message' => 'test two',
119
-            ],
120
-            [
121
-                'id' => rand(201, 300),
122
-                'message' => 'test three',
123
-            ],
124
-        ];
125
-
126
-        array_walk($testData, [$this, 'insertData']);
127
-
128
-        $repository = new MysqlChangelogRepository(self::$connection);
129
-        $data = $repository->getChanges(2, 1);
130
-
131
-        $this->assertNotFalse($data);
132
-        $this->assertInternalType('array', $data);
133
-        $this->assertCount(2, $data);
134
-
135
-        $testData = array_slice($testData, 1, 2);
136
-
137
-        foreach ($testData as $key => $testRow) {
138
-            $this->assertInternalType('array', $testRow);
139
-            $this->assertArraySubset($testRow, $data[$key]);
140
-        }
141
-    }
142
-
143
-    public function testGetChangesRangeFailure()
144
-    {
145
-        $testData = [
146
-            [
147
-                'id' => rand(1, 100),
148
-                'message' => 'test one',
149
-            ],
150
-            [
151
-                'id' => rand(101, 200),
152
-                'message' => 'test two',
153
-            ],
154
-        ];
155
-
156
-        array_walk($testData, [$this, 'insertData']);
157
-
158
-        $repository = new MysqlChangelogRepository(self::$connection);
159
-        $data = $repository->getChanges(1, 3);
160
-
161
-        $this->assertEmpty($data);
162
-        $this->assertInternalType('array', $data);
163
-    }
164
-
165
-    protected function insertData(array $data)
166
-    {
167
-        $defaultData = [
168
-            'id' => null,
169
-            'hash' => '',
170
-            'message' => null,
171
-            'message_short' => null,
172
-            'datetime' => '',
173
-            'author' => '',
174
-            'commit_link' => '',
175
-        ];
176
-
177
-        $data = array_merge($defaultData, $data);
178
-
179
-        return self::$connection->getDefault()->perform("
31
+		);
32
+
33
+		self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
34
+			return $extendedPdo;
35
+		});
36
+	}
37
+
38
+	public function testIsInstanceOfChangelogRepository()
39
+	{
40
+		$repository = new MysqlChangelogRepository(self::$connection);
41
+
42
+		$this->assertInstanceOf(
43
+			'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository',
44
+			$repository
45
+		);
46
+	}
47
+
48
+	public function testImplementsChangelogInterface()
49
+	{
50
+		$repository = new MysqlChangelogRepository(self::$connection);
51
+
52
+		$this->assertInstanceOf(
53
+			'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface',
54
+			$repository
55
+		);
56
+	}
57
+
58
+	public function testConstructSetsConnections()
59
+	{
60
+		$respository = new MysqlChangelogRepository(self::$connection);
61
+
62
+		$this->assertAttributeSame(
63
+			self::$connection,
64
+			'connections',
65
+			$respository
66
+		);
67
+	}
68
+
69
+	public function testGetChanges()
70
+	{
71
+		$testData = [
72
+			[
73
+				'id' => rand(1, 100),
74
+				'message' => 'test one',
75
+			],
76
+			[
77
+				'id' => rand(101, 200),
78
+				'message' => 'test two',
79
+			],
80
+		];
81
+
82
+		array_walk($testData, [$this, 'insertData']);
83
+
84
+		$repository = new MysqlChangelogRepository(self::$connection);
85
+		$data = $repository->getChanges();
86
+
87
+		$this->assertNotFalse($data);
88
+		$this->assertInternalType('array', $data);
89
+		foreach ($testData as $key => $testRow) {
90
+			$this->assertInternalType('array', $data[$key]);
91
+			$this->assertArraySubset($testRow, $data[$key]);
92
+			$this->assertArrayHasKey('id', $data[$key]);
93
+			$this->assertArrayHasKey('message', $data[$key]);
94
+			$this->assertArrayHasKey('message_short', $data[$key]);
95
+			$this->assertArrayHasKey('datetime', $data[$key]);
96
+			$this->assertArrayHasKey('commit_link', $data[$key]);
97
+		}
98
+	}
99
+
100
+	public function testGetChangesFailure()
101
+	{
102
+		$repository = new MysqlChangelogRepository(self::$connection);
103
+		$data = $repository->getChanges();
104
+
105
+		$this->assertEmpty($data);
106
+		$this->assertInternalType('array', $data);
107
+	}
108
+
109
+	public function testGetChangesRange()
110
+	{
111
+		$testData = [
112
+			[
113
+				'id' => rand(1, 100),
114
+				'message' => 'test one',
115
+			],
116
+			[
117
+				'id' => rand(101, 200),
118
+				'message' => 'test two',
119
+			],
120
+			[
121
+				'id' => rand(201, 300),
122
+				'message' => 'test three',
123
+			],
124
+		];
125
+
126
+		array_walk($testData, [$this, 'insertData']);
127
+
128
+		$repository = new MysqlChangelogRepository(self::$connection);
129
+		$data = $repository->getChanges(2, 1);
130
+
131
+		$this->assertNotFalse($data);
132
+		$this->assertInternalType('array', $data);
133
+		$this->assertCount(2, $data);
134
+
135
+		$testData = array_slice($testData, 1, 2);
136
+
137
+		foreach ($testData as $key => $testRow) {
138
+			$this->assertInternalType('array', $testRow);
139
+			$this->assertArraySubset($testRow, $data[$key]);
140
+		}
141
+	}
142
+
143
+	public function testGetChangesRangeFailure()
144
+	{
145
+		$testData = [
146
+			[
147
+				'id' => rand(1, 100),
148
+				'message' => 'test one',
149
+			],
150
+			[
151
+				'id' => rand(101, 200),
152
+				'message' => 'test two',
153
+			],
154
+		];
155
+
156
+		array_walk($testData, [$this, 'insertData']);
157
+
158
+		$repository = new MysqlChangelogRepository(self::$connection);
159
+		$data = $repository->getChanges(1, 3);
160
+
161
+		$this->assertEmpty($data);
162
+		$this->assertInternalType('array', $data);
163
+	}
164
+
165
+	protected function insertData(array $data)
166
+	{
167
+		$defaultData = [
168
+			'id' => null,
169
+			'hash' => '',
170
+			'message' => null,
171
+			'message_short' => null,
172
+			'datetime' => '',
173
+			'author' => '',
174
+			'commit_link' => '',
175
+		];
176
+
177
+		$data = array_merge($defaultData, $data);
178
+
179
+		return self::$connection->getDefault()->perform("
180 180
             INSERT INTO `jpemeric_stream`.`changelog`
181 181
                 (id, hash, message, message_short, datetime, author, commit_link)
182 182
             VALUES
183 183
                 (:id, :hash, :message, :message_short, :datetime, :author, :commit_link)",
184
-            $data
185
-        );
186
-    }
187
-
188
-    protected function tearDown()
189
-    {
190
-        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`changelog`");
191
-    }
192
-
193
-    public static function tearDownAfterClass()
194
-    {
195
-        self::$connection->getDefault()->disconnect();
196
-        unlink('jpemeric_stream.db');
197
-    }
184
+			$data
185
+		);
186
+	}
187
+
188
+	protected function tearDown()
189
+	{
190
+		self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`changelog`");
191
+	}
192
+
193
+	public static function tearDownAfterClass()
194
+	{
195
+		self::$connection->getDefault()->disconnect();
196
+		unlink('jpemeric_stream.db');
197
+	}
198 198
 }
Please login to merge, or discard this patch.
router/BlogRouter.class.inc.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 	{
48 48
 		if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches))
49 49
 		{
50
-        global $container;
51
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
52
-        $post = $repository->findPostByPath($matches[2]);
50
+		global $container;
51
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
52
+		$post = $repository->findPostByPath($matches[2]);
53 53
 
54 54
 			if(!$post)
55 55
 			{
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 			$post_uri = URLDecode::getPiece(1);
66 66
 			if($post_uri !== null)
67 67
 			{
68
-        global $container;
69
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
70
-        $post = $repository->findPostByPath($post_uri);
68
+		global $container;
69
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
70
+		$post = $repository->findPostByPath($post_uri);
71 71
 
72 72
 				if($post != false)
73 73
 				{
Please login to merge, or discard this patch.
controller/blog/HomeController.class.inc.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		if($this->page == 1)
51 51
 		{
52
-        global $container;
53
-        $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
54
-        $introduction_result = $repository->findByType('home');
52
+		global $container;
53
+		$repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
54
+		$introduction_result = $repository->findByType('home');
55 55
 			
56 56
 			$introduction = array();
57 57
 			$introduction['title'] = $introduction_result['title'];
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
 	protected function get_list_results()
77 77
 	{
78
-        global $container;
79
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
80
-        return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset);
78
+		global $container;
79
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
80
+		return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset);
81 81
 	}
82 82
 
83 83
 	protected function get_list_description()
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	private $total_post_count;
108 108
 	protected function get_total_post_count()
109 109
 	{
110
-      if(!isset($this->total_post_count)) {
111
-          global $container;
112
-          $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
113
-          $this->total_post_count = $repository->getActivePostsCount();
114
-      }
110
+	  if(!isset($this->total_post_count)) {
111
+		  global $container;
112
+		  $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
113
+		  $this->total_post_count = $repository->getActivePostsCount();
114
+	  }
115 115
 
116 116
 		return $this->total_post_count;
117 117
 	}
Please login to merge, or discard this patch.
controller/blog/TagController.class.inc.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 		$tag = URLDecode::getPiece(2);
27 27
 		$tag = str_replace('-', ' ', $tag);
28 28
 
29
-        global $container;
30
-        $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
31
-        $tag_result = $repository->findTagByTitle($tag);
29
+		global $container;
30
+		$repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
31
+		$tag_result = $repository->findTagByTitle($tag);
32 32
 
33 33
 		if($tag_result === false)
34 34
 			$this->eject();
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 		
65 65
 		if($this->page == 1)
66 66
 		{
67
-        global $container;
68
-        $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
69
-        $introduction_result = $repository->findByType('tag', $this->tag['tag']);
67
+		global $container;
68
+		$repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
69
+		$introduction_result = $repository->findByType('tag', $this->tag['tag']);
70 70
 			
71 71
 			if($introduction_result !== false)
72 72
 			{
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 
97 97
 	protected function get_list_results()
98 98
 	{
99
-        global $container;
100
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
101
-        return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset);
99
+		global $container;
100
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
101
+		return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset);
102 102
 	}
103 103
 
104 104
 	protected function get_list_description()
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
 	protected function get_total_post_count()
130 130
 	{
131 131
 		if(!isset($this->total_post_count)) {
132
-        global $container;
133
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
134
-        $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']);
135
-    }
132
+		global $container;
133
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
134
+		$this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']);
135
+	}
136 136
 
137 137
 		return $this->total_post_count;
138 138
 	}
Please login to merge, or discard this patch.
controller/blog/CategoryController.class.inc.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	{
116 116
 		if($this->page == 1)
117 117
 		{
118
-        global $container;
119
-        $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
120
-        $introduction_result = $repository->findByType('category', $this->category->link);
118
+		global $container;
119
+		$repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
120
+		$introduction_result = $repository->findByType('category', $this->category->link);
121 121
 			
122 122
 			$introduction = array();
123 123
 			$introduction['title'] = $introduction_result['title'];
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 
142 142
 	protected function get_list_results()
143 143
 	{
144
-        global $container;
145
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
146
-        return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset);
144
+		global $container;
145
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
146
+		return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset);
147 147
 	}
148 148
 
149 149
 	protected function get_list_description()
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 	protected function get_total_post_count()
175 175
 	{
176 176
 		if(!isset($this->total_post_count)) {
177
-        global $container;
178
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
179
-        $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link);
180
-    }
177
+		global $container;
178
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
179
+		$this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link);
180
+	}
181 181
 		return $this->total_post_count;
182 182
 	}
183 183
 
Please login to merge, or discard this patch.
controller/blog/AboutController.class.inc.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@
 block discarded – undo
33 33
 
34 34
 	protected function get_introduction()
35 35
 	{
36
-        global $container;
37
-        $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
38
-        $introduction_result = $repository->findByType('about');
36
+		global $container;
37
+		$repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
38
+		$introduction_result = $repository->findByType('about');
39 39
 		
40 40
 		if($introduction_result !== null)
41 41
 		{
Please login to merge, or discard this patch.
controller/blog/SearchController.class.inc.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	{
35 35
 		$query = URLDecode::getPiece(2);
36 36
 		$query = urldecode($query);
37
-        $query = str_replace('-', ' ', $query);
37
+		$query = str_replace('-', ' ', $query);
38 38
 		
39 39
 		$this->query = $query;
40 40
 		
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	{
88 88
 		if(!isset($this->search_result))
89 89
 		{
90
-        global $container;
91
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
92
-        $posts = $repository->getActivePosts();
90
+		global $container;
91
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
92
+		$posts = $repository->getActivePosts();
93 93
 			
94 94
 			$this->search_result = Search::instance()
95 95
 				->setQuery($this->query)
Please login to merge, or discard this patch.