Completed
Push — master ( a2526c...4c6be8 )
by Jacob
03:16
created
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 1 patch
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.
tests/unit/Domain/Stream/Changelog/MysqlChangelogRepositoryTest.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,35 +9,35 @@
 block discarded – undo
9 9
 class MysqlChangelogRepositoryTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    public function testIsInstanceOfChangelogRepository()
13
-    {
14
-        $repository = new MysqlChangelogRepository(new ConnectionLocator());
15
-
16
-        $this->assertInstanceOf(
17
-            'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository',
18
-            $repository
19
-        );
20
-    }
21
-
22
-    public function testImplementsChangelogInterface()
23
-    {
24
-        $repository = new MysqlChangelogRepository(new ConnectionLocator());
25
-
26
-        $this->assertInstanceOf(
27
-            'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface',
28
-            $repository
29
-        );
30
-    }
31
-
32
-    public function testConstructSetsConnections()
33
-    {
34
-        $connection = new ConnectionLocator();
35
-        $respository = new MysqlChangelogRepository($connection);
36
-
37
-        $this->assertAttributeSame(
38
-            $connection,
39
-            'connections',
40
-            $respository
41
-        );
42
-    }
12
+	public function testIsInstanceOfChangelogRepository()
13
+	{
14
+		$repository = new MysqlChangelogRepository(new ConnectionLocator());
15
+
16
+		$this->assertInstanceOf(
17
+			'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository',
18
+			$repository
19
+		);
20
+	}
21
+
22
+	public function testImplementsChangelogInterface()
23
+	{
24
+		$repository = new MysqlChangelogRepository(new ConnectionLocator());
25
+
26
+		$this->assertInstanceOf(
27
+			'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface',
28
+			$repository
29
+		);
30
+	}
31
+
32
+	public function testConstructSetsConnections()
33
+	{
34
+		$connection = new ConnectionLocator();
35
+		$respository = new MysqlChangelogRepository($connection);
36
+
37
+		$this->assertAttributeSame(
38
+			$connection,
39
+			'connections',
40
+			$respository
41
+		);
42
+	}
43 43
 }
Please login to merge, or discard this patch.
tests/unit/Domain/Stream/Activity/MysqlActivityRepositoryTest.php 1 patch
Indentation   +191 added lines, -191 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,193 +27,193 @@  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
-        $this->insertData($testData[0]);
114
-        $this->insertData($testData[1]);
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', $testRow);
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
-    public function testGetActivitiesRangeFailure() {}
139
-
140
-    public function testGetActivitiesCount()
141
-    {
142
-        $testData = [
143
-            [
144
-                'id' => rand(1, 100),
145
-                'message' => 'test one',
146
-            ],
147
-            [
148
-                'id' => rand(101, 200),
149
-                'message' => 'test two',
150
-            ],
151
-        ];
152
-
153
-        $this->insertData($testData[0]);
154
-        $this->insertData($testData[1]);
155
-
156
-        $repository = new MysqlActivityRepository(self::$connection);
157
-        $data = $repository->getActivitiesCount();
158
-
159
-        $this->assertNotFalse($data);
160
-        $this->assertStringMatchesFormat('%d', $data);
161
-        $this->assertEquals(count($testData), $data);
162
-    }
163
-
164
-    public function testGetActivitiesCountEmpty()
165
-    {
166
-        $repository = new MysqlActivityRepository(self::$connection);
167
-        $data = $repository->getActivitiesCount();
168
-
169
-        $this->assertNotFalse($data);
170
-        $this->assertStringMatchesFormat('%d', $data);
171
-        $this->assertEquals('0', $data);
172
-    }
173
-
174
-    public function testGetActivitiesByType() {}
175
-
176
-    public function testGetActivitiesByTypeFailure() {}
177
-
178
-    public function testGetActivitiesByTypeRange() {}
179
-
180
-    public function testGetActivitiesByTypeRangeFailure() {}
181
-
182
-    public function testGetActivitiesByTypeCount() {}
183
-
184
-    public function testGetActivitiesByTypeCountEmpty() {}
185
-
186
-    protected function tearDown()
187
-    {
188
-        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`activity`");
189
-    }
190
-
191
-    public static function tearDownAfterClass()
192
-    {
193
-        self::$connection->getDefault()->disconnect();
194
-        unlink('jpemeric_stream.db');
195
-    }
196
-
197
-    protected function insertData(array $data)
198
-    {
199
-        $defaultData = [
200
-            'id' => null,
201
-            'message' => '',
202
-            'message_long' => '',
203
-            'datetime' => '',
204
-            'metadata' => '',
205
-            'type' => '',
206
-            'type_id' => '',
207
-        ];
208
-
209
-        $data = array_merge($defaultData, $data);
210
-
211
-        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
+		$this->insertData($testData[0]);
114
+		$this->insertData($testData[1]);
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', $testRow);
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
+	public function testGetActivitiesRangeFailure() {}
139
+
140
+	public function testGetActivitiesCount()
141
+	{
142
+		$testData = [
143
+			[
144
+				'id' => rand(1, 100),
145
+				'message' => 'test one',
146
+			],
147
+			[
148
+				'id' => rand(101, 200),
149
+				'message' => 'test two',
150
+			],
151
+		];
152
+
153
+		$this->insertData($testData[0]);
154
+		$this->insertData($testData[1]);
155
+
156
+		$repository = new MysqlActivityRepository(self::$connection);
157
+		$data = $repository->getActivitiesCount();
158
+
159
+		$this->assertNotFalse($data);
160
+		$this->assertStringMatchesFormat('%d', $data);
161
+		$this->assertEquals(count($testData), $data);
162
+	}
163
+
164
+	public function testGetActivitiesCountEmpty()
165
+	{
166
+		$repository = new MysqlActivityRepository(self::$connection);
167
+		$data = $repository->getActivitiesCount();
168
+
169
+		$this->assertNotFalse($data);
170
+		$this->assertStringMatchesFormat('%d', $data);
171
+		$this->assertEquals('0', $data);
172
+	}
173
+
174
+	public function testGetActivitiesByType() {}
175
+
176
+	public function testGetActivitiesByTypeFailure() {}
177
+
178
+	public function testGetActivitiesByTypeRange() {}
179
+
180
+	public function testGetActivitiesByTypeRangeFailure() {}
181
+
182
+	public function testGetActivitiesByTypeCount() {}
183
+
184
+	public function testGetActivitiesByTypeCountEmpty() {}
185
+
186
+	protected function tearDown()
187
+	{
188
+		self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`activity`");
189
+	}
190
+
191
+	public static function tearDownAfterClass()
192
+	{
193
+		self::$connection->getDefault()->disconnect();
194
+		unlink('jpemeric_stream.db');
195
+	}
196
+
197
+	protected function insertData(array $data)
198
+	{
199
+		$defaultData = [
200
+			'id' => null,
201
+			'message' => '',
202
+			'message_long' => '',
203
+			'datetime' => '',
204
+			'metadata' => '',
205
+			'type' => '',
206
+			'type_id' => '',
207
+		];
208
+
209
+		$data = array_merge($defaultData, $data);
210
+
211
+		return self::$connection->getDefault()->perform("
212 212
             INSERT INTO `jpemeric_stream`.`activity`
213 213
                 (id, message, message_long, datetime, metadata, type, type_id)
214 214
             VALUES
215 215
                 (:id, :message, :message_long, :datetime, :metadata, :type, :type_id)",
216
-            $data
217
-        );
218
-    }
216
+			$data
217
+		);
218
+	}
219 219
 }
Please login to merge, or discard this patch.