Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
check same URL in unit tests
  • Loading branch information
ChristophWurst committed Aug 30, 2016
commit 8e5c4c91faba6747682339ed7af95a1227d2f1b4
23 changes: 12 additions & 11 deletions tests/Core/Controller/TwoFactorChallengeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class TwoFactorChallengeControllerTest extends TestCase {
protected function setUp() {
parent::setUp();

$this->request = $this->getMock('\OCP\IRequest');
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
$this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
->disableOriginalConstructor()
->getMock();
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->session = $this->getMock('\OCP\ISession');
$this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock();
$this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();

$this->controller = $this->getMockBuilder('OC\Core\Controller\TwoFactorChallengeController')
->setConstructorArgs([
Expand All @@ -64,7 +64,7 @@ protected function setUp() {
}

public function testSelectChallenge() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$providers = [
'prov1',
'prov2',
Expand All @@ -88,7 +88,7 @@ public function testSelectChallenge() {
}

public function testShowChallenge() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testShowChallenge() {
}

public function testShowInvalidChallenge() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();

$this->userSession->expects($this->once())
->method('getUser')
Expand All @@ -150,7 +150,7 @@ public function testShowInvalidChallenge() {
}

public function testSolveChallenge() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
->disableOriginalConstructor()
->getMock();
Expand All @@ -168,11 +168,12 @@ public function testSolveChallenge() {
->with('myprovider', $user, 'token')
->will($this->returnValue(true));

$this->assertInstanceOf('\OCP\AppFramework\Http\RedirectResponse', $this->controller->solveChallenge('myprovider', 'token'));
$expected = new \OCP\AppFramework\Http\RedirectResponse(\OC_Util::getDefaultPageUrl());
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token'));
}

public function testSolveChallengeInvalidProvider() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();

$this->userSession->expects($this->once())
->method('getUser')
Expand All @@ -192,7 +193,7 @@ public function testSolveChallengeInvalidProvider() {
}

public function testSolveInvalidChallenge() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
->disableOriginalConstructor()
->getMock();
Expand Down