Completed
Push — master ( 4c6be8...89e88a )
by Jacob
03:08
created
router/Router.class.inc.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 
19 19
 	private static function get_router_name()
20 20
 	{
21
-		if(Request::isAJAX())
21
+		if (Request::isAJAX())
22 22
 			return 'AJAXRouter';
23 23
 		
24
-		switch(URLDecode::getSite())
24
+		switch (URLDecode::getSite())
25 25
 		{
26 26
 			case 'ajax' :
27 27
 				return 'AjaxRouter';
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 
66 66
 	final protected function check_for_redirect($redirect_uri)
67 67
 	{
68
-		foreach($this->get_redirect_array() as $check)
68
+		foreach ($this->get_redirect_array() as $check)
69 69
 		{
70 70
 			$redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri);
71 71
 		}
72 72
 		
73 73
 		$redirect_uri = $this->check_for_special_redirect($redirect_uri);
74 74
 		
75
-		if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/')
75
+		if ($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/')
76 76
 			$redirect_uri .= '/';
77 77
 		
78 78
         if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') {
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
             $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri;
81 81
         }
82 82
         
83
-		if($redirect_uri == URLDecode::getURI())
83
+		if ($redirect_uri == URLDecode::getURI())
84 84
 			return;
85 85
 		
86 86
 		$controller_check = $redirect_uri;
87
-		if(substr($redirect_uri, 0, 4) == 'http') {
87
+		if (substr($redirect_uri, 0, 4) == 'http') {
88 88
       $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
89 89
 			$controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri);
90 90
 		
91 91
 		$controller = $this->get_controller($controller_check);
92
-		if($controller == '/Error404Controller')
92
+		if ($controller == '/Error404Controller')
93 93
 		{
94 94
 			Loader::loadNew('controller', '/Error404Controller')
95 95
 				->activate();
96 96
 			exit;
97 97
 		}
98 98
 
99
-		if(substr($redirect_uri, 0, 4) != 'http')
99
+		if (substr($redirect_uri, 0, 4) != 'http')
100 100
 		{
101 101
 			$redirect_uri = substr($redirect_uri, 1);
102 102
 			$redirect_uri = URLDecode::getBase() . $redirect_uri;
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 
114 114
 	final private function get_controller($uri)
115 115
 	{
116
-		foreach($this->get_direct_array() as $check)
116
+		foreach ($this->get_direct_array() as $check)
117 117
 		{
118
-			if($uri == $check->match)
118
+			if ($uri == $check->match)
119 119
 				return "{$this->get_primary_folder()}/{$check->controller}";
120 120
 			
121
-			if(preg_match("@^{$check->match}$@", $uri))
121
+			if (preg_match("@^{$check->match}$@", $uri))
122 122
 				return "{$this->get_primary_folder()}/{$check->controller}";
123 123
 		}
124 124
 		
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 	final private function get_primary_folder()
129 129
 	{
130
-		if(Request::isAjax())
130
+		if (Request::isAjax())
131 131
 			return 'ajax';
132 132
 		
133 133
 		return URLDecode::getSite();
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
 	private static function get_router_name()
20 20
 	{
21
-		if(Request::isAJAX())
22
-			return 'AJAXRouter';
21
+		if(Request::isAJAX()) {
22
+					return 'AJAXRouter';
23
+		}
23 24
 		
24 25
 		switch(URLDecode::getSite())
25 26
 		{
@@ -72,16 +73,18 @@  discard block
 block discarded – undo
72 73
 		
73 74
 		$redirect_uri = $this->check_for_special_redirect($redirect_uri);
74 75
 		
75
-		if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/')
76
-			$redirect_uri .= '/';
76
+		if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') {
77
+					$redirect_uri .= '/';
78
+		}
77 79
 		
78 80
         if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') {
79 81
             $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
80 82
             $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri;
81 83
         }
82 84
         
83
-		if($redirect_uri == URLDecode::getURI())
84
-			return;
85
+		if($redirect_uri == URLDecode::getURI()) {
86
+					return;
87
+		}
85 88
 		
86 89
 		$controller_check = $redirect_uri;
87 90
 		if(substr($redirect_uri, 0, 4) == 'http') {
@@ -115,11 +118,13 @@  discard block
 block discarded – undo
115 118
 	{
116 119
 		foreach($this->get_direct_array() as $check)
117 120
 		{
118
-			if($uri == $check->match)
119
-				return "{$this->get_primary_folder()}/{$check->controller}";
121
+			if($uri == $check->match) {
122
+							return "{$this->get_primary_folder()}/{$check->controller}";
123
+			}
120 124
 			
121
-			if(preg_match("@^{$check->match}$@", $uri))
122
-				return "{$this->get_primary_folder()}/{$check->controller}";
125
+			if(preg_match("@^{$check->match}$@", $uri)) {
126
+							return "{$this->get_primary_folder()}/{$check->controller}";
127
+			}
123 128
 		}
124 129
 		
125 130
 		return '/Error404Controller';
@@ -127,8 +132,9 @@  discard block
 block discarded – undo
127 132
 
128 133
 	final private function get_primary_folder()
129 134
 	{
130
-		if(Request::isAjax())
131
-			return 'ajax';
135
+		if(Request::isAjax()) {
136
+					return 'ajax';
137
+		}
132 138
 		
133 139
 		return URLDecode::getSite();
134 140
 	}
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 		if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/')
76 76
 			$redirect_uri .= '/';
77 77
 		
78
-        if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') {
79
-            $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
80
-            $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri;
81
-        }
78
+		if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') {
79
+			$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
80
+			$redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri;
81
+		}
82 82
         
83 83
 		if($redirect_uri == URLDecode::getURI())
84 84
 			return;
85 85
 		
86 86
 		$controller_check = $redirect_uri;
87 87
 		if(substr($redirect_uri, 0, 4) == 'http') {
88
-      $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
88
+	  $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
89 89
 			$controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri);
90
-    }
90
+	}
91 91
 		
92 92
 		$controller = $this->get_controller($controller_check);
93 93
 		if($controller == '/Error404Controller')
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	{
139 139
 		return (
140 140
 			URLDecode::getExtension() != 'json' &&
141
-            strstr(URLDecode::getURI(), '#') === false);
141
+			strstr(URLDecode::getURI(), '#') === false);
142 142
 	}
143 143
 
144 144
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Activity/MysqlActivityRepository.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -7,108 +7,108 @@
 block discarded – undo
7 7
 class MysqlActivityRepository implements ActivityRepositoryInterface
8 8
 {
9 9
 
10
-    /** @var  ConnectionLocator */
11
-    protected $connections;
10
+	/** @var  ConnectionLocator */
11
+	protected $connections;
12 12
 
13
-    /**
14
-     * @param ConnectonLocator $connections
15
-     */
16
-    public function __construct(ConnectionLocator $connections)
17
-    {
18
-        $this->connections = $connections;
19
-    }
13
+	/**
14
+	 * @param ConnectonLocator $connections
15
+	 */
16
+	public function __construct(ConnectionLocator $connections)
17
+	{
18
+		$this->connections = $connections;
19
+	}
20 20
 
21
-    /**
22
-     * @param integer $id
23
-     *
24
-     * @return array|false
25
-     */
26
-    public function getActivityById($id)
27
-    {
28
-        $query = "
21
+	/**
22
+	 * @param integer $id
23
+	 *
24
+	 * @return array|false
25
+	 */
26
+	public function getActivityById($id)
27
+	{
28
+		$query = "
29 29
             SELECT *
30 30
             FROM `jpemeric_stream`.`activity`
31 31
             WHERE `id` = :id
32 32
             LIMIT 1";
33
-        $bindings = [
34
-            'id' => $id,
35
-        ];
33
+		$bindings = [
34
+			'id' => $id,
35
+		];
36 36
 
37
-        return $this
38
-            ->connections
39
-            ->getRead()
40
-            ->fetchOne($query, $bindings);
41
-    }
37
+		return $this
38
+			->connections
39
+			->getRead()
40
+			->fetchOne($query, $bindings);
41
+	}
42 42
 
43
-    /**
44
-     * @param integer $limit
45
-     * @param integer $offset
46
-     *
47
-     * @return array|false
48
-     */
49
-    public function getActivities($limit = null, $offset = 0)
50
-    {
51
-        $query = "
43
+	/**
44
+	 * @param integer $limit
45
+	 * @param integer $offset
46
+	 *
47
+	 * @return array|false
48
+	 */
49
+	public function getActivities($limit = null, $offset = 0)
50
+	{
51
+		$query = "
52 52
             SELECT *
53 53
             FROM `jpemeric_stream`.`activity`
54 54
             ORDER BY `datetime` DESC";
55
-        if (!is_null($limit)) {
56
-            $query .= "
55
+		if (!is_null($limit)) {
56
+			$query .= "
57 57
             LIMIT {$offset}, {$limit}";
58
-        }
58
+		}
59 59
 
60
-        return $this
61
-            ->connections
62
-            ->getRead()
63
-            ->fetchAll($query);
64
-    }
60
+		return $this
61
+			->connections
62
+			->getRead()
63
+			->fetchAll($query);
64
+	}
65 65
 
66
-    public function getActivitiesCount()
67
-    {
68
-        $query = "
66
+	public function getActivitiesCount()
67
+	{
68
+		$query = "
69 69
             SELECT COUNT(1) AS `count`
70 70
             FROM `jpemeric_stream`.`activity`";
71 71
 
72
-        return $this
73
-            ->connections
74
-            ->getRead()
75
-            ->fetchValue($query);
76
-    }
72
+		return $this
73
+			->connections
74
+			->getRead()
75
+			->fetchValue($query);
76
+	}
77 77
 
78
-    public function getActivitiesByType($type, $limit = null, $offset = 0)
79
-    {
80
-        $query = "
78
+	public function getActivitiesByType($type, $limit = null, $offset = 0)
79
+	{
80
+		$query = "
81 81
             SELECT *
82 82
             FROM `jpemeric_stream`.`activity`
83 83
             WHERE `type` = :type
84 84
             ORDER BY `datetime` DESC";
85
-        if (!is_null($limit)) {
86
-            $query .= "
85
+		if (!is_null($limit)) {
86
+			$query .= "
87 87
             LIMIT {$offset}, {$limit}";
88
-        }
89
-        $bindings = [
90
-            'type' => $type,
91
-        ];
88
+		}
89
+		$bindings = [
90
+			'type' => $type,
91
+		];
92 92
 
93
-        return $this
94
-            ->connections
95
-            ->getRead()
96
-            ->fetchAll($query, $bindings);
97
-    }
93
+		return $this
94
+			->connections
95
+			->getRead()
96
+			->fetchAll($query, $bindings);
97
+	}
98 98
 
99
-    public function getActivitiesByTypeCount($type)
100
-    {
101
-        $query = "
99
+	public function getActivitiesByTypeCount($type)
100
+	{
101
+		$query = "
102 102
             SELECT COUNT(1) AS `count`
103 103
             FROM `jpemeric_stream`.`activity`
104 104
             WHERE `type` = :type";
105
-        $bindings = [
106
-            'type' => $type,
107
-        ];
105
+		$bindings = [
106
+			'type' => $type,
107
+		];
108 108
 
109
-        return $this
110
-            ->connections
111
-            ->getRead()
112
-            ->fetchValue($query, $bindings);
113
-    }
109
+		return $this
110
+			->connections
111
+			->getRead()
112
+			->fetchValue($query, $bindings);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Changelog/MysqlChangelogRepository.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -7,37 +7,37 @@
 block discarded – undo
7 7
 class MysqlChangelogRepository implements ChangelogRepositoryInterface
8 8
 {
9 9
 
10
-    /** @var  ConnectionLocator */
11
-    protected $connections;
10
+	/** @var  ConnectionLocator */
11
+	protected $connections;
12 12
 
13
-    /**
14
-     * @param ConnectonLocator $connections
15
-     */
16
-    public function __construct(ConnectionLocator $connections)
17
-    {
18
-        $this->connections = $connections;
19
-    }
13
+	/**
14
+	 * @param ConnectonLocator $connections
15
+	 */
16
+	public function __construct(ConnectionLocator $connections)
17
+	{
18
+		$this->connections = $connections;
19
+	}
20 20
 
21
-    /**
22
-     * @param integer $limit
23
-     * @param integer $offset
24
-     *
25
-     * @return array|false
26
-     */
27
-    public function getChanges($limit = null, $offset = 0)
28
-    {
29
-        $query = "
21
+	/**
22
+	 * @param integer $limit
23
+	 * @param integer $offset
24
+	 *
25
+	 * @return array|false
26
+	 */
27
+	public function getChanges($limit = null, $offset = 0)
28
+	{
29
+		$query = "
30 30
             SELECT `message`, `message_short`, `datetime`, `commit_link`
31 31
             FROM `jpemeric_stream`.`changelog`
32 32
             ORDER BY `datetime` DESC";
33
-        if (!is_null($limit)) {
34
-            $query .= "
33
+		if (!is_null($limit)) {
34
+			$query .= "
35 35
             LIMIT {$offset}, {$limit}";
36
-        }
36
+		}
37 37
 
38
-        return $this
39
-            ->connections
40
-            ->getRead()
41
-            ->fetchAll($query);
42
-    }
38
+		return $this
39
+			->connections
40
+			->getRead()
41
+			->fetchAll($query);
42
+	}
43 43
 }
Please login to merge, or discard this patch.
tests/unit/Domain/Blog/Post/MysqlPostRepositoryTest.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@  discard block
 block discarded – undo
7 7
 class MysqlPostRepositoryTest extends PHPUnit_Framework_TestCase
8 8
 {
9 9
 
10
-    protected $connections;
11
-
12
-    public function __construct()
13
-    {
14
-        $extendedPdo = $this->newExtendedPdo();
15
-        $this->connections = new ConnectionLocator(function () use ($extendedPdo) {
16
-            return $extendedPdo;
17
-        });
18
-    }
19
-
20
-    protected function newExtendedPdo()
21
-    {
22
-        $extendedPdo = new ExtendedPdo('sqlite::memory:');
23
-        $extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`');
24
-        $extendedPdo->exec("
10
+	protected $connections;
11
+
12
+	public function __construct()
13
+	{
14
+		$extendedPdo = $this->newExtendedPdo();
15
+		$this->connections = new ConnectionLocator(function () use ($extendedPdo) {
16
+			return $extendedPdo;
17
+		});
18
+	}
19
+
20
+	protected function newExtendedPdo()
21
+	{
22
+		$extendedPdo = new ExtendedPdo('sqlite::memory:');
23
+		$extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`');
24
+		$extendedPdo->exec("
25 25
             CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`post` (
26 26
               `id` integer PRIMARY KEY AUTOINCREMENT,
27 27
               `title` varchar(60) NOT NULL,
@@ -31,88 +31,88 @@  discard block
 block discarded – undo
31 31
               `body` text NOT NULL,
32 32
               `display` integer NOT NULL
33 33
             )"
34
-        );
35
-        return $extendedPdo;
36
-    }
37
-
38
-    public function newMysqlPostRepository()
39
-    {
40
-        return new MysqlPostRepository($this->connections);
41
-    }
42
-
43
-    public function testConstructSetsConnections()
44
-    {
45
-        $this->assertAttributeEquals(
46
-            $this->connections,
47
-            'connections',
48
-            $this->newMysqlPostRepository()
49
-        );
50
-    }
51
-
52
-    public function testFindPostByPath()
53
-    {
54
-        $test_active_post = array(
55
-            'title'     => 'test findByPath active',
56
-            'path'      => 'test-findbypath-active',
57
-            'category'  => 'test-category',
58
-            'date'      => (new DateTime())->format('Y-m-d H:i:s'),
59
-            'body'      => 'test content',
60
-            'display'   => 1
61
-        );
62
-
63
-        $this->connections->getDefault()->perform("
34
+		);
35
+		return $extendedPdo;
36
+	}
37
+
38
+	public function newMysqlPostRepository()
39
+	{
40
+		return new MysqlPostRepository($this->connections);
41
+	}
42
+
43
+	public function testConstructSetsConnections()
44
+	{
45
+		$this->assertAttributeEquals(
46
+			$this->connections,
47
+			'connections',
48
+			$this->newMysqlPostRepository()
49
+		);
50
+	}
51
+
52
+	public function testFindPostByPath()
53
+	{
54
+		$test_active_post = array(
55
+			'title'     => 'test findByPath active',
56
+			'path'      => 'test-findbypath-active',
57
+			'category'  => 'test-category',
58
+			'date'      => (new DateTime())->format('Y-m-d H:i:s'),
59
+			'body'      => 'test content',
60
+			'display'   => 1
61
+		);
62
+
63
+		$this->connections->getDefault()->perform("
64 64
             INSERT INTO jpemeric_blog.post
65 65
                 (title, path, category, date, body, display)
66 66
             VALUES
67 67
                 (:title, :path, :category, :date, :body, :display)",
68
-            $test_active_post);
69
-
70
-        $active_post = $this->newMysqlPostRepository()->findPostByPath(
71
-            $test_active_post['category'],
72
-            $test_active_post['path']
73
-        );
74
-        $this->assertSame($test_active_post['title'], $active_post['title']);
75
-
76
-        $test_inactive_post = array(
77
-            'title'     => 'test findByPath inactive',
78
-            'path'      => 'test-findbypath-inactive',
79
-            'category'  => 'test-category',
80
-            'date'      => (new DateTime())->format('Y-m-d H:i:s'),
81
-            'body'      => 'test content',
82
-            'display'   => 0
83
-        );
84
-
85
-        $this->connections->getDefault()->perform("
68
+			$test_active_post);
69
+
70
+		$active_post = $this->newMysqlPostRepository()->findPostByPath(
71
+			$test_active_post['category'],
72
+			$test_active_post['path']
73
+		);
74
+		$this->assertSame($test_active_post['title'], $active_post['title']);
75
+
76
+		$test_inactive_post = array(
77
+			'title'     => 'test findByPath inactive',
78
+			'path'      => 'test-findbypath-inactive',
79
+			'category'  => 'test-category',
80
+			'date'      => (new DateTime())->format('Y-m-d H:i:s'),
81
+			'body'      => 'test content',
82
+			'display'   => 0
83
+		);
84
+
85
+		$this->connections->getDefault()->perform("
86 86
             INSERT INTO jpemeric_blog.post
87 87
                 (title, path, category, date, body, display)
88 88
             VALUES
89 89
                 (:title, :path, :category, :date, :body, :display)",
90
-            $test_inactive_post);
91
-
92
-        $inactive_post = $this->newMysqlPostRepository()->findPostByPath(
93
-            $test_inactive_post['category'],
94
-            $test_inactive_post['path']
95
-        );
96
-        $this->assertFalse($inactive_post);
97
-
98
-        $nonexistant_post = $this->newMysqlPostRepository()->findPostByPath(
99
-            'test-category',
100
-            'test-findbypath-nonexistant'
101
-        );
102
-        $this->assertFalse($nonexistant_post);
90
+			$test_inactive_post);
91
+
92
+		$inactive_post = $this->newMysqlPostRepository()->findPostByPath(
93
+			$test_inactive_post['category'],
94
+			$test_inactive_post['path']
95
+		);
96
+		$this->assertFalse($inactive_post);
97
+
98
+		$nonexistant_post = $this->newMysqlPostRepository()->findPostByPath(
99
+			'test-category',
100
+			'test-findbypath-nonexistant'
101
+		);
102
+		$this->assertFalse($nonexistant_post);
103 103
    }
104 104
 
105
-    public function testIsInstanceOfPostRepository()
106
-    {
107
-        $this->assertInstanceOf(
108
-            'Jacobemerick\Web\Domain\Blog\Post\PostRepositoryInterface',
109
-            $this->newMysqlPostRepository()
110
-        );
111
-    }
105
+	public function testIsInstanceOfPostRepository()
106
+	{
107
+		$this->assertInstanceOf(
108
+			'Jacobemerick\Web\Domain\Blog\Post\PostRepositoryInterface',
109
+			$this->newMysqlPostRepository()
110
+		);
111
+	}
112 112
 
113
-    public static function tearDownAfterClass()
114
-    {
113
+	public static function tearDownAfterClass()
114
+	{
115 115
 //        $this->connections->getDefault()->disconnect();
116
-        unlink('jpemeric_blog.db');
117
-    }
116
+		unlink('jpemeric_blog.db');
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function __construct()
14 14
     {
15 15
         $extendedPdo = $this->newExtendedPdo();
16
-        $this->connections = new ConnectionLocator(function () use ($extendedPdo) {
16
+        $this->connections = new ConnectionLocator(function() use ($extendedPdo) {
17 17
             return $extendedPdo;
18 18
         });
19 19
     }
Please login to merge, or discard this patch.
tests/unit/Domain/Stream/Activity/MysqlActivityRepositoryTest.php 2 patches
Indentation   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  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`");
18
-        $extendedPdo->exec("
14
+	public static function setUpBeforeClass()
15
+	{
16
+		$extendedPdo = new ExtendedPdo('sqlite::memory:');
17
+		$extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`");
18
+		$extendedPdo->exec("
19 19
             CREATE TABLE IF NOT EXISTS `jpemeric_stream`.`activity` (
20 20
               `id` integer PRIMARY KEY AUTOINCREMENT,
21 21
               `message` text NOT NULL,
@@ -27,428 +27,428 @@  discard block
 block discarded – undo
27 27
               `created_at` datetime,
28 28
               `updated_at` datetime
29 29
             )"
30
-        );
31
-
32
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
33
-            return $extendedPdo;
34
-        });
35
-    }
36
-
37
-    public function testIsInstanceOfActivityRepository()
38
-    {
39
-        $repository = new MysqlActivityRepository(self::$connection);
40
-
41
-        $this->assertInstanceOf(
42
-            'Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository',
43
-            $repository
44
-        );
45
-    }
46
-
47
-    public function testImplementsActivityInterface()
48
-    {
49
-        $repository = new MysqlActivityRepository(self::$connection);
50
-
51
-        $this->assertInstanceOf(
52
-            'Jacobemerick\Web\Domain\Stream\Activity\ActivityRepositoryInterface',
53
-            $repository
54
-        );
55
-    }
56
-
57
-    public function testConstructSetsConnections()
58
-    {
59
-        $respository = new MysqlActivityRepository(self::$connection);
60
-
61
-        $this->assertAttributeSame(
62
-            self::$connection,
63
-            'connections',
64
-            $respository
65
-        );
66
-    }
67
-
68
-    public function testGetActivityById()
69
-    {
70
-        $testData = [
71
-            'id' => rand(1, 100),
72
-            'message' => 'test data',
73
-        ];
74
-
75
-        $this->insertData($testData);
76
-
77
-        $repository = new MysqlActivityRepository(self::$connection);
78
-        $data = $repository->getActivityById($testData['id']);
79
-
80
-        $this->assertNotFalse($data);
81
-        $this->assertInternalType('array', $data);
82
-        $this->assertArraySubset($testData, $data);
83
-    }
84
-
85
-    public function testGetActivityByIdFailure()
86
-    {
87
-        $testData = [
88
-            'id' => rand(1, 100),
89
-            'message' => 'test data',
90
-        ];
91
-
92
-        $this->insertData($testData);
93
-
94
-        $repository = new MysqlActivityRepository(self::$connection);
95
-        $data = $repository->getActivityById($testData['id'] + 1);
96
-
97
-        $this->assertFalse($data);
98
-    }
99
-
100
-    public function testGetActivities()
101
-    {
102
-        $testData = [
103
-            [
104
-                'id' => rand(1, 100),
105
-                'message' => 'test one',
106
-            ],
107
-            [
108
-                'id' => rand(101, 200),
109
-                'message' => 'test two',
110
-            ],
111
-        ];
112
-
113
-        array_walk($testData, [$this, 'insertData']);
114
-
115
-        $repository = new MysqlActivityRepository(self::$connection);
116
-        $data = $repository->getActivities();
117
-
118
-        $this->assertNotFalse($data);
119
-        $this->assertInternalType('array', $data);
120
-        foreach ($testData as $key => $testRow) {
121
-            $this->assertInternalType('array', $testRow);
122
-            $this->assertArraySubset($testRow, $data[$key]);
123
-        }
124
-    }
125
-
126
-    public function testGetActivitiesFailure()
127
-    {
128
-        $repository = new MysqlActivityRepository(self::$connection);
129
-        $data = $repository->getActivities();
130
-
131
-        $this->assertEmpty($data);
132
-        $this->assertInternalType('array', $data);
133
-    }
134
-
135
-    public function testGetActivitiesRange()
136
-    {
137
-        $testData = [
138
-            [
139
-                'id' => rand(1, 100),
140
-                'message' => 'test one',
141
-            ],
142
-            [
143
-                'id' => rand(101, 200),
144
-                'message' => 'test two',
145
-            ],
146
-            [
147
-                'id' => rand(201, 300),
148
-                'message' => 'test three',
149
-            ],
150
-        ];
151
-
152
-        array_walk($testData, [$this, 'insertData']);
153
-
154
-        $repository = new MysqlActivityRepository(self::$connection);
155
-        $data = $repository->getActivities(2, 1);
156
-
157
-        $this->assertNotFalse($data);
158
-        $this->assertInternalType('array', $data);
159
-        $this->assertCount(2, $data);
160
-
161
-        $testData = array_slice($testData, 1, 2);
162
-
163
-        foreach ($testData as $key => $testRow) {
164
-            $this->assertInternalType('array', $testRow);
165
-            $this->assertArraySubset($testRow, $data[$key]);
166
-        }
167
-    }
168
-
169
-    public function testGetActivitiesRangeFailure()
170
-    {
171
-        $testData = [
172
-            [
173
-                'id' => rand(1, 100),
174
-                'message' => 'test one',
175
-            ],
176
-            [
177
-                'id' => rand(101, 200),
178
-                'message' => 'test two',
179
-            ],
180
-        ];
181
-
182
-        array_walk($testData, [$this, 'insertData']);
183
-
184
-        $repository = new MysqlActivityRepository(self::$connection);
185
-        $data = $repository->getActivities(1, 3);
186
-
187
-        $this->assertEmpty($data);
188
-        $this->assertInternalType('array', $data);
189
-    }
190
-
191
-    public function testGetActivitiesCount()
192
-    {
193
-        $testData = [
194
-            [
195
-                'id' => rand(1, 100),
196
-                'message' => 'test one',
197
-            ],
198
-            [
199
-                'id' => rand(101, 200),
200
-                'message' => 'test two',
201
-            ],
202
-        ];
203
-
204
-        array_walk($testData, [$this, 'insertData']);
205
-
206
-        $repository = new MysqlActivityRepository(self::$connection);
207
-        $data = $repository->getActivitiesCount();
208
-
209
-        $this->assertNotFalse($data);
210
-        $this->assertStringMatchesFormat('%d', $data);
211
-        $this->assertEquals(count($testData), $data);
212
-    }
213
-
214
-    public function testGetActivitiesCountEmpty()
215
-    {
216
-        $repository = new MysqlActivityRepository(self::$connection);
217
-        $data = $repository->getActivitiesCount();
218
-
219
-        $this->assertNotFalse($data);
220
-        $this->assertStringMatchesFormat('%d', $data);
221
-        $this->assertEquals('0', $data);
222
-    }
223
-
224
-    public function testGetActivitiesByType()
225
-    {
226
-        $testData = [
227
-            [
228
-                'id' => rand(1, 100),
229
-                'message' => 'test one',
230
-                'type' => 'type one',
231
-            ],
232
-            [
233
-                'id' => rand(101, 200),
234
-                'message' => 'test two',
235
-                'type' => 'type two',
236
-            ],
237
-            [
238
-                'id' => rand(201, 300),
239
-                'message' => 'test three',
240
-                'type' => 'type one',
241
-            ],
242
-        ];
243
-
244
-        array_walk($testData, [$this, 'insertData']);
245
-
246
-        $repository = new MysqlActivityRepository(self::$connection);
247
-        $data = $repository->getActivitiesByType('type one');
248
-
249
-        $this->assertNotFalse($data);
250
-        $this->assertInternalType('array', $data);
251
-
252
-        $testData = array_filter($testData, function ($row) {
253
-            return ($row['type'] == 'type one');
254
-        });
255
-        $testData = array_values($testData);
256
-
257
-        foreach ($testData as $key => $testRow) {
258
-            $this->assertInternalType('array', $testRow);
259
-            $this->assertArraySubset($testRow, $data[$key]);
260
-        }
261
-    }
262
-
263
-    public function testGetActivitiesByTypeFailure()
264
-    {
265
-        $testData = [
266
-            [
267
-                'id' => rand(1, 100),
268
-                'message' => 'test one',
269
-                'type' => 'type one',
270
-            ],
271
-            [
272
-                'id' => rand(101, 200),
273
-                'message' => 'test two',
274
-                'type' => 'type one',
275
-            ],
276
-        ];
277
-
278
-        array_walk($testData, [$this, 'insertData']);
279
-
280
-        $repository = new MysqlActivityRepository(self::$connection);
281
-        $data = $repository->getActivitiesByType('type two');
282
-
283
-        $this->assertEmpty($data);
284
-        $this->assertInternalType('array', $data);
285
-    }
286
-
287
-    public function testGetActivitiesByTypeRange()
288
-    {
289
-        $testData = [
290
-            [
291
-                'id' => rand(1, 100),
292
-                'message' => 'test one',
293
-                'type' => 'type one',
294
-            ],
295
-            [
296
-                'id' => rand(101, 200),
297
-                'message' => 'test two',
298
-                'type' => 'type two',
299
-            ],
300
-            [
301
-                'id' => rand(201, 300),
302
-                'message' => 'test three',
303
-                'type' => 'type one',
304
-            ],
305
-            [
306
-                'id' => rand(301, 400),
307
-                'message' => 'test four',
308
-                'type' => 'type one',
309
-            ],
310
-        ];
311
-
312
-        array_walk($testData, [$this, 'insertData']);
313
-
314
-        $repository = new MysqlActivityRepository(self::$connection);
315
-        $data = $repository->getActivitiesByType('type one', 2, 1);
316
-
317
-        $this->assertNotFalse($data);
318
-        $this->assertInternalType('array', $data);
319
-        $this->assertCount(2, $data);
320
-
321
-        $testData = array_filter($testData, function ($row) {
322
-            return ($row['type'] == 'type one');
323
-        });
324
-        $testData = array_values($testData);
325
-        $testData = array_slice($testData, 1, 2);
326
-
327
-        foreach ($testData as $key => $testRow) {
328
-            $this->assertInternalType('array', $testRow);
329
-            $this->assertArraySubset($testRow, $data[$key]);
330
-        }
331
-    }
332
-
333
-    public function testGetActivitiesByTypeRangeFailure()
334
-    {
335
-        $testData = [
336
-            [
337
-                'id' => rand(1, 100),
338
-                'message' => 'test one',
339
-                'type' => 'type one',
340
-            ],
341
-            [
342
-                'id' => rand(101, 200),
343
-                'message' => 'test two',
344
-                'type' => 'type one',
345
-            ],
346
-            [
347
-                'id' => rand(201, 300),
348
-                'message' => 'test three',
349
-                'type' => 'type one',
350
-            ],
351
-        ];
352
-
353
-        array_walk($testData, [$this, 'insertData']);
354
-
355
-        $repository = new MysqlActivityRepository(self::$connection);
356
-        $data = $repository->getActivitiesByType('type two', 2, 1);
357
-
358
-        $this->assertEmpty($data);
359
-        $this->assertInternalType('array', $data);
360
-    }
361
-
362
-    public function testGetActivitiesByTypeCount()
363
-    {
364
-        $testData = [
365
-            [
366
-                'id' => rand(1, 100),
367
-                'message' => 'test one',
368
-                'type' => 'type one',
369
-            ],
370
-            [
371
-                'id' => rand(101, 200),
372
-                'message' => 'test two',
373
-                'type' => 'type two',
374
-            ],
375
-            [
376
-                'id' => rand(201, 300),
377
-                'message' => 'test three',
378
-                'type' => 'type one',
379
-            ],
380
-        ];
381
-
382
-        array_walk($testData, [$this, 'insertData']);
383
-
384
-        $repository = new MysqlActivityRepository(self::$connection);
385
-        $data = $repository->getActivitiesByTypeCount('type one');
386
-
387
-        $testData = array_filter($testData, function ($row) {
388
-            return ($row['type'] == 'type one');
389
-        });
390
-
391
-        $this->assertNotFalse($data);
392
-        $this->assertStringMatchesFormat('%d', $data);
393
-        $this->assertEquals(count($testData), $data);
394
-    }
395
-
396
-    public function testGetActivitiesByTypeCountEmpty()
397
-    {
398
-        $testData = [
399
-            [
400
-                'id' => rand(1, 100),
401
-                'message' => 'test one',
402
-                'type' => 'type one',
403
-            ],
404
-            [
405
-                'id' => rand(101, 200),
406
-                'message' => 'test two',
407
-                'type' => 'type one',
408
-            ],
409
-        ];
410
-
411
-        array_walk($testData, [$this, 'insertData']);
412
-
413
-        $repository = new MysqlActivityRepository(self::$connection);
414
-        $data = $repository->getActivitiesByTypeCount('type two');
415
-
416
-        $this->assertNotFalse($data);
417
-        $this->assertStringMatchesFormat('%d', $data);
418
-        $this->assertEquals('0', $data);
419
-    }
420
-
421
-    protected function tearDown()
422
-    {
423
-        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`activity`");
424
-    }
425
-
426
-    public static function tearDownAfterClass()
427
-    {
428
-        self::$connection->getDefault()->disconnect();
429
-        unlink('jpemeric_stream.db');
430
-    }
431
-
432
-    protected function insertData(array $data)
433
-    {
434
-        $defaultData = [
435
-            'id' => null,
436
-            'message' => '',
437
-            'message_long' => '',
438
-            'datetime' => '',
439
-            'metadata' => '',
440
-            'type' => '',
441
-            'type_id' => '',
442
-        ];
443
-
444
-        $data = array_merge($defaultData, $data);
445
-
446
-        return self::$connection->getDefault()->perform("
30
+		);
31
+
32
+		self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
33
+			return $extendedPdo;
34
+		});
35
+	}
36
+
37
+	public function testIsInstanceOfActivityRepository()
38
+	{
39
+		$repository = new MysqlActivityRepository(self::$connection);
40
+
41
+		$this->assertInstanceOf(
42
+			'Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository',
43
+			$repository
44
+		);
45
+	}
46
+
47
+	public function testImplementsActivityInterface()
48
+	{
49
+		$repository = new MysqlActivityRepository(self::$connection);
50
+
51
+		$this->assertInstanceOf(
52
+			'Jacobemerick\Web\Domain\Stream\Activity\ActivityRepositoryInterface',
53
+			$repository
54
+		);
55
+	}
56
+
57
+	public function testConstructSetsConnections()
58
+	{
59
+		$respository = new MysqlActivityRepository(self::$connection);
60
+
61
+		$this->assertAttributeSame(
62
+			self::$connection,
63
+			'connections',
64
+			$respository
65
+		);
66
+	}
67
+
68
+	public function testGetActivityById()
69
+	{
70
+		$testData = [
71
+			'id' => rand(1, 100),
72
+			'message' => 'test data',
73
+		];
74
+
75
+		$this->insertData($testData);
76
+
77
+		$repository = new MysqlActivityRepository(self::$connection);
78
+		$data = $repository->getActivityById($testData['id']);
79
+
80
+		$this->assertNotFalse($data);
81
+		$this->assertInternalType('array', $data);
82
+		$this->assertArraySubset($testData, $data);
83
+	}
84
+
85
+	public function testGetActivityByIdFailure()
86
+	{
87
+		$testData = [
88
+			'id' => rand(1, 100),
89
+			'message' => 'test data',
90
+		];
91
+
92
+		$this->insertData($testData);
93
+
94
+		$repository = new MysqlActivityRepository(self::$connection);
95
+		$data = $repository->getActivityById($testData['id'] + 1);
96
+
97
+		$this->assertFalse($data);
98
+	}
99
+
100
+	public function testGetActivities()
101
+	{
102
+		$testData = [
103
+			[
104
+				'id' => rand(1, 100),
105
+				'message' => 'test one',
106
+			],
107
+			[
108
+				'id' => rand(101, 200),
109
+				'message' => 'test two',
110
+			],
111
+		];
112
+
113
+		array_walk($testData, [$this, 'insertData']);
114
+
115
+		$repository = new MysqlActivityRepository(self::$connection);
116
+		$data = $repository->getActivities();
117
+
118
+		$this->assertNotFalse($data);
119
+		$this->assertInternalType('array', $data);
120
+		foreach ($testData as $key => $testRow) {
121
+			$this->assertInternalType('array', $testRow);
122
+			$this->assertArraySubset($testRow, $data[$key]);
123
+		}
124
+	}
125
+
126
+	public function testGetActivitiesFailure()
127
+	{
128
+		$repository = new MysqlActivityRepository(self::$connection);
129
+		$data = $repository->getActivities();
130
+
131
+		$this->assertEmpty($data);
132
+		$this->assertInternalType('array', $data);
133
+	}
134
+
135
+	public function testGetActivitiesRange()
136
+	{
137
+		$testData = [
138
+			[
139
+				'id' => rand(1, 100),
140
+				'message' => 'test one',
141
+			],
142
+			[
143
+				'id' => rand(101, 200),
144
+				'message' => 'test two',
145
+			],
146
+			[
147
+				'id' => rand(201, 300),
148
+				'message' => 'test three',
149
+			],
150
+		];
151
+
152
+		array_walk($testData, [$this, 'insertData']);
153
+
154
+		$repository = new MysqlActivityRepository(self::$connection);
155
+		$data = $repository->getActivities(2, 1);
156
+
157
+		$this->assertNotFalse($data);
158
+		$this->assertInternalType('array', $data);
159
+		$this->assertCount(2, $data);
160
+
161
+		$testData = array_slice($testData, 1, 2);
162
+
163
+		foreach ($testData as $key => $testRow) {
164
+			$this->assertInternalType('array', $testRow);
165
+			$this->assertArraySubset($testRow, $data[$key]);
166
+		}
167
+	}
168
+
169
+	public function testGetActivitiesRangeFailure()
170
+	{
171
+		$testData = [
172
+			[
173
+				'id' => rand(1, 100),
174
+				'message' => 'test one',
175
+			],
176
+			[
177
+				'id' => rand(101, 200),
178
+				'message' => 'test two',
179
+			],
180
+		];
181
+
182
+		array_walk($testData, [$this, 'insertData']);
183
+
184
+		$repository = new MysqlActivityRepository(self::$connection);
185
+		$data = $repository->getActivities(1, 3);
186
+
187
+		$this->assertEmpty($data);
188
+		$this->assertInternalType('array', $data);
189
+	}
190
+
191
+	public function testGetActivitiesCount()
192
+	{
193
+		$testData = [
194
+			[
195
+				'id' => rand(1, 100),
196
+				'message' => 'test one',
197
+			],
198
+			[
199
+				'id' => rand(101, 200),
200
+				'message' => 'test two',
201
+			],
202
+		];
203
+
204
+		array_walk($testData, [$this, 'insertData']);
205
+
206
+		$repository = new MysqlActivityRepository(self::$connection);
207
+		$data = $repository->getActivitiesCount();
208
+
209
+		$this->assertNotFalse($data);
210
+		$this->assertStringMatchesFormat('%d', $data);
211
+		$this->assertEquals(count($testData), $data);
212
+	}
213
+
214
+	public function testGetActivitiesCountEmpty()
215
+	{
216
+		$repository = new MysqlActivityRepository(self::$connection);
217
+		$data = $repository->getActivitiesCount();
218
+
219
+		$this->assertNotFalse($data);
220
+		$this->assertStringMatchesFormat('%d', $data);
221
+		$this->assertEquals('0', $data);
222
+	}
223
+
224
+	public function testGetActivitiesByType()
225
+	{
226
+		$testData = [
227
+			[
228
+				'id' => rand(1, 100),
229
+				'message' => 'test one',
230
+				'type' => 'type one',
231
+			],
232
+			[
233
+				'id' => rand(101, 200),
234
+				'message' => 'test two',
235
+				'type' => 'type two',
236
+			],
237
+			[
238
+				'id' => rand(201, 300),
239
+				'message' => 'test three',
240
+				'type' => 'type one',
241
+			],
242
+		];
243
+
244
+		array_walk($testData, [$this, 'insertData']);
245
+
246
+		$repository = new MysqlActivityRepository(self::$connection);
247
+		$data = $repository->getActivitiesByType('type one');
248
+
249
+		$this->assertNotFalse($data);
250
+		$this->assertInternalType('array', $data);
251
+
252
+		$testData = array_filter($testData, function ($row) {
253
+			return ($row['type'] == 'type one');
254
+		});
255
+		$testData = array_values($testData);
256
+
257
+		foreach ($testData as $key => $testRow) {
258
+			$this->assertInternalType('array', $testRow);
259
+			$this->assertArraySubset($testRow, $data[$key]);
260
+		}
261
+	}
262
+
263
+	public function testGetActivitiesByTypeFailure()
264
+	{
265
+		$testData = [
266
+			[
267
+				'id' => rand(1, 100),
268
+				'message' => 'test one',
269
+				'type' => 'type one',
270
+			],
271
+			[
272
+				'id' => rand(101, 200),
273
+				'message' => 'test two',
274
+				'type' => 'type one',
275
+			],
276
+		];
277
+
278
+		array_walk($testData, [$this, 'insertData']);
279
+
280
+		$repository = new MysqlActivityRepository(self::$connection);
281
+		$data = $repository->getActivitiesByType('type two');
282
+
283
+		$this->assertEmpty($data);
284
+		$this->assertInternalType('array', $data);
285
+	}
286
+
287
+	public function testGetActivitiesByTypeRange()
288
+	{
289
+		$testData = [
290
+			[
291
+				'id' => rand(1, 100),
292
+				'message' => 'test one',
293
+				'type' => 'type one',
294
+			],
295
+			[
296
+				'id' => rand(101, 200),
297
+				'message' => 'test two',
298
+				'type' => 'type two',
299
+			],
300
+			[
301
+				'id' => rand(201, 300),
302
+				'message' => 'test three',
303
+				'type' => 'type one',
304
+			],
305
+			[
306
+				'id' => rand(301, 400),
307
+				'message' => 'test four',
308
+				'type' => 'type one',
309
+			],
310
+		];
311
+
312
+		array_walk($testData, [$this, 'insertData']);
313
+
314
+		$repository = new MysqlActivityRepository(self::$connection);
315
+		$data = $repository->getActivitiesByType('type one', 2, 1);
316
+
317
+		$this->assertNotFalse($data);
318
+		$this->assertInternalType('array', $data);
319
+		$this->assertCount(2, $data);
320
+
321
+		$testData = array_filter($testData, function ($row) {
322
+			return ($row['type'] == 'type one');
323
+		});
324
+		$testData = array_values($testData);
325
+		$testData = array_slice($testData, 1, 2);
326
+
327
+		foreach ($testData as $key => $testRow) {
328
+			$this->assertInternalType('array', $testRow);
329
+			$this->assertArraySubset($testRow, $data[$key]);
330
+		}
331
+	}
332
+
333
+	public function testGetActivitiesByTypeRangeFailure()
334
+	{
335
+		$testData = [
336
+			[
337
+				'id' => rand(1, 100),
338
+				'message' => 'test one',
339
+				'type' => 'type one',
340
+			],
341
+			[
342
+				'id' => rand(101, 200),
343
+				'message' => 'test two',
344
+				'type' => 'type one',
345
+			],
346
+			[
347
+				'id' => rand(201, 300),
348
+				'message' => 'test three',
349
+				'type' => 'type one',
350
+			],
351
+		];
352
+
353
+		array_walk($testData, [$this, 'insertData']);
354
+
355
+		$repository = new MysqlActivityRepository(self::$connection);
356
+		$data = $repository->getActivitiesByType('type two', 2, 1);
357
+
358
+		$this->assertEmpty($data);
359
+		$this->assertInternalType('array', $data);
360
+	}
361
+
362
+	public function testGetActivitiesByTypeCount()
363
+	{
364
+		$testData = [
365
+			[
366
+				'id' => rand(1, 100),
367
+				'message' => 'test one',
368
+				'type' => 'type one',
369
+			],
370
+			[
371
+				'id' => rand(101, 200),
372
+				'message' => 'test two',
373
+				'type' => 'type two',
374
+			],
375
+			[
376
+				'id' => rand(201, 300),
377
+				'message' => 'test three',
378
+				'type' => 'type one',
379
+			],
380
+		];
381
+
382
+		array_walk($testData, [$this, 'insertData']);
383
+
384
+		$repository = new MysqlActivityRepository(self::$connection);
385
+		$data = $repository->getActivitiesByTypeCount('type one');
386
+
387
+		$testData = array_filter($testData, function ($row) {
388
+			return ($row['type'] == 'type one');
389
+		});
390
+
391
+		$this->assertNotFalse($data);
392
+		$this->assertStringMatchesFormat('%d', $data);
393
+		$this->assertEquals(count($testData), $data);
394
+	}
395
+
396
+	public function testGetActivitiesByTypeCountEmpty()
397
+	{
398
+		$testData = [
399
+			[
400
+				'id' => rand(1, 100),
401
+				'message' => 'test one',
402
+				'type' => 'type one',
403
+			],
404
+			[
405
+				'id' => rand(101, 200),
406
+				'message' => 'test two',
407
+				'type' => 'type one',
408
+			],
409
+		];
410
+
411
+		array_walk($testData, [$this, 'insertData']);
412
+
413
+		$repository = new MysqlActivityRepository(self::$connection);
414
+		$data = $repository->getActivitiesByTypeCount('type two');
415
+
416
+		$this->assertNotFalse($data);
417
+		$this->assertStringMatchesFormat('%d', $data);
418
+		$this->assertEquals('0', $data);
419
+	}
420
+
421
+	protected function tearDown()
422
+	{
423
+		self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`activity`");
424
+	}
425
+
426
+	public static function tearDownAfterClass()
427
+	{
428
+		self::$connection->getDefault()->disconnect();
429
+		unlink('jpemeric_stream.db');
430
+	}
431
+
432
+	protected function insertData(array $data)
433
+	{
434
+		$defaultData = [
435
+			'id' => null,
436
+			'message' => '',
437
+			'message_long' => '',
438
+			'datetime' => '',
439
+			'metadata' => '',
440
+			'type' => '',
441
+			'type_id' => '',
442
+		];
443
+
444
+		$data = array_merge($defaultData, $data);
445
+
446
+		return self::$connection->getDefault()->perform("
447 447
             INSERT INTO `jpemeric_stream`.`activity`
448 448
                 (id, message, message_long, datetime, metadata, type, type_id)
449 449
             VALUES
450 450
                 (:id, :message, :message_long, :datetime, :metadata, :type, :type_id)",
451
-            $data
452
-        );
453
-    }
451
+			$data
452
+		);
453
+	}
454 454
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             )"
30 30
         );
