AdminTest.php 2.1 KB

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