Completed
Push — master ( 568319...1f7489 )
by Jacob
04:04
created
src/Domain/Blog/MysqlPostRepository.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     protected $connections;
12 12
 
13 13
     /**
14
-     * @param Aura\Sql\ConnectionLocator $connections
14
+     * @param ConnectionLocator $connections
15 15
      */
16 16
     public function __construct(ConnectionLocator $connections)
17 17
     {
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param string $category
23 23
      * @param string $path
24 24
      *
25
-     * @return array|false
25
+     * @return boolean
26 26
      */
27 27
     public function findByPath($category, $path)
28 28
     {
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@
 block discarded – undo
7 7
 class MysqlPostRepository implements PostRepository
8 8
 {
9 9
 
10
-    /** @var  Aura\Sql\ConnectionLocator */
11
-    protected $connections;
10
+	/** @var  Aura\Sql\ConnectionLocator */
11
+	protected $connections;
12 12
 
13
-    /**
14
-     * @param Aura\Sql\ConnectionLocator $connections
15
-     */
16
-    public function __construct(ConnectionLocator $connections)
17
-    {
18
-        $this->connections = $connections;
19
-    }
13
+	/**
14
+	 * @param Aura\Sql\ConnectionLocator $connections
15
+	 */
16
+	public function __construct(ConnectionLocator $connections)
17
+	{
18
+		$this->connections = $connections;
19
+	}
20 20
 
21
-    /**
22
-     * @param string $category
23
-     * @param string $path
24
-     *
25
-     * @return array|false
26
-     */
27
-    public function findByPath($category, $path)
28
-    {
29
-        $query = "
21
+	/**
22
+	 * @param string $category
23
+	 * @param string $path
24
+	 *
25
+	 * @return array|false
26
+	 */
27
+	public function findByPath($category, $path)
28
+	{
29
+		$query = "
30 30
             SELECT `id`, `title`, `path`, `date`, `body`, `category`
31 31
             FROM `jpemeric_blog`.`post`
32 32
             WHERE `path` = :path AND `category` = :category AND `display` = :is_active
33 33
             LIMIT 1";
34
-        $bindings = array(
35
-            'path'      => $path,
36
-            'category'  => $category,
37
-            'is_active' => 1,
38
-        );
34
+		$bindings = array(
35
+			'path'      => $path,
36
+			'category'  => $category,
37
+			'is_active' => 1,
38
+		);
39 39
 
40
-        return $this
41
-            ->connections
42
-            ->getRead()
43
-            ->fetchOne($query, $bindings);
44
-    }
40
+		return $this
41
+			->connections
42
+			->getRead()
43
+			->fetchOne($query, $bindings);
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Domain/Blog/PostRepository.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,5 +4,5 @@
 block discarded – undo
4 4
 
5 5
 interface PostRepository
6 6
 {
7
-    public function findByPath($category, $path);
7
+	public function findByPath($category, $path);
8 8
 }
Please login to merge, or discard this patch.
tests/unit/domain/blog/MysqlPostRepositoryTest.php 1 patch
Indentation   +68 added lines, -68 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;
10
+	protected $connections;
11 11
 
12
-    public function __construct()
13
-    {
14
-        $extendedPdo = $this->newExtendedPdo();
15
-        $this->connections = new ConnectionLocator(function () use ($extendedPdo) {
16
-            return $extendedPdo;
17
-        });
18
-    }
12
+	public function __construct()
13
+	{
14
+		$extendedPdo = $this->newExtendedPdo();
15
+		$this->connections = new ConnectionLocator(function () use ($extendedPdo) {
16
+			return $extendedPdo;
17
+		});
18
+	}
19 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("
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,79 +31,79 @@  discard block
 block discarded – undo
31 31
               `body` text NOT NULL,
32 32
               `display` integer NOT NULL
33 33
             )"
34
-        );
35
-        return $extendedPdo;
36
-    }
34
+		);
35
+		return $extendedPdo;
36
+	}
37 37
 
38
-    public function newMysqlPostRepository()
39
-    {
40
-        return new MysqlPostRepository($this->connections);
41
-    }
38
+	public function newMysqlPostRepository()
39
+	{
40
+		return new MysqlPostRepository($this->connections);
41
+	}
42 42
 
