| @@ 34-97 (lines=64) @@ | ||
| 31 | use OCP\IDBConnection; |
|
| 32 | use League\FactoryMuffin\Faker\Facade as Faker; |
|
| 33 | ||
| 34 | class CommentMapperTest extends UnitTestCase { |
|
| 35 | ||
| 36 | /** @var IDBConnection */ |
|
| 37 | private $con; |
|
| 38 | /** @var CommentMapper */ |
|
| 39 | private $commentMapper; |
|
| 40 | /** @var EventMapper */ |
|
| 41 | private $eventMapper; |
|
| 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 | } |
|
| 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)); |
|
| 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)); |
|
| 67 | ||
| 68 | return $comment; |
|
| 69 | } |
|
| 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); |
|
| 82 | ||
| 83 | return $comment; |
|
| 84 | } |
|
| 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 | } |
|
| 97 | } |
|
| 98 | ||
| @@ 34-97 (lines=64) @@ | ||
| 31 | use OCP\IDBConnection; |
|
| 32 | use League\FactoryMuffin\Faker\Facade as Faker; |
|
| 33 | ||
| 34 | class DateMapperTest extends UnitTestCase { |
|
| 35 | ||
| 36 | /** @var IDBConnection */ |
|
| 37 | private $con; |
|
| 38 | /** @var DateMapper */ |
|
| 39 | private $dateMapper; |
|
| 40 | /** @var EventMapper */ |
|
| 41 | private $eventMapper; |
|
| 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 | } |
|
| 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)); |
|
| 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)); |
|
| 67 | ||
| 68 | return $date; |
|
| 69 | } |
|
| 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); |
|
| 82 | ||
| 83 | return $date; |
|
| 84 | } |
|
| 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 | } |
|
| 97 | } |
|
| 98 | ||
| @@ 34-97 (lines=64) @@ | ||
| 31 | use OCP\IDBConnection; |
|
| 32 | use League\FactoryMuffin\Faker\Facade as Faker; |
|
| 33 | ||
| 34 | class NotificationMapperTest extends UnitTestCase { |
|
| 35 | ||
| 36 | /** @var IDBConnection */ |
|
| 37 | private $con; |
|
| 38 | /** @var NotificationMapper */ |
|
| 39 | private $notificationMapper; |
|
| 40 | /** @var EventMapper */ |
|
| 41 | private $eventMapper; |
|
| 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 | } |
|
| 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)); |
|
| 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)); |
|
| 67 | ||
| 68 | return $notification; |
|
| 69 | } |
|
| 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); |
|
| 82 | ||
| 83 | return $notification; |
|
| 84 | } |
|
| 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 | } |
|
| 97 | } |
|
| 98 | ||
| @@ 34-97 (lines=64) @@ | ||
| 31 | use OCP\IDBConnection; |
|
| 32 | use League\FactoryMuffin\Faker\Facade as Faker; |
|
| 33 | ||
| 34 | class ParticipationMapperTest extends UnitTestCase { |
|
| 35 | ||
| 36 | /** @var IDBConnection */ |
|
| 37 | private $con; |
|
| 38 | /** @var ParticipationMapper */ |
|
| 39 | private $participationMapper; |
|
| 40 | /** @var EventMapper */ |
|
| 41 | private $eventMapper; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritDoc} |
|
| 45 | */ |
|
| 46 | public function setUp() { |
|
| 47 | parent::setUp(); |
|
| 48 | $this->con = \OC::$server->getDatabaseConnection(); |
|
| 49 | $this->participationMapper = new ParticipationMapper($this->con); |
|
| 50 | $this->eventMapper = new EventMapper($this->con); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Create some fake data and persist them to the database. |
|
| 55 | * |
|
| 56 | * @return Participation |
|
| 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 | ||
| 63 | /** @var Participation $participation */ |
|
| 64 | $participation = $this->fm->instance('OCA\Polls\Db\Participation'); |
|
| 65 | $participation->setPollId($event->getId()); |
|
| 66 | $this->assertInstanceOf(Participation::class, $this->participationMapper->insert($participation)); |
|
| 67 | ||
| 68 | return $participation; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Update the previously created entry and persist the changes. |
|
| 73 | * |
|
| 74 | * @depends testCreate |
|
| 75 | * @param Participation $participation |
|
| 76 | * @return Participation |
|
| 77 | */ |
|
| 78 | public function testUpdate(Participation $participation) { |
|
| 79 | $newDt = Faker::date('Y-m-d H:i:s'); |
|
| 80 | $participation->setDt($newDt()); |
|
| 81 | $this->participationMapper->update($participation); |
|
| 82 | ||
| 83 | return $participation; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Delete the previously created entries from the database. |
|
| 88 | * |
|
| 89 | * @depends testUpdate |
|
| 90 | * @param Participation $participation |
|
| 91 | */ |
|
| 92 | public function testDelete(Participation $participation) { |
|
| 93 | $event = $this->eventMapper->find($participation->getPollId()); |
|
| 94 | $this->participationMapper->delete($participation); |
|
| 95 | $this->eventMapper->delete($event); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||
| @@ 34-97 (lines=64) @@ | ||
| 31 | use OCP\IDBConnection; |
|
| 32 | use League\FactoryMuffin\Faker\Facade as Faker; |
|
| 33 | ||
| 34 | class ParticipationTextMapperTest extends UnitTestCase { |
|
| 35 | ||
| 36 | /** @var IDBConnection */ |
|
| 37 | private $con; |
|
| 38 | /** @var ParticipationTextMapper */ |
|
| 39 | private $participationTextMapper; |
|
| 40 | /** @var EventMapper */ |
|
| 41 | private $eventMapper; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritDoc} |
|
| 45 | */ |
|
| 46 | public function setUp() { |
|
| 47 | parent::setUp(); |
|
| 48 | $this->con = \OC::$server->getDatabaseConnection(); |
|
| 49 | $this->participationTextMapper = new ParticipationTextMapper($this->con); |
|
| 50 | $this->eventMapper = new EventMapper($this->con); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Create some fake data and persist them to the database. |
|
| 55 | * |
|
| 56 | * @return ParticipationText |
|
| 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 | ||
| 63 | /** @var ParticipationText $participationText */ |
|
| 64 | $participationText = $this->fm->instance('OCA\Polls\Db\ParticipationText'); |
|
| 65 | $participationText->setPollId($event->getId()); |
|
| 66 | $this->assertInstanceOf(ParticipationText::class, $this->participationTextMapper->insert($participationText)); |
|
| 67 | ||
| 68 | return $participationText; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Update the previously created entry and persist the changes. |
|
| 73 | * |
|
| 74 | * @depends testCreate |
|
| 75 | * @param ParticipationText $participationText |
|
| 76 | * @return ParticipationText |
|
| 77 | */ |
|
| 78 | public function testUpdate(ParticipationText $participationText) { |
|
| 79 | $newText = Faker::paragraph(); |
|
| 80 | $participationText->setText($newText()); |
|
| 81 | $this->participationTextMapper->update($participationText); |
|
| 82 | ||
| 83 | return $participationText; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Delete the previously created entries from the database. |
|
| 88 | * |
|
| 89 | * @depends testUpdate |
|
| 90 | * @param ParticipationText $participationText |
|
| 91 | */ |
|
| 92 | public function testDelete(ParticipationText $participationText) { |
|
| 93 | $event = $this->eventMapper->find($participationText->getPollId()); |
|
| 94 | $this->participationTextMapper->delete($participationText); |
|
| 95 | $this->eventMapper->delete($event); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||
| @@ 34-97 (lines=64) @@ | ||
| 31 | use OCP\IDBConnection; |
|
| 32 | use League\FactoryMuffin\Faker\Facade as Faker; |
|
| 33 | ||
| 34 | class TextMapperTest extends UnitTestCase { |
|
| 35 | ||
| 36 | /** @var IDBConnection */ |
|
| 37 | private $con; |
|
| 38 | /** @var TextMapper */ |
|
| 39 | private $textMapper; |
|
| 40 | /** @var EventMapper */ |
|
| 41 | private $eventMapper; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritDoc} |
|
| 45 | */ |
|
| 46 | public function setUp() { |
|
| 47 | parent::setUp(); |
|
| 48 | $this->con = \OC::$server->getDatabaseConnection(); |
|
| 49 | $this->textMapper = new TextMapper($this->con); |
|
| 50 | $this->eventMapper = new EventMapper($this->con); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Create some fake data and persist them to the database. |
|
| 55 | * |
|
| 56 | * @return Text |
|
| 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 | ||
| 63 | /** @var Text $text */ |
|
| 64 | $text = $this->fm->instance('OCA\Polls\Db\Text'); |
|
| 65 | $text->setPollId($event->getId()); |
|
| 66 | $this->assertInstanceOf(Text::class, $this->textMapper->insert($text)); |
|
| 67 | ||
| 68 | return $text; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Update the previously created entry and persist the changes. |
|
| 73 | * |
|
| 74 | * @depends testCreate |
|
| 75 | * @param Text $text |
|
| 76 | * @return Text |
|
| 77 | */ |
|
| 78 | public function testUpdate(Text $text) { |
|
| 79 | $newText = Faker::paragraph(); |
|
| 80 | $text->setText($newText()); |
|
| 81 | $this->textMapper->update($text); |
|
| 82 | ||
| 83 | return $text; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Delete the previously created entries from the database. |
|
| 88 | * |
|
| 89 | * @depends testUpdate |
|
| 90 | * @param Text $text |
|
| 91 | */ |
|
| 92 | public function testDelete(Text $text) { |
|
| 93 | $event = $this->eventMapper->find($text->getPollId()); |
|
| 94 | $this->textMapper->delete($text); |
|
| 95 | $this->eventMapper->delete($event); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||