summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-10-04 20:45:33 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-11-03 19:58:37 +0100
commit10e8c28feaf6d858948285a291231f651ef74728 (patch)
tree5c48216dc1ce6a6dd8f292d489bb4a7d03cb5595 /tests
parent361cfa55b7302b29e158647060085550b9a3dfe1 (diff)
Add migration with foreign keys
Closes #829 Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/Fixtures/FeedFixture.php2
-rw-r--r--tests/Integration/Fixtures/FolderFixture.php4
-rw-r--r--tests/Integration/IntegrationTest.php2
-rw-r--r--tests/Unit/Command/FeedAddTest.php4
-rw-r--r--tests/Unit/Command/FolderDeleteTest.php2
-rw-r--r--tests/Unit/Controller/UserApiControllerTest.php155
-rw-r--r--tests/Unit/Service/FeedServiceTest.php2
-rw-r--r--tests/Unit/Utility/OPMLExporterTest.php4
8 files changed, 10 insertions, 165 deletions
diff --git a/tests/Integration/Fixtures/FeedFixture.php b/tests/Integration/Fixtures/FeedFixture.php
index f0de6de2d..77abd3ee0 100644
--- a/tests/Integration/Fixtures/FeedFixture.php
+++ b/tests/Integration/Fixtures/FeedFixture.php
@@ -30,7 +30,7 @@ class FeedFixture extends Feed
'title' => 'title',
'faviconLink' => 'http://feed.com/favicon.ico',
'added' => 3000,
- 'folderId' => 0,
+ 'folderId' => null,
'link' => 'http://feed.com/rss',
'preventUpdate' => false,
'deletedAt' => 0,
diff --git a/tests/Integration/Fixtures/FolderFixture.php b/tests/Integration/Fixtures/FolderFixture.php
index 19f19041b..09c03e5de 100644
--- a/tests/Integration/Fixtures/FolderFixture.php
+++ b/tests/Integration/Fixtures/FolderFixture.php
@@ -19,11 +19,11 @@ class FolderFixture extends Folder
{
use Fixture;
- public function __construct(array $defaults=[])
+ public function __construct(array $defaults=[])
{
$defaults = array_merge(
[
- 'parentId' => 0,
+ 'parentId' => null,
'name' => 'folder',
'userId' => 'test',
'opened' => true,
diff --git a/tests/Integration/IntegrationTest.php b/tests/Integration/IntegrationTest.php
index 1135bbd2e..f943e2940 100644
--- a/tests/Integration/IntegrationTest.php
+++ b/tests/Integration/IntegrationTest.php
@@ -141,7 +141,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadFeedFixtures(array $feedFixtures = [], $folderId = 0)
+ protected function loadFeedFixtures(array $feedFixtures = [], $folderId = null)
{
foreach ($feedFixtures as $feedFixture) {
$feed = new FeedFixture($feedFixture);
diff --git a/tests/Unit/Command/FeedAddTest.php b/tests/Unit/Command/FeedAddTest.php
index c0d4de1bd..0f2d3606f 100644
--- a/tests/Unit/Command/FeedAddTest.php
+++ b/tests/Unit/Command/FeedAddTest.php
@@ -69,7 +69,7 @@ class FeedAddTest extends TestCase
$this->consoleInput->expects($this->exactly(5))
->method('getOption')
->will($this->returnValueMap([
- ['folder', '0'],
+ ['folder', null],
['title', 'title'],
['username', 'user'],
['password', 'pass'],
@@ -80,7 +80,7 @@ class FeedAddTest extends TestCase
$this->service->expects($this->exactly(1))
->method('create')
- ->with('admin', 'http://feed', 0, true, 'title', 'user', 'pass')
+ ->with('admin', 'http://feed', null, true, 'title', 'user', 'pass')
->willReturn($feed);
$this->service->expects($this->exactly(1))
diff --git a/tests/Unit/Command/FolderDeleteTest.php b/tests/Unit/Command/FolderDeleteTest.php
index 9db078b33..c87b05acd 100644
--- a/tests/Unit/Command/FolderDeleteTest.php
+++ b/tests/Unit/Command/FolderDeleteTest.php
@@ -88,7 +88,7 @@ class FolderDeleteTest extends TestCase
$this->consoleInput->expects($this->exactly(2))
->method('getArgument')
->will($this->returnValueMap([
- ['folder-id', '0'],
+ ['folder-id', null],
['user-id', 'admin'],
]));
diff --git a/tests/Unit/Controller/UserApiControllerTest.php b/tests/Unit/Controller/UserApiControllerTest.php
deleted file mode 100644
index dd0140c81..000000000
--- a/tests/Unit/Controller/UserApiControllerTest.php
+++ /dev/null
@@ -1,155 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2012 Alessandro Cosentino
- * @copyright 2012-2014 Bernhard Posselt
- */
-
-namespace OCA\News\Tests\Unit\Controller;
-
-use OCA\News\Controller\UserApiController;
-use OCP\Files\File;
-use OCP\Files\IRootFolder;
-use OCP\IRequest;
-use OCP\IUser;
-use OCP\IUserSession;
-
-use PHPUnit\Framework\TestCase;
-
-class UserApiControllerTest extends TestCase
-{
-
- private $request;
- private $appName;
- private $rootFolder;
- private $userSession;
- private $controller;
- private $user;
- private $file;
-
- protected function setUp(): void
- {
- $this->appName = 'news';
- $this->request = $this->getMockBuilder(IRequest::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->rootFolder = $this->getMockBuilder(IRootFolder::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->file = $this->getMockBuilder(File::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->userSession = $this->getMockBuilder(IUserSession::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->user = $this->getMockBuilder(IUser::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->controller = new UserApiController(
- $this->appName, $this->request, $this->userSession,
- $this->rootFolder
- );
-
-
- }
-
- private function expectUser($uid, $displayName, $lastLogin)
- {
- $this->userSession->expects($this->any())
- ->method('getUser')
- ->will($this->returnValue($this->user));
- $this->user->expects($this->any())
- ->method('getUID')
- ->will($this->returnValue($uid));
- $this->user->expects($this->any())
- ->method('getLastLogin')
- ->will($this->returnValue($lastLogin));
- $this->user->expects($this->any())
- ->method('getDisplayName')
- ->will($this->returnValue($displayName));
- }
-
- private function expectImg($isJpg, $isPng, $user, $exists, $data)
- {
- $jpg = '/' . $user . '/' . 'avatar.jpg';
- $png = '/' . $user . '/' . 'avatar.png';
-
- $this->rootFolder->expects($this->any())
- ->method('nodeExists')
- ->will(
- $this->returnValueMap(
- [
- [$jpg, $isJpg],
- [$png, $isPng]
- ]
- )
- );
- $this->rootFolder->expects($this->any())
- ->method('get')
- ->will($this->returnValue($this->file));
- $this->file->expects($this->any())
- ->method('getContent')
- ->will($this->returnValue($data));
- }
-
- public function testGetJpeg()
- {
- $this->expectUser('john', 'John', 123);
- $this->expectImg(true, false, 'john', true, 'hi');
-
- $result = $this->controller->index();
- $expected = [
- 'userId' => 'john',
- 'displayName' => 'John',
- 'lastLoginTimestamp' => 123,
- 'avatar' => [
- 'data' => base64_encode('hi'),
- 'mime' => 'image/jpeg'
- ]
- ];
-
- $this->assertEquals($expected, $result);
- }
-
- public function testGetPng()
- {
- $this->expectUser('john', 'John', 123);
- $this->expectImg(false, true, 'john', false, 'hi');
-
- $result = $this->controller->index();
- $expected = [
- 'userId' => 'john',
- 'displayName' => 'John',
- 'lastLoginTimestamp' => 123,
- 'avatar' => [
- 'data' => base64_encode('hi'),
- 'mime' => 'image/png'
- ]
- ];
-
- $this->assertEquals($expected, $result);
- }
-
- public function testNoAvatar()
- {
- $this->expectUser('john', 'John', 123);
- $this->expectImg(false, false, 'john', false, 'hi');
-
- $result = $this->controller->index();
- $expected = [
- 'userId' => 'john',
- 'displayName' => 'John',
- 'lastLoginTimestamp' => 123,
- 'avatar' => null
- ];
-
- $this->assertEquals($expected, $result);
- }
-
-}
diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php
index 3b39019c1..769453459 100644
--- a/tests/Unit/Service/FeedServiceTest.php
+++ b/tests/Unit/Service/FeedServiceTest.php
@@ -913,7 +913,7 @@ class FeedServiceTest extends TestCase
$insertFeed->setTitle('Articles without feed');
$insertFeed->setAdded($this->time);
$insertFeed->setPreventUpdate(true);
- $insertFeed->setFolderId(0);
+ $insertFeed->setFolderId(null);
$this->l10n->expects($this->once())
->method('t')
diff --git a/tests/Unit/Utility/OPMLExporterTest.php b/tests/Unit/Utility/OPMLExporterTest.php
index 8c7c3c923..bc0fd7bee 100644
--- a/tests/Unit/Utility/OPMLExporterTest.php
+++ b/tests/Unit/Utility/OPMLExporterTest.php
@@ -37,7 +37,7 @@ class OPMLExporterTest extends TestCase
$this->exporter = new OPMLExporter();
$this->folder1 = new Folder();
$this->folder1->setId(3);
- $this->folder1->setParentId(0);
+ $this->folder1->setParentId(null);
$this->folder1->setName('Örgendwas');
$this->folder2 = new Folder();
$this->folder2->setId(1);
@@ -46,7 +46,7 @@ class OPMLExporterTest extends TestCase
$this->feed1 = new Feed();
$this->feed1->setUrl('http://url1');
$this->feed1->setTitle('tötel');
- $this->feed1->setFolderId(0);
+ $this->feed1->setFolderId(null);
$this->feed2 = new Feed();
$this->feed2->setUrl('http://url');
$this->feed2->setTitle('ttel df');