1
0

AdminTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 OCP\Security\ICrypto;
  31. use PHPUnit\Framework\MockObject\MockObject;
  32. use Psr\Log\LoggerInterface;
  33. use Test\TestCase;
  34. class AdminTest extends TestCase {
  35. /** @var Admin|MockObject */
  36. private $admin;
  37. /** @var IInitialStateService|MockObject */
  38. private $initialState;
  39. /** @var ClientMapper|MockObject */
  40. private $clientMapper;
  41. protected function setUp(): void {
  42. parent::setUp();
  43. $this->initialState = $this->createMock(IInitialState::class);
  44. $this->clientMapper = $this->createMock(ClientMapper::class);
  45. $this->admin = new Admin(
  46. $this->initialState,
  47. $this->clientMapper,
  48. $this->createMock(IURLGenerator::class),
  49. $this->createMock(ICrypto::class),
  50. $this->createMock(LoggerInterface::class)
  51. );
  52. }
  53. public function testGetForm() {
  54. $expected = new TemplateResponse(
  55. 'oauth2',
  56. 'admin',
  57. [],
  58. ''
  59. );
  60. $this->assertEquals($expected, $this->admin->getForm());
  61. }
  62. public function testGetSection() {
  63. $this->assertSame('security', $this->admin->getSection());
  64. }
  65. public function testGetPriority() {
  66. $this->assertSame(100, $this->admin->getPriority());
  67. }
  68. }