summaryrefslogtreecommitdiffstats
path: root/tests/Integration
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-08-29 23:39:35 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-27 15:35:31 +0200
commitd00d1ab2a28f428223e52b17052c072c64784016 (patch)
treec019f85fb7ac67147dd43ca64b4ac3cda99832f7 /tests/Integration
parent5687baca75d47dbdffd3de74e865ad2f71ef0cb7 (diff)
Create V2 mapper, Service and management commands
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests/Integration')
-rw-r--r--tests/Integration/Db/FeedMapperTest.php16
-rw-r--r--tests/Integration/Db/ItemMapperTest.php52
-rw-r--r--tests/Integration/IntegrationTest.php30
3 files changed, 45 insertions, 53 deletions
diff --git a/tests/Integration/Db/FeedMapperTest.php b/tests/Integration/Db/FeedMapperTest.php
index 626b8f9a9..f07103d10 100644
--- a/tests/Integration/Db/FeedMapperTest.php
+++ b/tests/Integration/Db/FeedMapperTest.php
@@ -25,7 +25,7 @@ class FeedMapperTest extends IntegrationTest
$feed = new FeedFixture();
$feed = $this->feedMapper->insert($feed);
- $fetched = $this->feedMapper->find($feed->getId(), $this->user);
+ $fetched = $this->feedMapper->find($this->user, $feed->getId());
$this->assertInstanceOf(Feed::class, $fetched);
$this->assertEquals($feed->getLink(), $fetched->getLink());
@@ -34,7 +34,7 @@ class FeedMapperTest extends IntegrationTest
public function testFindNotExisting()
{
$this->expectException('OCP\AppFramework\Db\DoesNotExistException');
- $this->feedMapper->find(0, $this->user);
+ $this->feedMapper->find($this->user, 0);
}
@@ -252,22 +252,14 @@ class FeedMapperTest extends IntegrationTest
$this->assertCount(4, $this->feedMapper->findAllFromUser($this->user));
- $items = $this->itemMapper->findAll(100, 0, 0, true, false, $this->user);
+ $items = $this->itemMapper->findAllItems(100, 0, 0, true, false, $this->user);
$this->assertCount(9, $items);
$this->feedMapper->deleteUser($this->user);
$this->assertCount(0, $this->feedMapper->findAllFromUser($this->user));
- $items = $this->itemMapper->findAll(100, 0, 0, true, false, $this->user);
+ $items = $this->itemMapper->findAllItems(100, 0, 0, true, false, $this->user);
$this->assertCount(0, $items);
}
-
- /**
- * @coversNothing
- */
- public function testDeleteUserNotExisting()
- {
- $this->feedMapper->deleteUser('notexistinguser');
- }
}
diff --git a/tests/Integration/Db/ItemMapperTest.php b/tests/Integration/Db/ItemMapperTest.php
index 026834e6b..28a6c3e11 100644
--- a/tests/Integration/Db/ItemMapperTest.php
+++ b/tests/Integration/Db/ItemMapperTest.php
@@ -27,7 +27,7 @@ class ItemMapperTest extends IntegrationTest
$item = $this->itemMapper->insert($item);
- $fetched = $this->itemMapper->find($item->getId(), $this->user);
+ $fetched = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals($item->getTitle(), $fetched->getTitle());
}
@@ -44,7 +44,7 @@ class ItemMapperTest extends IntegrationTest
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testFindNotFoundWhenDeletedFeed()
{
@@ -52,12 +52,12 @@ class ItemMapperTest extends IntegrationTest
$this->loadFixtures('default');
$id = $this->whereTitleId('not found feed');
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testFindNotFoundWhenDeletedFolder()
{
@@ -66,7 +66,7 @@ class ItemMapperTest extends IntegrationTest
$id = $this->whereTitleId('not found folder');
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
@@ -76,15 +76,15 @@ class ItemMapperTest extends IntegrationTest
$this->itemMapper->deleteReadOlderThanThreshold(1);
- $this->itemMapper->find($this->whereTitleId('a title1'), $this->user);
- $this->itemMapper->find($this->whereTitleId('a title2'), $this->user);
- $this->itemMapper->find($this->whereTitleId('a title3'), $this->user);
- $this->itemMapper->find($this->whereTitleId('del3'), $this->user);
- $this->itemMapper->find($this->whereTitleId('del4'), $this->user);
+ $this->itemMapper->find($this->user, $this->whereTitleId('a title1'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('a title2'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('a title3'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('del3'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('del4'));
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testDeleteOlderThanThresholdOne()
{
@@ -94,11 +94,11 @@ class ItemMapperTest extends IntegrationTest
$this->deleteReadOlderThanThreshold();
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testDeleteOlderThanThresholdTwo()
{
@@ -108,7 +108,7 @@ class ItemMapperTest extends IntegrationTest
$this->deleteReadOlderThanThreshold();
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
@@ -127,24 +127,24 @@ class ItemMapperTest extends IntegrationTest
$this->itemMapper->readAll(PHP_INT_MAX, 10, $this->user);
- $items = $this->itemMapper->findAll(
+ $items = $this->itemMapper->findAllItems(
30, 0, 0, false, false, $this->user
);
$this->assertEquals(0, count($items));
$itemId = $this->whereTitleId('a title1');
- $item = $this->itemMapper->find($itemId, $this->user);
+ $item = $this->itemMapper->find($this->user, $itemId);
$this->assertEquals(10, $item->getLastModified());
$itemId = $this->whereTitleId('a title3');
- $item = $this->itemMapper->find($itemId, $this->user);
+ $item = $this->itemMapper->find($this->user, $itemId);
$this->assertEquals(10, $item->getLastModified());
$itemId = $this->whereTitleId('a title9');
- $item = $this->itemMapper->find($itemId, $this->user);
+ $item = $this->itemMapper->find($this->user, $itemId);
$this->assertEquals(10, $item->getLastModified());
}
@@ -159,24 +159,24 @@ class ItemMapperTest extends IntegrationTest
$folderId, PHP_INT_MAX, 10, $this->user
);
- $items = $this->itemMapper->findAll(
+ $items = $this->itemMapper->findAllItems(
30, 0, 0, false, false, $this->user
);
$this->assertEquals(1, count($items));
$item = $this->findItemByTitle('a title1');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals(10, $item->getLastModified());
$item = $this->findItemByTitle('a title3');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals(10, $item->getLastModified());
$item = $this->findItemByTitle('a title9');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertTrue($item->isUnread());
}
@@ -191,24 +191,24 @@ class ItemMapperTest extends IntegrationTest
$feedId, PHP_INT_MAX, 10, $this->user
);
- $items = $this->itemMapper->findAll(
+ $items = $this->itemMapper->findAllItems(
30, 0, 0, false, false, $this->user
);
$this->assertEquals(2, count($items));
$item = $this->findItemByTitle('a title9');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals(10, $item->getLastModified());
$item = $this->findItemByTitle('a title3');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertTrue($item->isUnread());
$item = $this->findItemByTitle('a title1');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertTrue($item->isUnread());
}
diff --git a/tests/Integration/IntegrationTest.php b/tests/Integration/IntegrationTest.php
index 13969e7c3..276c6c394 100644
--- a/tests/Integration/IntegrationTest.php
+++ b/tests/Integration/IntegrationTest.php
@@ -39,22 +39,22 @@ abstract class IntegrationTest extends \Test\TestCase
protected $userPassword = 'test';
/**
- * @var ItemMapper
+ * @var ItemMapper
*/
protected $itemMapper;
/**
- * @var FeedMapper
+ * @var FeedMapper
*/
protected $feedMapper;
/**
- * @var FolderMapper
+ * @var FolderMapper
*/
protected $folderMapper;
/**
- * @var IAppContainer
+ * @var IAppContainer
*/
protected $container;
@@ -72,7 +72,7 @@ abstract class IntegrationTest extends \Test\TestCase
$this->folderMapper = $this->container->query(FolderMapper::class);
}
- protected function findItemByTitle($title)
+ protected function findItemByTitle($title)
{
// db logic in app code, negligible since its a test
$items = $this->itemMapper->where(['title' => $title]);
@@ -97,7 +97,7 @@ abstract class IntegrationTest extends \Test\TestCase
return $result;
}
- protected function findFolderByName($name)
+ protected function findFolderByName($name)
{
return $this->folderMapper->where(
[
@@ -107,7 +107,7 @@ abstract class IntegrationTest extends \Test\TestCase
)[0];
}
- protected function findFeedByTitle($title)
+ protected function findFeedByTitle($title)
{
return $this->feedMapper->where(
[
@@ -120,7 +120,7 @@ abstract class IntegrationTest extends \Test\TestCase
/**
* @param string $name loads fixtures from a given file
*/
- protected function loadFixtures($name)
+ protected function loadFixtures($name)
{
$fixtures = include __DIR__ . '/Fixtures/data/' . $name . '.php';
if (array_key_exists('folders', $fixtures)) {
@@ -131,7 +131,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadFolderFixtures(array $folderFixtures=[])
+ protected function loadFolderFixtures(array $folderFixtures = [])
{
foreach ($folderFixtures as $folderFixture) {
$folder = new FolderFixture($folderFixture);
@@ -140,7 +140,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadFeedFixtures(array $feedFixtures=[], $folderId=0)
+ protected function loadFeedFixtures(array $feedFixtures = [], $folderId = 0)
{
foreach ($feedFixtures as $feedFixture) {
$feed = new FeedFixture($feedFixture);
@@ -153,7 +153,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadItemFixtures(array $itemFixtures=[], $feedId)
+ protected function loadItemFixtures(array $itemFixtures, $feedId)
{
foreach ($itemFixtures as $itemFixture) {
$item = new ItemFixture($itemFixture);
@@ -168,7 +168,7 @@ abstract class IntegrationTest extends \Test\TestCase
* @param Entity $fixture
* @return int the id
*/
- protected function loadFixture(Entity $fixture)
+ protected function loadFixture(Entity $fixture)
{
if ($fixture instanceof FeedFixture) {
return $this->feedMapper->insert($fixture)->getId();
@@ -187,7 +187,7 @@ abstract class IntegrationTest extends \Test\TestCase
* @param $user
* @param $password
*/
- protected function setupUser($user, $password)
+ protected function setupUser($user, $password)
{
$userManager = $this->container->query(IUserManager::class);
$userManager->createUser($user, $password);
@@ -200,7 +200,7 @@ abstract class IntegrationTest extends \Test\TestCase
*
* @param $user
*/
- protected function tearDownUser($user)
+ protected function tearDownUser($user)
{
$userManager = $this->container->query(IUserManager::class);
@@ -216,7 +216,7 @@ abstract class IntegrationTest extends \Test\TestCase
*
* @param string $user
*/
- protected function clearUserNewsDatabase($user)
+ protected function clearUserNewsDatabase($user)
{
$sql = [
'DELETE FROM `*PREFIX*news_items` WHERE `feed_id` IN