31 31
 
32
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
32
+        self::$connection = new ConnectionLocator(function() use ($extendedPdo) {
33 33
             return $extendedPdo;
34 34
         });
35 35
     }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $this->assertNotFalse($data);
250 250
         $this->assertInternalType('array', $data);
251 251
 
252
-        $testData = array_filter($testData, function ($row) {
252
+        $testData = array_filter($testData, function($row) {
253 253
             return ($row['type'] == 'type one');
254 254
         });
255 255
         $testData = array_values($testData);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
         $this->assertInternalType('array', $data);
319 319
         $this->assertCount(2, $data);
320 320
 
321
-        $testData = array_filter($testData, function ($row) {
321
+        $testData = array_filter($testData, function($row) {
322 322
             return ($row['type'] == 'type one');
323 323
         });
324 324
         $testData = array_values($testData);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         $repository = new MysqlActivityRepository(self::$connection);
385 385
         $data = $repository->getActivitiesByTypeCount('type one');
386 386
 
387
-        $testData = array_filter($testData, function ($row) {
387
+        $testData = array_filter($testData, function($row) {
388 388
             return ($row['type'] == 'type one');
389 389
         });
390 390
 
Please login to merge, or discard this patch.
tests/unit/Domain/Stream/Changelog/MysqlChangelogRepositoryTest.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  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`");
18
-        $extendedPdo->exec("
14
+	public static function setUpBeforeClass()
15
+	{
16
+		$extendedPdo = new ExtendedPdo('sqlite::memory:');
17
+		$extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`");
18
+		$extendedPdo->exec("
19 19
             CREATE TABLE IF NOT EXISTS `jpemeric_stream`.`changelog` (
20 20
               `id` integer PRIMARY KEY AUTOINCREMENT,
21 21
               `hash` char(40) NOT NULL,
@@ -27,171 +27,171 @@  discard block
 block discarded – undo
27 27
               `created_at` datetime,
28 28
               `updated_at` datetime
29 29
             )"
30
-        );
31
-
32
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
33
-            return $extendedPdo;
34
-        });
35
-    }
36
-
37
-    public function testIsInstanceOfChangelogRepository()
38
-    {
39
-        $repository = new MysqlChangelogRepository(self::$connection);
40
-
41
-        $this->assertInstanceOf(
42
-            'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository',
43
-            $repository
44
-        );
45
-    }
46
-
47
-    public function testImplementsChangelogInterface()
48
-    {
49
-        $repository = new MysqlChangelogRepository(self::$connection);
50
-
51
-        $this->assertInstanceOf(
52
-            'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface',
53
-            $repository
54
-        );
55
-    }
56
-
57
-    public function testConstructSetsConnections()
58
-    {
59
-        $respository = new MysqlChangelogRepository(self::$connection);
60
-
61
-        $this->assertAttributeSame(
62
-            self::$connection,
63
-            'connections',
64
-            $respository
65
-        );
66
-    }
67
-
68
-    public function testGetChanges()
69
-    {
70
-        $testData = [
71
-            [
72
-                'id' => rand(1, 100),
73
-                'message' => 'test one',
74
-            ],
75
-            [
76
-                'id' => rand(101, 200),
77
-                'message' => 'test two',
78
-            ],
79
-        ];
80
-
81
-        array_walk($testData, [$this, 'insertData']);
82
-
83
-        $repository = new MysqlChangelogRepository(self::$connection);
84
-        $data = $repository->getChanges();
85
-
86
-        $this->assertNotFalse($data);
87
-        $this->assertInternalType('array', $data);
88
-        foreach ($testData as $key => $testRow) {
89
-            $this->assertInternalType('array', $testRow);
90
-            $this->assertArraySubset($testRow, $data[$key]);
91
-            $this->assertArrayHasKey('id', $data[$key]);
92
-            $this->assertArrayHasKey('message', $data[$key]);
93
-            $this->assertArrayHasKey('message_short', $data[$key]);
94
-            $this->assertArrayHasKey('datetime', $data[$key]);
95
-            $this->assertArrayHasKey('commit_link', $data[$key]);
96
-        }
97
-    }
98
-
99
-    public function testGetChangesFailure()
100
-    {
101
-        $repository = new MysqlChangelogRepository(self::$connection);
102
-        $data = $repository->getChanges();
103
-
104
-        $this->assertEmpty($data);
105
-        $this->assertInternalType('array', $data);
106
-    }
107
-
108
-    public function testGetChangesRange()
109
-    {
110
-        $testData = [
111
-            [
112
-                'id' => rand(1, 100),
113
-                'message' => 'test one',
114
-            ],
115
-            [
116
-                'id' => rand(101, 200),
117
-                'message' => 'test two',
118
-            ],
119
-            [
120
-                'id' => rand(201, 300),
121
-                'message' => 'test three',
122
-            ],
123
-        ];
124
-
125
-        array_walk($testData, [$this, 'insertData']);
126
-
127
-        $repository = new MysqlChangelogRepository(self::$connection);
128
-        $data = $repository->getChanges(2, 1);
129
-
130
-        $this->assertNotFalse($data);
131
-        $this->assertInternalType('array', $data);
132
-        $this->assertCount(2, $data);
133
-
134
-        $testData = array_slice($testData, 1, 2);
135
-
136
-        foreach ($testData as $key => $testRow) {
137
-            $this->assertInternalType('array', $testRow);
138
-            $this->assertArraySubset($testRow, $data[$key]);
139
-        }
140
-    }
141
-
142
-    public function testGetChangesRangeFailure()
143
-    {
144
-        $testData = [
145
-            [
146
-                'id' => rand(1, 100),
147
-                'message' => 'test one',
148
-            ],
149
-            [
150
-                'id' => rand(101, 200),
151
-                'message' => 'test two',
152
-            ],
153
-        ];
154
-
155
-        array_walk($testData, [$this, 'insertData']);
156
-
157
-        $repository = new MysqlChangelogRepository(self::$connection);
158
-        $data = $repository->getChanges(1, 3);
159
-
160
-        $this->assertEmpty($data);
161
-        $this->assertInternalType('array', $data);
162
-    }
163
-
164
-    protected function tearDown()
165
-    {
166
-        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`changelog`");
167
-    }
168
-
169
-    public static function tearDownAfterClass()
170
-    {
171
-        self::$connection->getDefault()->disconnect();
172
-        unlink('jpemeric_stream.db');
173
-    }
174
-
175
-    protected function insertData(array $data)
176
-    {
177
-        $defaultData = [
178
-            'id' => null,
179
-            'hash' => '',
180
-            'message' => null,
181
-            'message_short' => null,
182
-            'datetime' => '',
183
-            'author' => '',
184
-            'commit_link' => '',
185
-        ];
186
-
187
-        $data = array_merge($defaultData, $data);
188
-
189
-        return self::$connection->getDefault()->perform("
30
+		);
31
+
32
+		self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
33
+			return $extendedPdo;
34
+		});
35
+	}
36
+
37
+	public function testIsInstanceOfChangelogRepository()
38
+	{
39
+		$repository = new MysqlChangelogRepository(self::$connection);
40
+
41
+		$this->assertInstanceOf(
42
+			'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository',
43
+			$repository
44
+		);
45
+	}
46
+
47
+	public function testImplementsChangelogInterface()
48
+	{
49
+		$repository = new MysqlChangelogRepository(self::$connection);
50
+
51
+		$this->assertInstanceOf(
52
+			'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface',
53
+			$repository
54
+		);
55
+	}
56
+
57
+	public function testConstructSetsConnections()
58
+	{
59
+		$respository = new MysqlChangelogRepository(self::$connection);
60
+
61
+		$this->assertAttributeSame(
62
+			self::$connection,
63
+			'connections',
64
+			$respository
65
+		);
66
+	}
67
+
68
+	public function testGetChanges()
69
+	{
70
+		$testData = [
71
+			[
72
+				'id' => rand(1, 100),
73
+				'message' => 'test one',
74
+			],
75
+			[
76
+				'id' => rand(101, 200),
77
+				'message' => 'test two',
78
+			],
79
+		];
80
+
81
+		array_walk($testData, [$this, 'insertData']);
82
+
83
+		$repository = new MysqlChangelogRepository(self::$connection);
84
+		$data = $repository->getChanges();
85
+
86
+		$this->assertNotFalse($data);
87
+		$this->assertInternalType('array', $data);
88
+		foreach ($testData as $key => $testRow) {
89
+			$this->assertInternalType('array', $testRow);
90
+			$this->assertArraySubset($testRow, $data[$key]);
91
+			$this->assertArrayHasKey('id', $data[$key]);
92
+			$this->assertArrayHasKey('message', $data[$key]);
93
+			$this->assertArrayHasKey('message_short', $data[$key]);
94
+			$this->assertArrayHasKey('datetime', $data[$key]);
95
+			$this->assertArrayHasKey('commit_link', $data[$key]);
96
+		}
97
+	}
98
+
99
+	public function testGetChangesFailure()
100
+	{
101
+		$repository = new MysqlChangelogRepository(self::$connection);
102
+		$data = $repository->getChanges();
103
+
104
+		$this->assertEmpty($data);
105
+		$this->assertInternalType('array', $data);
106
+	}
107
+
108
+	public function testGetChangesRange()
109
+	{
110
+		$testData = [
111
+			[
112
+				'id' => rand(1, 100),
113
+				'message' => 'test one',
114
+			],
115
+			[
116
+				'id' => rand(101, 200),
117
+				'message' => 'test two',
118
+			],
119
+			[
120
+				'id' => rand(201, 300),
121
+				'message' => 'test three',
122
+			],
123
+		];
124
+
125
+		array_walk($testData, [$this, 'insertData']);
126
+
127
+		$repository = new MysqlChangelogRepository(self::$connection);
128
+		$data = $repository->getChanges(2, 1);
129
+
130
+		$this->assertNotFalse($data);
131
+		$this->assertInternalType('array', $data);
132
+		$this->assertCount(2, $data);
133
+
134
+		$testData = array_slice($testData, 1, 2);
135
+
136
+		foreach ($testData as $key => $testRow) {
137
+			$this->assertInternalType('array', $testRow);
138
+			$this->assertArraySubset($testRow, $data[$key]);
139
+		}
140
+	}
141
+
142
+	public function testGetChangesRangeFailure()
143
+	{
144
+		$testData = [
145
+			[
146
+				'id' => rand(1, 100),
147
+				'message' => 'test one',
148
+			],
149
+			[
150
+				'id' => rand(101, 200),
151
+				'message' => 'test two',
152
+			],
153
+		];
154
+
155
+		array_walk($testData, [$this, 'insertData']);
156
+
157
+		$repository = new MysqlChangelogRepository(self::$connection);
158
+		$data = $repository->getChanges(1, 3);
159
+
160
+		$this->assertEmpty($data);
161
+		$this->assertInternalType('array', $data);
162
+	}
163
+
164
+	protected function tearDown()
165
+	{
166
+		self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`changelog`");
167
+	}
168
+
169
+	public static function tearDownAfterClass()
170
+	{
171
+		self::$connection->getDefault()->disconnect();
172
+		unlink('jpemeric_stream.db');
173
+	}
174
+
175
+	protected function insertData(array $data)
176
+	{
177
+		$defaultData = [
178
+			'id' => null,
179
+			'hash' => '',
180
+			'message' => null,
181
+			'message_short' => null,
182
+			'datetime' => '',
183
+			'author' => '',
184
+			'commit_link' => '',
185
+		];
186
+
187
+		$data = array_merge($defaultData, $data);
188
+
189
+		return self::$connection->getDefault()->perform("
190 190
             INSERT INTO `jpemeric_stream`.`changelog`
191 191
                 (id, hash, message, message_short, datetime, author, commit_link)
192 192
             VALUES
193 193
                 (:id, :hash, :message, :message_short, :datetime, :author, :commit_link)",
194
-            $data
195
-        );
196
-    }
194
+			$data
195
+		);
196
+	}
197 197
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
             )"
30 30
         );
31 31
 
32
-        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
32
+        self::$connection = new ConnectionLocator(function() use ($extendedPdo) {
33 33
             return $extendedPdo;
34 34
         });
35 35
     }
Please login to merge, or discard this patch.