Skip to content

Commit

Permalink
Added first unittest for "PersonalSettingsController".
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Nov 15, 2016
1 parent 2a3229d commit b6b263a
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/php/PersonalSettingsControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* @author Joachim Bauch <mail@joachim-bauch.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Spreed\Tests\php;

use OCA\Spreed\Controller\PersonalSettingsController;
use OCA\Spreed\Util;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use Test\TestCase;

/**
* Unittests for PersonalSettingsController.
*
* @group DB
*
*/
class PersonalSettingsControllerTest extends TestCase {

const TEST_PERSONAL_SETTINGS_USER = "test-personal-settings-user";

/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
/** @var string */
private $userId;
/** @var PersonalSettingsController */
private $controller;

protected function setUp() {
parent::setUp();

$this->userId = self::TEST_PERSONAL_SETTINGS_USER;

$this->config = \OC::$server->getConfig();
$this->controller = new PersonalSettingsController(
'spreed',
$this->createMock(IRequest::class),
$this->createMock(IL10N::class),
$this->config,
$this->userId
);
}

protected function tearDown() {
parent::tearDown();
}

public function testSetPersonalSettings() {
$server = "server.domain.invalid:12345";
$username = "foo";
$password = "bar";
$protocols = "udp,tcp";
$response = $this->controller->setSpreedSettings($server, $username, $password, $protocols);
$this->assertEquals('success', $response['status']);

$settings = Util::getTurnSettings($this->config, $this->userId);
$this->assertEquals($server, $settings['server']);
$this->assertEquals($username, $settings['username']);
$this->assertEquals($password, $settings['password']);
$this->assertEquals($protocols, $settings['protocols']);
}

}

0 comments on commit b6b263a

Please sign in to comment.