@@ -8,21 +8,21 @@ discard block |
||
8 | 8 | class MysqlPostRepositoryTest extends \PHPUnit_Framework_TestCase |
9 | 9 | { |
10 | 10 | |
11 | - protected $connections; |
|
11 | + protected $connections; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - $extendedPdo = $this->newExtendedPdo(); |
|
16 | - $this->connections = new ConnectionLocator(function () use ($extendedPdo) { |
|
17 | - return $extendedPdo; |
|
18 | - }); |
|
19 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + $extendedPdo = $this->newExtendedPdo(); |
|
16 | + $this->connections = new ConnectionLocator(function () use ($extendedPdo) { |
|
17 | + return $extendedPdo; |
|
18 | + }); |
|
19 | + } |
|
20 | 20 | |
21 | - protected function newExtendedPdo() |
|
22 | - { |
|
23 | - $extendedPdo = new ExtendedPdo('sqlite::memory:'); |
|
24 | - $extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`'); |
|
25 | - $extendedPdo->exec(" |
|
21 | + protected function newExtendedPdo() |
|
22 | + { |
|
23 | + $extendedPdo = new ExtendedPdo('sqlite::memory:'); |
|
24 | + $extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`'); |
|
25 | + $extendedPdo->exec(" |
|
26 | 26 | CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`post` ( |
27 | 27 | `id` integer PRIMARY KEY AUTOINCREMENT, |
28 | 28 | `title` varchar(60) NOT NULL, |
@@ -32,48 +32,48 @@ discard block |
||
32 | 32 | `body` text NOT NULL, |
33 | 33 | `display` integer NOT NULL |
34 | 34 | )" |
35 | - ); |
|
36 | - return $extendedPdo; |
|
37 | - } |
|
35 | + ); |
|
36 | + return $extendedPdo; |
|
37 | + } |
|
38 | 38 | |
39 | - public function newMysqlPostRepository() |
|
40 | - { |
|
41 | - return new MysqlPostRepository($this->connections); |
|
42 | - } |
|
39 | + public function newMysqlPostRepository() |
|
40 | + { |
|
41 | + return new MysqlPostRepository($this->connections); |
|
42 | + } |
|
43 | 43 | |
44 | - public function testFindByUri() |
|
45 | - { |
|
46 | - $test_post = array( |
|
47 | - 'title' => 'test title', |
|
48 | - 'path' => 'test-uri', |
|
49 | - 'category' => 'test', |
|
50 | - 'date' => date('Y-m-d H:i:s'), |
|
51 | - 'body' => 'test content', |
|
52 | - 'display' => 1 |
|
53 | - ); |
|
44 | + public function testFindByUri() |
|
45 | + { |
|
46 | + $test_post = array( |
|
47 | + 'title' => 'test title', |
|
48 | + 'path' => 'test-uri', |
|
49 | + 'category' => 'test', |
|
50 | + 'date' => date('Y-m-d H:i:s'), |
|
51 | + 'body' => 'test content', |
|
52 | + 'display' => 1 |
|
53 | + ); |
|
54 | 54 | |
55 | - $this->connections->getDefault()->perform(" |
|
55 | + $this->connections->getDefault()->perform(" |
|
56 | 56 | INSERT INTO jpemeric_blog.post |
57 | 57 | (title, path, category, date, body, display) |
58 | 58 | VALUES |
59 | 59 | (:title, :path, :category, :date, :body, :display)", |
60 | - $test_post); |
|
60 | + $test_post); |
|
61 | 61 | |
62 | - $post = $this->newMysqlPostRepository()->findByUri($test_post['path']); |
|
63 | - $this->assertSame($test_post['path'], $post['path']); |
|
64 | - } |
|
62 | + $post = $this->newMysqlPostRepository()->findByUri($test_post['path']); |
|
63 | + $this->assertSame($test_post['path'], $post['path']); |
|
64 | + } |
|
65 | 65 | |
66 | - public function testIsInstanceOfPostRepository() |
|
67 | - { |
|
68 | - $this->assertInstanceOf( |
|
69 | - 'Jacobemerick\Web\Domain\Blog\PostRepository', |
|
70 | - $this->newMysqlPostRepository() |
|
71 | - ); |
|
72 | - } |
|
66 | + public function testIsInstanceOfPostRepository() |
|
67 | + { |
|
68 | + $this->assertInstanceOf( |
|
69 | + 'Jacobemerick\Web\Domain\Blog\PostRepository', |
|
70 | + $this->newMysqlPostRepository() |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | - public static function tearDownAfterClass() |
|
75 | - { |
|
74 | + public static function tearDownAfterClass() |
|
75 | + { |
|
76 | 76 | // $this->connections->getDefault()->disconnect(); |
77 | - unlink('jpemeric_blog.db'); |
|
78 | - } |
|
77 | + unlink('jpemeric_blog.db'); |
|
78 | + } |
|
79 | 79 | } |