<commit_before><?php
/**
 * ownCloud - useroidc
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2016
 */

namespace OCA\UserOidc\Controller;

use PHPUnit\Framework\TestCase;

use OCP\AppFramework\Http\TemplateResponse;


class AuthControllerTest extends TestCase {

	private $controller;
	private $userId = 'john';

	public function setUp() {
		$request = $this->getMockBuilder('OCP\IRequest')->getMock();
		$config = $this->getMockBuilder('OCP\IConfig')->getMock();
		$logger = $this->getMockBuilder('OCP\ILogger')->getMock();
		$urlgenerator = $this->getMockBuilder('OCP\IURLGenerator')->getMock();
		$usermanager = $this->getMockBuilder('OCP\IUserManager')->getMock();
    $user = $this->getMockBuilder('OCP\IUser')->getMock();
    $usermanager->method('createUser')->willReturn($user);
		$securerandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->getMock();
		$session = $this->getMockBuilder('OC\Session\Memory')->disableOriginalConstructor()->getMock();
		$usersession = $this->getMockBuilder('OC\User\Session')->disableOriginalConstructor()->getMock();
        $usersession->method('getSession')->willReturn($session);
        $oidc = $this->getMockBuilder('OCA\UserOidc\OpenIDConnectClient')->setConstructorArgs([$config])->getMock();
        //$oidc = $this->getMock('OCA\UserOidc\OpenIDConnectClient');//->setConstructorArgs([$config])->getMock();
        //$oidc->setConstructorArgs([$config]);


        $config->setSystemValue('openid_connect', ['provider' => [
            'displayName' => 'Test Provider',
            'provider' => 'https://example.com',
            'client_id' => '1234',
            'client_secret' => 'abcd',
        ]]);

		$this->controller = new AuthController(
			'useroidc', $request, $config, $logger, $urlgenerator, $usermanager, $securerandom, $usersession, $session, $oidc
		);
	}


	public function testLogin() {
        $result = $this->controller->login("provider");
        $this->assertEquals('/', $result->getRedirectURL());
	}

}<commit_msg>currently failing<commit_after><?php
/**
 * ownCloud - useroidc
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2016
 */

namespace OCA\UserOidc\Controller;

use PHPUnit\Framework\TestCase;

use OCP\AppFramework\Http\TemplateResponse;


class AuthControllerTest extends TestCase {

	private $controller;
	private $userId = 'john';

	public function setUp() {
		$request = $this->getMockBuilder('OCP\IRequest')->getMock();
		$config = $this->getMockBuilder('OCP\IConfig')->getMock();
		$logger = $this->getMockBuilder('OCP\ILogger')->getMock();
		$urlgenerator = $this->getMockBuilder('OCP\IURLGenerator')->getMock();
		$usermanager = $this->getMockBuilder('OCP\IUserManager')->getMock();
    $user = $this->getMockBuilder('OCP\IUser')->getMock();
    $usermanager->method('createUser')->willReturn($user);
		$securerandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->getMock();
		$session = $this->getMockBuilder('OC\Session\Memory')->disableOriginalConstructor()->getMock();
		$usersession = $this->getMockBuilder('OC\User\Session')->disableOriginalConstructor()->getMock();
        $usersession->method('getSession')->willReturn($session);
        //$oidc = $this->getMockBuilder('OCA\UserOidc\OpenIDConnectClient')->setMethods(['createUser'])->setConstructorArgs([$config])->getMock();
        $oidc = $this->getMock('OCA\UserOidc\OpenIDConnectClient');//->setConstructorArgs([$config])->getMock();
        $oidc->setConstructorArgs([$config]);


        $config->setSystemValue('openid_connect', ['github' => [
            'displayName' => 'Test Provider',
            'provider' => 'https://example.com',
            'client_id' => '1234',
            'client_secret' => 'abcd',
        ]]);

		$this->controller = new AuthController(
			'useroidc', $request, $config, $logger, $urlgenerator, $usermanager, $securerandom, $usersession, $session, $oidc
		);
	}


	public function testLogin() {
        $result = $this->controller->login("github");
        $this->assertEquals('/', $result->getRedirectURL());
	}

}
{'fraction_non_alphanumeric': 0.18621013133208256, 'fraction_numerical': 0.004221388367729831, 'mean_word_length': 4.560625814863103, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 96, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4431494', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1298, 'n_words': 203}