SettingsControllerTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Semih Serhat Karakaya <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
namespace OCA\Security\Tests\Controller;
22
23
use OCA\Security\Controller\SettingsController;
24
use OCA\Security\SecurityConfig;
25
use OCP\IRequest;
26
use Test\TestCase;
27
28
class SettingsControllerTest extends TestCase {
29
	/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
30
	private $request;
31
	/** @var SecurityConfig|\PHPUnit_Framework_MockObject_MockObject */
32
	private $config;
33
	/** @var SettingsController */
34
	private $controller;
35
	protected function setUp() {
36
		parent::setUp();
37
		$this->request = $this->getMockBuilder(IRequest::class)->getMock();
38
		$this->config = $this->getMockBuilder(SecurityConfig::class)
39
			->disableOriginalConstructor()
40
			->getMock();
41
		$this->controller = new SettingsController('security', $this->request, $this->config);
42
	}
43
	public function testState() {
44
		$expected = [
45
			'bruteForceProtectionState' => true,
46
			'minPassLength' => 8,
47
			'enforceUpperLowerState' => true,
48
			'enforceNumericalCharactersState' => true,
49
			'enforceSpecialCharactersState' => true
50
		];
51
		$this->config->expects($this->exactly(1))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<OCA\Security\SecurityConfig>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
			->method('getAllSecurityConfigs')
53
			->willReturn($expected);
54
55
		$this->assertEquals($expected, $this->controller->state());
56
	}
57
}