summaryrefslogtreecommitdiffstats
path: root/apps/updatenotification/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-01-11 10:59:10 +0100
committerJoas Schilling <coding@schilljs.com>2018-01-15 09:55:03 +0100
commitffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb (patch)
tree79da8d3b535dfa79ffcdd5ccff712298e26ad3e8 /apps/updatenotification/tests
parent0f729e2cd375710890536f5968532879a3a7875d (diff)
downloadnextcloud-server-ffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb.tar.gz
nextcloud-server-ffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb.zip
Improve ResetTokenBackgroundJob and unit test
* Automatic DI is implemented since 11 * Correctly type hint parameters * Optimise the tests Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/updatenotification/tests')
-rw-r--r--apps/updatenotification/tests/ResetTokenBackgroundJobTest.php19
1 files changed, 9 insertions, 10 deletions
diff --git a/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php b/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
index 4309aed84bf..bd6223bab1d 100644
--- a/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
+++ b/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
@@ -29,23 +29,23 @@ use OCP\IConfig;
use Test\TestCase;
class ResetTokenBackgroundJobTest extends TestCase {
- /** @var IConfig */
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
+ /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $timeFactory;
/** @var ResetTokenBackgroundJob */
private $resetTokenBackgroundJob;
- /** @var ITimeFactory */
- private $timeFactory;
public function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\\OCP\\IConfig')->getMock();
- $this->timeFactory = $this->getMockBuilder('\\OCP\\AppFramework\\Utility\\ITimeFactory')->getMock();
+ $this->config = $this->createMock(IConfig::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
$this->resetTokenBackgroundJob = new ResetTokenBackgroundJob($this->config, $this->timeFactory);
}
public function testRunWithNotExpiredToken() {
$this->timeFactory
- ->expects($this->any())
+ ->expects($this->atLeastOnce())
->method('getTime')
->willReturn(123);
$this->config
@@ -54,10 +54,9 @@ class ResetTokenBackgroundJobTest extends TestCase {
->with('core', 'updater.secret.created', 123);
$this->config
->expects($this->never())
- ->method('deleteSystemValue')
- ->with('updater.secret');
+ ->method('deleteSystemValue');
- $this->invokePrivate($this->resetTokenBackgroundJob, 'run', ['']);
+ static::invokePrivate($this->resetTokenBackgroundJob, 'run', [null]);
}
public function testRunWithExpiredToken() {
@@ -78,6 +77,6 @@ class ResetTokenBackgroundJobTest extends TestCase {
->method('deleteSystemValue')
->with('updater.secret');
- $this->invokePrivate($this->resetTokenBackgroundJob, 'run', ['']);
+ static::invokePrivate($this->resetTokenBackgroundJob, 'run', [null]);
}
}