summaryrefslogtreecommitdiffstats
path: root/tests/Unit/Controller/ExportControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Controller/ExportControllerTest.php')
-rw-r--r--tests/Unit/Controller/ExportControllerTest.php24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php
index 563bd987c..276a36abf 100644
--- a/tests/Unit/Controller/ExportControllerTest.php
+++ b/tests/Unit/Controller/ExportControllerTest.php
@@ -25,6 +25,8 @@ use \OCA\News\Db\Feed;
use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\IRequest;
+use OCP\IUser;
+use OCP\IUserSession;
use PHPUnit\Framework\TestCase;
class ExportControllerTest extends TestCase
@@ -33,6 +35,10 @@ class ExportControllerTest extends TestCase
private $controller;
private $user;
/**
+ * @var \PHPUnit\Framework\MockObject\MockObject|IUserSession
+ */
+ private $userSession;
+ /**
* @var \PHPUnit\Framework\MockObject\MockObject|FeedServiceV2
*/
private $feedService;
@@ -55,7 +61,6 @@ class ExportControllerTest extends TestCase
public function setUp(): void
{
$appName = 'news';
- $this->user = 'john';
$this->itemService = $this->getMockBuilder(ItemServiceV2::class)
->disableOriginalConstructor()
->getMock();
@@ -68,6 +73,15 @@ class ExportControllerTest extends TestCase
$this->opmlService = $this->getMockBuilder(OpmlService::class)
->disableOriginalConstructor()
->getMock();
+ $this->user = $this->getMockBuilder(IUser::class)->getMock();
+ $this->user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('user'));
+ $this->userSession = $this->getMockBuilder(IUserSession::class)
+ ->getMock();
+ $this->userSession->expects($this->any())
+ ->method('getUser')
+ ->will($this->returnValue($this->user));
$request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
@@ -78,7 +92,7 @@ class ExportControllerTest extends TestCase
$this->feedService,
$this->itemService,
$this->opmlService,
- $this->user
+ $this->userSession
);
}
@@ -96,7 +110,7 @@ class ExportControllerTest extends TestCase
$this->opmlService->expects($this->once())
->method('export')
- ->with($this->user)
+ ->with('user')
->will($this->returnValue($opml));
$return = $this->controller->opml();
@@ -126,11 +140,11 @@ class ExportControllerTest extends TestCase
$this->feedService->expects($this->once())
->method('findAllForUser')
- ->with($this->user)
+ ->with('user')
->will($this->returnValue($feeds));
$this->itemService->expects($this->once())
->method('findAllForUser')
- ->with($this->user, ['unread' => true, 'starred' => true])
+ ->with('user', ['unread' => true, 'starred' => true])
->will($this->returnValue($articles));