diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-06-24 15:24:16 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-06-24 15:39:52 +0200 |
commit | a9cfa72d1cf5eccb352b34eb823559ac52f8e22c (patch) | |
tree | 29335b912f39ca2f780a2c904d4b0cb97c533920 /apps/federation/tests/Controller/SettingsControllerTest.php | |
parent | b282fe1e6f5587a6440d170df245ad5acb8dc976 (diff) | |
download | nextcloud-server-a9cfa72d1cf5eccb352b34eb823559ac52f8e22c.tar.gz nextcloud-server-a9cfa72d1cf5eccb352b34eb823559ac52f8e22c.zip |
Summer cleanup of the federation app
- Use IEventDispatcher instead of deprecated symfony dispatcher
- Use LoggerInterface where possible
- Use php 7.4 properties
- Add type hinting where possible
- Move federation hooks to a seperate listener
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/federation/tests/Controller/SettingsControllerTest.php')
-rw-r--r-- | apps/federation/tests/Controller/SettingsControllerTest.php | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php index 856dcaa533f..c33ee6feb87 100644 --- a/apps/federation/tests/Controller/SettingsControllerTest.php +++ b/apps/federation/tests/Controller/SettingsControllerTest.php @@ -5,6 +5,7 @@ * @author Björn Schießle <bjoern@schiessle.org> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Carl Schwan <carl@carlschwan.eu> * * @license AGPL-3.0 * @@ -31,9 +32,7 @@ use OCP\IRequest; use Test\TestCase; class SettingsControllerTest extends TestCase { - - /** @var SettingsController */ - private $controller; + private SettingsController $controller; /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IRequest */ private $request; @@ -60,7 +59,7 @@ class SettingsControllerTest extends TestCase { ); } - public function testAddServer() { + public function testAddServer(): void { $this->trustedServers ->expects($this->once()) ->method('isTrustedServer') @@ -68,7 +67,7 @@ class SettingsControllerTest extends TestCase { ->willReturn(false); $this->trustedServers ->expects($this->once()) - ->method('isOwnCloudServer') + ->method('isNextcloudServer') ->with('url') ->willReturn(true); @@ -83,11 +82,8 @@ class SettingsControllerTest extends TestCase { /** * @dataProvider checkServerFails - * - * @param bool $isTrustedServer - * @param bool $isOwnCloud */ - public function testAddServerFail($isTrustedServer, $isOwnCloud) { + public function testAddServerFail(bool $isTrustedServer, bool $isNextcloud): void { $this->expectException(\OCP\HintException::class); $this->trustedServers @@ -97,14 +93,14 @@ class SettingsControllerTest extends TestCase { ->willReturn($isTrustedServer); $this->trustedServers ->expects($this->any()) - ->method('isOwnCloudServer') + ->method('isNextcloudServer') ->with('url') - ->willReturn($isOwnCloud); + ->willReturn($isNextcloud); $this->controller->addServer('url'); } - public function testRemoveServer() { + public function testRemoveServer(): void { $this->trustedServers->expects($this->once())->method('removeServer') ->with('url'); $result = $this->controller->removeServer('url'); @@ -112,7 +108,7 @@ class SettingsControllerTest extends TestCase { $this->assertSame(200, $result->getStatus()); } - public function testCheckServer() { + public function testCheckServer(): void { $this->trustedServers ->expects($this->once()) ->method('isTrustedServer') @@ -120,7 +116,7 @@ class SettingsControllerTest extends TestCase { ->willReturn(false); $this->trustedServers ->expects($this->once()) - ->method('isOwnCloudServer') + ->method('isNextcloudServer') ->with('url') ->willReturn(true); @@ -131,11 +127,8 @@ class SettingsControllerTest extends TestCase { /** * @dataProvider checkServerFails - * - * @param bool $isTrustedServer - * @param bool $isOwnCloud */ - public function testCheckServerFail($isTrustedServer, $isOwnCloud) { + public function testCheckServerFail(bool $isTrustedServer, bool $isNextcloud): void { $this->expectException(\OCP\HintException::class); $this->trustedServers @@ -145,9 +138,9 @@ class SettingsControllerTest extends TestCase { ->willReturn($isTrustedServer); $this->trustedServers ->expects($this->any()) - ->method('isOwnCloudServer') + ->method('isNextcloudServer') ->with('url') - ->willReturn($isOwnCloud); + ->willReturn($isNextcloud); $this->assertTrue( $this->invokePrivate($this->controller, 'checkServer', ['url']) @@ -155,11 +148,9 @@ class SettingsControllerTest extends TestCase { } /** - * data to simulate checkServer fails - * - * @return array + * Data to simulate checkServer fails */ - public function checkServerFails() { + public function checkServerFails(): array { return [ [true, true], [false, false] |