summaryrefslogtreecommitdiffstats
path: root/tests/integration/db/ItemMapperTest.php
blob: 97956b28d3bc5afc2f9714338367fbd6f673d511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

namespace OCA\News\Db;

use \OCA\News\AppInfo\Application;
use \OCA\News\Tests\Integration\NewsIntegrationTest;

class ItemMapperTest extends NewsIntegrationTest {

    private $container;
    private $itemMapper;

    protected function setUp() {
        parent::setUpOwnCloud();
        $app = new Application();
        $this->container = $app->getContainer();
        $this->itemMapper = $this->container->query('ItemMapper');
    }


    public function testInsert() {
        $item = new Item();
        $item->setTitle('my title');
        $item->setGuid('test');
        $item->setFeedId(3);
        $item->setUnread();

        $created = $this->itemMapper->insert($item);

        $fetched = $this->itemMapper->find($created->getId(), $this->userId);

        $this->assertEquals($item->getTitle(), $fetched->getTitle());
        $this->assertEquals($item->getGuid(), $fetched->getGuid());
        $this->assertEquals($item->getGuidHash(), $fetched->getGuidHash());
        $this->assertEquals($item->getFeedId(), $fetched->getFeedId());
        $this->assertEquals($item->isRead(), $fetched->isRead());
    }

}