@@ -34,6 +34,6 @@ |
||
34 | 34 | * @param $value |
35 | 35 | */ |
36 | 36 | public function __set($name, $value) { |
37 | - $this->setter($name, [$value]); |
|
37 | + $this->setter($name, [ $value ]); |
|
38 | 38 | } |
39 | 39 | } |
@@ -26,14 +26,14 @@ |
||
26 | 26 | use OCP\AppFramework\Db\Entity; |
27 | 27 | |
28 | 28 | abstract class Model extends Entity { |
29 | - /** |
|
30 | - * FactoryMuffin checks for the existence of setters with method_exists($obj, $attr) but that returns false. |
|
31 | - * By overwriting the __set() magic method we can trigger the changed flag on $obj->attr assignment. |
|
32 | - * |
|
33 | - * @param $name |
|
34 | - * @param $value |
|
35 | - */ |
|
36 | - public function __set($name, $value) { |
|
37 | - $this->setter($name, [$value]); |
|
38 | - } |
|
29 | + /** |
|
30 | + * FactoryMuffin checks for the existence of setters with method_exists($obj, $attr) but that returns false. |
|
31 | + * By overwriting the __set() magic method we can trigger the changed flag on $obj->attr assignment. |
|
32 | + * |
|
33 | + * @param $name |
|
34 | + * @param $value |
|
35 | + */ |
|
36 | + public function __set($name, $value) { |
|
37 | + $this->setter($name, [$value]); |
|
38 | + } |
|
39 | 39 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | $fm->define('OCA\Polls\Db\Comment')->setDefinitions([ |
30 | 30 | 'userId' => Faker::firstNameMale(), |
31 | - 'dt' => function () { |
|
31 | + 'dt' => function() { |
|
32 | 32 | $date = new DateTime('today'); |
33 | 33 | return $date->format('Y-m-d H:i:s'); |
34 | 34 | }, |
@@ -27,10 +27,10 @@ |
||
27 | 27 | * General factory for the comment model. |
28 | 28 | */ |
29 | 29 | $fm->define('OCA\Polls\Db\Comment')->setDefinitions([ |
30 | - 'userId' => Faker::firstNameMale(), |
|
31 | - 'dt' => function () { |
|
32 | - $date = new DateTime('today'); |
|
33 | - return $date->format('Y-m-d H:i:s'); |
|
34 | - }, |
|
35 | - 'comment' => Faker::text(256) |
|
30 | + 'userId' => Faker::firstNameMale(), |
|
31 | + 'dt' => function () { |
|
32 | + $date = new DateTime('today'); |
|
33 | + return $date->format('Y-m-d H:i:s'); |
|
34 | + }, |
|
35 | + 'comment' => Faker::text(256) |
|
36 | 36 | ]); |
@@ -29,85 +29,85 @@ |
||
29 | 29 | |
30 | 30 | class PageControllerTest extends UnitTestCase { |
31 | 31 | |
32 | - /** @var PageController */ |
|
33 | - private $controller; |
|
32 | + /** @var PageController */ |
|
33 | + private $controller; |
|
34 | 34 | |
35 | - private $userId = 'john'; |
|
35 | + private $userId = 'john'; |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inheritDoc} |
|
39 | - */ |
|
40 | - public function setUp() { |
|
41 | - $request = $this->getMockBuilder('OCP\IRequest') |
|
42 | - ->disableOriginalConstructor() |
|
43 | - ->getMock(); |
|
44 | - $userManager = $this->getMockBuilder('OCP\IUserManager') |
|
45 | - ->disableOriginalConstructor() |
|
46 | - ->getMock(); |
|
47 | - $groupManager = $this->getMockBuilder('OCP\IGroupManager') |
|
48 | - ->disableOriginalConstructor() |
|
49 | - ->getMock(); |
|
50 | - $avatarManager = $this->getMockBuilder('OCP\IAvatarManager') |
|
51 | - ->disableOriginalConstructor() |
|
52 | - ->getMock(); |
|
53 | - $logger = $this->getMockBuilder('OCP\ILogger') |
|
54 | - ->disableOriginalConstructor() |
|
55 | - ->getMock(); |
|
56 | - $l10n = $this->getMockBuilder('OCP\IL10N') |
|
57 | - ->disableOriginalConstructor() |
|
58 | - ->getMock(); |
|
59 | - $urlGenerator = $this->getMockBuilder('OCP\IURLGenerator') |
|
60 | - ->disableOriginalConstructor() |
|
61 | - ->getMock(); |
|
62 | - $commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper') |
|
63 | - ->disableOriginalConstructor() |
|
64 | - ->getMock(); |
|
65 | - $dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper') |
|
66 | - ->disableOriginalConstructor() |
|
67 | - ->getMock(); |
|
68 | - $eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper') |
|
69 | - ->disableOriginalConstructor() |
|
70 | - ->getMock(); |
|
71 | - $notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper') |
|
72 | - ->disableOriginalConstructor() |
|
73 | - ->getMock(); |
|
74 | - $participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper') |
|
75 | - ->disableOriginalConstructor() |
|
76 | - ->getMock(); |
|
77 | - $participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper') |
|
78 | - ->disableOriginalConstructor() |
|
79 | - ->getMock(); |
|
80 | - $textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper') |
|
81 | - ->disableOriginalConstructor() |
|
82 | - ->getMock(); |
|
37 | + /** |
|
38 | + * {@inheritDoc} |
|
39 | + */ |
|
40 | + public function setUp() { |
|
41 | + $request = $this->getMockBuilder('OCP\IRequest') |
|
42 | + ->disableOriginalConstructor() |
|
43 | + ->getMock(); |
|
44 | + $userManager = $this->getMockBuilder('OCP\IUserManager') |
|
45 | + ->disableOriginalConstructor() |
|
46 | + ->getMock(); |
|
47 | + $groupManager = $this->getMockBuilder('OCP\IGroupManager') |
|
48 | + ->disableOriginalConstructor() |
|
49 | + ->getMock(); |
|
50 | + $avatarManager = $this->getMockBuilder('OCP\IAvatarManager') |
|
51 | + ->disableOriginalConstructor() |
|
52 | + ->getMock(); |
|
53 | + $logger = $this->getMockBuilder('OCP\ILogger') |
|
54 | + ->disableOriginalConstructor() |
|
55 | + ->getMock(); |
|
56 | + $l10n = $this->getMockBuilder('OCP\IL10N') |
|
57 | + ->disableOriginalConstructor() |
|
58 | + ->getMock(); |
|
59 | + $urlGenerator = $this->getMockBuilder('OCP\IURLGenerator') |
|
60 | + ->disableOriginalConstructor() |
|
61 | + ->getMock(); |
|
62 | + $commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper') |
|
63 | + ->disableOriginalConstructor() |
|
64 | + ->getMock(); |
|
65 | + $dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper') |
|
66 | + ->disableOriginalConstructor() |
|
67 | + ->getMock(); |
|
68 | + $eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper') |
|
69 | + ->disableOriginalConstructor() |
|
70 | + ->getMock(); |
|
71 | + $notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper') |
|
72 | + ->disableOriginalConstructor() |
|
73 | + ->getMock(); |
|
74 | + $participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper') |
|
75 | + ->disableOriginalConstructor() |
|
76 | + ->getMock(); |
|
77 | + $participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper') |
|
78 | + ->disableOriginalConstructor() |
|
79 | + ->getMock(); |
|
80 | + $textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper') |
|
81 | + ->disableOriginalConstructor() |
|
82 | + ->getMock(); |
|
83 | 83 | |
84 | - $this->controller = new PageController( |
|
85 | - 'polls', |
|
86 | - $request, |
|
87 | - $userManager, |
|
88 | - $groupManager, |
|
89 | - $avatarManager, |
|
90 | - $logger, |
|
91 | - $l10n, |
|
92 | - $urlGenerator, |
|
93 | - $this->userId, |
|
94 | - $commentMapper, |
|
95 | - $dateMapper, |
|
96 | - $eventMapper, |
|
97 | - $notificationMapper, |
|
98 | - $participationMapper, |
|
99 | - $participationTextMapper, |
|
100 | - $textMapper |
|
101 | - ); |
|
102 | - } |
|
84 | + $this->controller = new PageController( |
|
85 | + 'polls', |
|
86 | + $request, |
|
87 | + $userManager, |
|
88 | + $groupManager, |
|
89 | + $avatarManager, |
|
90 | + $logger, |
|
91 | + $l10n, |
|
92 | + $urlGenerator, |
|
93 | + $this->userId, |
|
94 | + $commentMapper, |
|
95 | + $dateMapper, |
|
96 | + $eventMapper, |
|
97 | + $notificationMapper, |
|
98 | + $participationMapper, |
|
99 | + $participationTextMapper, |
|
100 | + $textMapper |
|
101 | + ); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Basic controller index route test. |
|
106 | - */ |
|
107 | - public function testIndex() { |
|
108 | - $result = $this->controller->index(); |
|
104 | + /** |
|
105 | + * Basic controller index route test. |
|
106 | + */ |
|
107 | + public function testIndex() { |
|
108 | + $result = $this->controller->index(); |
|
109 | 109 | |
110 | - $this->assertEquals('main.tmpl', $result->getTemplateName()); |
|
111 | - $this->assertInstanceOf(TemplateResponse::class, $result); |
|
112 | - } |
|
110 | + $this->assertEquals('main.tmpl', $result->getTemplateName()); |
|
111 | + $this->assertInstanceOf(TemplateResponse::class, $result); |
|
112 | + } |
|
113 | 113 | } |
@@ -28,15 +28,15 @@ |
||
28 | 28 | |
29 | 29 | abstract class UnitTestCase extends PHPUnit_Framework_TestCase { |
30 | 30 | |
31 | - /** @var FactoryMuffin */ |
|
32 | - protected $fm; |
|
31 | + /** @var FactoryMuffin */ |
|
32 | + protected $fm; |
|
33 | 33 | |
34 | - /** |
|
35 | - * {@inheritDoc} |
|
36 | - */ |
|
37 | - public function setUp() { |
|
38 | - parent::setUp(); |
|
39 | - $this->fm = new FactoryMuffin(); |
|
40 | - $this->fm->loadFactories(__DIR__ . '/Factories'); |
|
41 | - } |
|
34 | + /** |
|
35 | + * {@inheritDoc} |
|
36 | + */ |
|
37 | + public function setUp() { |
|
38 | + parent::setUp(); |
|
39 | + $this->fm = new FactoryMuffin(); |
|
40 | + $this->fm->loadFactories(__DIR__ . '/Factories'); |
|
41 | + } |
|
42 | 42 | } |
@@ -27,10 +27,10 @@ |
||
27 | 27 | * General factory for the participation model. |
28 | 28 | */ |
29 | 29 | $fm->define('OCA\Polls\Db\Participation')->setDefinitions([ |
30 | - 'userId' => Faker::firstNameMale(), |
|
31 | - 'dt' => function () { |
|
32 | - $date = new DateTime('today'); |
|
33 | - return $date->format('Y-m-d H:i:s'); |
|
34 | - }, |
|
35 | - 'type' => 0 |
|
30 | + 'userId' => Faker::firstNameMale(), |
|
31 | + 'dt' => function () { |
|
32 | + $date = new DateTime('today'); |
|
33 | + return $date->format('Y-m-d H:i:s'); |
|
34 | + }, |
|
35 | + 'type' => 0 |
|
36 | 36 | ]); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | $fm->define('OCA\Polls\Db\Participation')->setDefinitions([ |
30 | 30 | 'userId' => Faker::firstNameMale(), |
31 | - 'dt' => function () { |
|
31 | + 'dt' => function() { |
|
32 | 32 | $date = new DateTime('today'); |
33 | 33 | return $date->format('Y-m-d H:i:s'); |
34 | 34 | }, |
@@ -25,8 +25,8 @@ |
||
25 | 25 | * General factory for the date model. |
26 | 26 | */ |
27 | 27 | $fm->define('OCA\Polls\Db\Date')->setDefinitions([ |
28 | - 'dt' => function () { |
|
29 | - $date = new DateTime('today'); |
|
30 | - return $date->format('Y-m-d H:i:s'); |
|
31 | - } |
|
28 | + 'dt' => function () { |
|
29 | + $date = new DateTime('today'); |
|
30 | + return $date->format('Y-m-d H:i:s'); |
|
31 | + } |
|
32 | 32 | ]); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * General factory for the date model. |
26 | 26 | */ |
27 | 27 | $fm->define('OCA\Polls\Db\Date')->setDefinitions([ |
28 | - 'dt' => function () { |
|
28 | + 'dt' => function() { |
|
29 | 29 | $date = new DateTime('today'); |
30 | 30 | return $date->format('Y-m-d H:i:s'); |
31 | 31 | } |
@@ -33,65 +33,65 @@ |
||
33 | 33 | |
34 | 34 | class CommentMapperTest extends UnitTestCase { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $con; |
|
38 | - /** @var CommentMapper */ |
|
39 | - private $commentMapper; |
|
40 | - /** @var EventMapper */ |
|
41 | - private $eventMapper; |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $con; |
|
38 | + /** @var CommentMapper */ |
|
39 | + private $commentMapper; |
|
40 | + /** @var EventMapper */ |
|
41 | + private $eventMapper; |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - */ |
|
46 | - public function setUp() { |
|
47 | - parent::setUp(); |
|
48 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | - $this->commentMapper = new CommentMapper($this->con); |
|
50 | - $this->eventMapper = new EventMapper($this->con); |
|
51 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + */ |
|
46 | + public function setUp() { |
|
47 | + parent::setUp(); |
|
48 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | + $this->commentMapper = new CommentMapper($this->con); |
|
50 | + $this->eventMapper = new EventMapper($this->con); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Create some fake data and persist them to the database. |
|
55 | - * |
|
56 | - * @return Comment |
|
57 | - */ |
|
58 | - public function testCreate() { |
|
59 | - /** @var Event $event */ |
|
60 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
53 | + /** |
|
54 | + * Create some fake data and persist them to the database. |
|
55 | + * |
|
56 | + * @return Comment |
|
57 | + */ |
|
58 | + public function testCreate() { |
|
59 | + /** @var Event $event */ |
|
60 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
62 | 62 | |
63 | - /** @var Comment $comment */ |
|
64 | - $comment = $this->fm->instance('OCA\Polls\Db\Comment'); |
|
65 | - $comment->setPollId($event->getId()); |
|
66 | - $this->assertInstanceOf(Comment::class, $this->commentMapper->insert($comment)); |
|
63 | + /** @var Comment $comment */ |
|
64 | + $comment = $this->fm->instance('OCA\Polls\Db\Comment'); |
|
65 | + $comment->setPollId($event->getId()); |
|
66 | + $this->assertInstanceOf(Comment::class, $this->commentMapper->insert($comment)); |
|
67 | 67 | |
68 | - return $comment; |
|
69 | - } |
|
68 | + return $comment; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Update the previously created entry and persist the changes. |
|
73 | - * |
|
74 | - * @depends testCreate |
|
75 | - * @param Comment $comment |
|
76 | - * @return Comment |
|
77 | - */ |
|
78 | - public function testUpdate(Comment $comment) { |
|
79 | - $newComment = Faker::paragraph(); |
|
80 | - $comment->setComment($newComment()); |
|
81 | - $this->commentMapper->update($comment); |
|
71 | + /** |
|
72 | + * Update the previously created entry and persist the changes. |
|
73 | + * |
|
74 | + * @depends testCreate |
|
75 | + * @param Comment $comment |
|
76 | + * @return Comment |
|
77 | + */ |
|
78 | + public function testUpdate(Comment $comment) { |
|
79 | + $newComment = Faker::paragraph(); |
|
80 | + $comment->setComment($newComment()); |
|
81 | + $this->commentMapper->update($comment); |
|
82 | 82 | |
83 | - return $comment; |
|
84 | - } |
|
83 | + return $comment; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Delete the previously created entries from the database. |
|
88 | - * |
|
89 | - * @depends testUpdate |
|
90 | - * @param Comment $comment |
|
91 | - */ |
|
92 | - public function testDelete(Comment $comment) { |
|
93 | - $event = $this->eventMapper->find($comment->getPollId()); |
|
94 | - $this->commentMapper->delete($comment); |
|
95 | - $this->eventMapper->delete($event); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Delete the previously created entries from the database. |
|
88 | + * |
|
89 | + * @depends testUpdate |
|
90 | + * @param Comment $comment |
|
91 | + */ |
|
92 | + public function testDelete(Comment $comment) { |
|
93 | + $event = $this->eventMapper->find($comment->getPollId()); |
|
94 | + $this->commentMapper->delete($comment); |
|
95 | + $this->eventMapper->delete($event); |
|
96 | + } |
|
97 | 97 | } |
@@ -33,65 +33,65 @@ |
||
33 | 33 | |
34 | 34 | class DateMapperTest extends UnitTestCase { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $con; |
|
38 | - /** @var DateMapper */ |
|
39 | - private $dateMapper; |
|
40 | - /** @var EventMapper */ |
|
41 | - private $eventMapper; |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $con; |
|
38 | + /** @var DateMapper */ |
|
39 | + private $dateMapper; |
|
40 | + /** @var EventMapper */ |
|
41 | + private $eventMapper; |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - */ |
|
46 | - public function setUp() { |
|
47 | - parent::setUp(); |
|
48 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | - $this->dateMapper = new DateMapper($this->con); |
|
50 | - $this->eventMapper = new EventMapper($this->con); |
|
51 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + */ |
|
46 | + public function setUp() { |
|
47 | + parent::setUp(); |
|
48 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | + $this->dateMapper = new DateMapper($this->con); |
|
50 | + $this->eventMapper = new EventMapper($this->con); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Create some fake data and persist them to the database. |
|
55 | - * |
|
56 | - * @return Date |
|
57 | - */ |
|
58 | - public function testCreate() { |
|
59 | - /** @var Event $event */ |
|
60 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
53 | + /** |
|
54 | + * Create some fake data and persist them to the database. |
|
55 | + * |
|
56 | + * @return Date |
|
57 | + */ |
|
58 | + public function testCreate() { |
|
59 | + /** @var Event $event */ |
|
60 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
62 | 62 | |
63 | - /** @var Date $date */ |
|
64 | - $date = $this->fm->instance('OCA\Polls\Db\Date'); |
|
65 | - $date->setPollId($event->getId()); |
|
66 | - $this->assertInstanceOf(Date::class, $this->dateMapper->insert($date)); |
|
63 | + /** @var Date $date */ |
|
64 | + $date = $this->fm->instance('OCA\Polls\Db\Date'); |
|
65 | + $date->setPollId($event->getId()); |
|
66 | + $this->assertInstanceOf(Date::class, $this->dateMapper->insert($date)); |
|
67 | 67 | |
68 | - return $date; |
|
69 | - } |
|
68 | + return $date; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Update the previously created entry and persist the changes. |
|
73 | - * |
|
74 | - * @depends testCreate |
|
75 | - * @param Date $date |
|
76 | - * @return Date |
|
77 | - */ |
|
78 | - public function testUpdate(Date $date) { |
|
79 | - $newDt = Faker::date('Y-m-d H:i:s'); |
|
80 | - $date->setDt($newDt()); |
|
81 | - $this->dateMapper->update($date); |
|
71 | + /** |
|
72 | + * Update the previously created entry and persist the changes. |
|
73 | + * |
|
74 | + * @depends testCreate |
|
75 | + * @param Date $date |
|
76 | + * @return Date |
|
77 | + */ |
|
78 | + public function testUpdate(Date $date) { |
|
79 | + $newDt = Faker::date('Y-m-d H:i:s'); |
|
80 | + $date->setDt($newDt()); |
|
81 | + $this->dateMapper->update($date); |
|
82 | 82 | |
83 | - return $date; |
|
84 | - } |
|
83 | + return $date; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Delete the previously created entries from the database. |
|
88 | - * |
|
89 | - * @depends testUpdate |
|
90 | - * @param Date $date |
|
91 | - */ |
|
92 | - public function testDelete(Date $date) { |
|
93 | - $event = $this->eventMapper->find($date->getPollId()); |
|
94 | - $this->dateMapper->delete($date); |
|
95 | - $this->eventMapper->delete($event); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Delete the previously created entries from the database. |
|
88 | + * |
|
89 | + * @depends testUpdate |
|
90 | + * @param Date $date |
|
91 | + */ |
|
92 | + public function testDelete(Date $date) { |
|
93 | + $event = $this->eventMapper->find($date->getPollId()); |
|
94 | + $this->dateMapper->delete($date); |
|
95 | + $this->eventMapper->delete($event); |
|
96 | + } |
|
97 | 97 | } |
@@ -33,65 +33,65 @@ |
||
33 | 33 | |
34 | 34 | class NotificationMapperTest extends UnitTestCase { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $con; |
|
38 | - /** @var NotificationMapper */ |
|
39 | - private $notificationMapper; |
|
40 | - /** @var EventMapper */ |
|
41 | - private $eventMapper; |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $con; |
|
38 | + /** @var NotificationMapper */ |
|
39 | + private $notificationMapper; |
|
40 | + /** @var EventMapper */ |
|
41 | + private $eventMapper; |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - */ |
|
46 | - public function setUp() { |
|
47 | - parent::setUp(); |
|
48 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | - $this->notificationMapper = new NotificationMapper($this->con); |
|
50 | - $this->eventMapper = new EventMapper($this->con); |
|
51 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + */ |
|
46 | + public function setUp() { |
|
47 | + parent::setUp(); |
|
48 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | + $this->notificationMapper = new NotificationMapper($this->con); |
|
50 | + $this->eventMapper = new EventMapper($this->con); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Create some fake data and persist them to the database. |
|
55 | - * |
|
56 | - * @return Notification |
|
57 | - */ |
|
58 | - public function testCreate() { |
|
59 | - /** @var Event $event */ |
|
60 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
53 | + /** |
|
54 | + * Create some fake data and persist them to the database. |
|
55 | + * |
|
56 | + * @return Notification |
|
57 | + */ |
|
58 | + public function testCreate() { |
|
59 | + /** @var Event $event */ |
|
60 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
62 | 62 | |
63 | - /** @var Notification $notification */ |
|
64 | - $notification = $this->fm->instance('OCA\Polls\Db\Notification'); |
|
65 | - $notification->setPollId($event->getId()); |
|
66 | - $this->assertInstanceOf(Notification::class, $this->notificationMapper->insert($notification)); |
|
63 | + /** @var Notification $notification */ |
|
64 | + $notification = $this->fm->instance('OCA\Polls\Db\Notification'); |
|
65 | + $notification->setPollId($event->getId()); |
|
66 | + $this->assertInstanceOf(Notification::class, $this->notificationMapper->insert($notification)); |
|
67 | 67 | |
68 | - return $notification; |
|
69 | - } |
|
68 | + return $notification; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Update the previously created entry and persist the changes. |
|
73 | - * |
|
74 | - * @depends testCreate |
|
75 | - * @param Notification $notification |
|
76 | - * @return Notification |
|
77 | - */ |
|
78 | - public function testUpdate(Notification $notification) { |
|
79 | - $newUserId = Faker::firstNameMale(); |
|
80 | - $notification->setUserId($newUserId()); |
|
81 | - $this->notificationMapper->update($notification); |
|
71 | + /** |
|
72 | + * Update the previously created entry and persist the changes. |
|
73 | + * |
|
74 | + * @depends testCreate |
|
75 | + * @param Notification $notification |
|
76 | + * @return Notification |
|
77 | + */ |
|
78 | + public function testUpdate(Notification $notification) { |
|
79 | + $newUserId = Faker::firstNameMale(); |
|
80 | + $notification->setUserId($newUserId()); |
|
81 | + $this->notificationMapper->update($notification); |
|
82 | 82 | |
83 | - return $notification; |
|
84 | - } |
|
83 | + return $notification; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Delete the previously created entries from the database. |
|
88 | - * |
|
89 | - * @depends testUpdate |
|
90 | - * @param Notification $notification |
|
91 | - */ |
|
92 | - public function testDelete(Notification $notification) { |
|
93 | - $event = $this->eventMapper->find($notification->getPollId()); |
|
94 | - $this->notificationMapper->delete($notification); |
|
95 | - $this->eventMapper->delete($event); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Delete the previously created entries from the database. |
|
88 | + * |
|
89 | + * @depends testUpdate |
|
90 | + * @param Notification $notification |
|
91 | + */ |
|
92 | + public function testDelete(Notification $notification) { |
|
93 | + $event = $this->eventMapper->find($notification->getPollId()); |
|
94 | + $this->notificationMapper->delete($notification); |
|
95 | + $this->eventMapper->delete($event); |
|
96 | + } |
|
97 | 97 | } |