AdminTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\OAuth2\Tests\Settings;
  25. use OCA\OAuth2\Db\ClientMapper;
  26. use OCA\OAuth2\Settings\Admin;
  27. use OCP\AppFramework\Http\TemplateResponse;
  28. use OCP\AppFramework\Services\IInitialState;
  29. use OCP\IURLGenerator;
  30. use PHPUnit\Framework\MockObject\MockObject;
  31. use Test\TestCase;
  32. class AdminTest extends TestCase {
  33. /** @var Admin|MockObject */
  34. private $admin;
  35. /** @var IInitialStateService|MockObject */
  36. private $initialState;
  37. /** @var ClientMapper|MockObject */
  38. private $clientMapper;
  39. protected function setUp(): void {
  40. parent::setUp();
  41. $this->initialState = $this->createMock(IInitialState::class);
  42. $this->clientMapper = $this->createMock(ClientMapper::class);
  43. $this->admin = new Admin($this->initialState, $this->clientMapper, $this->createMock(IURLGenerator::class));
  44. }
  45. public function testGetForm() {
  46. $expected = new TemplateResponse(
  47. 'oauth2',
  48. 'admin',
  49. [],
  50. ''
  51. );
  52. $this->assertEquals($expected, $this->admin->getForm());
  53. }
  54. public function testGetSection() {
  55. $this->assertSame('security', $this->admin->getSection());
  56. }
  57. public function testGetPriority() {
  58. $this->assertSame(100, $this->admin->getPriority());
  59. }
  60. }