43
-    public function testFindByPath()
44
-    {
45
-        $test_active_post = array(
46
-            'title'     => 'test findByPath active',
47
-            'path'      => 'test-findbypath-active',
48
-            'category'  => 'test-category',
49
-            'date'      => (new DateTime())->format('Y-m-d H:i:s'),
50
-            'body'      => 'test content',
51
-            'display'   => 1
52
-        );
43
+	public function testFindByPath()
44
+	{
45
+		$test_active_post = array(
46
+			'title'     => 'test findByPath active',
47
+			'path'      => 'test-findbypath-active',
48
+			'category'  => 'test-category',
49
+			'date'      => (new DateTime())->format('Y-m-d H:i:s'),
50
+			'body'      => 'test content',
51
+			'display'   => 1
52
+		);
53 53
 
54
-        $this->connections->getDefault()->perform("
54
+		$this->connections->getDefault()->perform("
55 55
             INSERT INTO jpemeric_blog.post
56 56
                 (title, path, category, date, body, display)
57 57
             VALUES
58 58
                 (:title, :path, :category, :date, :body, :display)",
59
-            $test_active_post);
59
+			$test_active_post);
60 60
 
61
-        $active_post = $this->newMysqlPostRepository()->findByPath(
62
-            $test_active_post['category'],
63
-            $test_active_post['path']
64
-        );
65
-        $this->assertSame($test_active_post['title'], $active_post['title']);
61
+		$active_post = $this->newMysqlPostRepository()->findByPath(
62
+			$test_active_post['category'],
63
+			$test_active_post['path']
64
+		);
65
+		$this->assertSame($test_active_post['title'], $active_post['title']);
66 66
 
67
-        $test_inactive_post = array(
68
-            'title'     => 'test findByPath inactive',
69
-            'path'      => 'test-findbypath-inactive',
70
-            'category'  => 'test-category',
71
-            'date'      => (new DateTime())->format('Y-m-d H:i:s'),
72
-            'body'      => 'test content',
73
-            'display'   => 0
74
-        );
67
+		$test_inactive_post = array(
68
+			'title'     => 'test findByPath inactive',
69
+			'path'      => 'test-findbypath-inactive',
70
+			'category'  => 'test-category',
71
+			'date'      => (new DateTime())->format('Y-m-d H:i:s'),
72
+			'body'      => 'test content',
73
+			'display'   => 0
74
+		);
75 75
 
76
-        $this->connections->getDefault()->perform("
76
+		$this->connections->getDefault()->perform("
77 77
             INSERT INTO jpemeric_blog.post
78 78
                 (title, path, category, date, body, display)
79 79
             VALUES
80 80
                 (:title, :path, :category, :date, :body, :display)",
81
-            $test_inactive_post);
81
+			$test_inactive_post);
82 82
 
83
-        $inactive_post = $this->newMysqlPostRepository()->findByPath(
84
-            $test_inactive_post['category'],
85
-            $test_inactive_post['path']
86
-        );
87
-        $this->assertFalse($inactive_post);
83
+		$inactive_post = $this->newMysqlPostRepository()->findByPath(
84
+			$test_inactive_post['category'],
85
+			$test_inactive_post['path']
86
+		);
87
+		$this->assertFalse($inactive_post);
88 88
 
89
-        $nonexistant_post = $this->newMysqlPostRepository()->findByPath(
90
-            'test-category',
91
-            'test-findbypath-nonexistant'
92
-        );
93
-        $this->assertFalse($nonexistant_post);
89
+		$nonexistant_post = $this->newMysqlPostRepository()->findByPath(
90
+			'test-category',
91
+			'test-findbypath-nonexistant'
92
+		);
93
+		$this->assertFalse($nonexistant_post);
94 94
    }
95 95
 
96
-    public function testIsInstanceOfPostRepository()
97
-    {
98
-        $this->assertInstanceOf(
99
-            'Jacobemerick\Web\Domain\Blog\PostRepository',
100
-            $this->newMysqlPostRepository()
101
-        );
102
-    }
96
+	public function testIsInstanceOfPostRepository()
97
+	{
98
+		$this->assertInstanceOf(
99
+			'Jacobemerick\Web\Domain\Blog\PostRepository',
100
+			$this->newMysqlPostRepository()
101
+		);
102
+	}
103 103
 
104
-    public static function tearDownAfterClass()
105
-    {
104
+	public static function tearDownAfterClass()
105
+	{
106 106
 //        $this->connections->getDefault()->disconnect();
107
-        unlink('jpemeric_blog.db');
108
-    }
107
+		unlink('jpemeric_blog.db');
108
+	}
109 109
 }
Please login to merge, or discard this patch.