<commit_before><?php

namespace Test\CoreBundle\Security\Provider;

use CoreBundle\Entity\User;
use CoreBundle\Exception\ProgrammerException;
use CoreBundle\Factory\FaceBookClientFactory;
use CoreBundle\Repository\UserRepository;
use CoreBundle\Security\Provider\FacebookProvider;
use CoreBundle\Service\User\RegisterService;
use CoreBundle\Service\User\UserService;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Facebook;
use Facebook\FacebookResponse;
use Facebook\GraphNodes\GraphUser;
use Mockery\Mock;
use PHPUnit\Framework\Assert;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Tests\BaseTestCase;

class FacebookProviderTest extends BaseTestCase
{
    /**
     * @var UserRepository|Mock
     */
    private $userService;

    /**
     * @var RegisterService|Mock
     */
    private $registerService;

    /**
     * @var Facebook|Mock
     */
    protected $facebookClient;

    /**
     * @var FacebookProvider
     */
    protected $facebookProvider;


    protected function setUp()
    {
        parent::setUp();
        $this->userService = \Mockery::mock(UserRepository::class);
        $this->registerService = \Mockery::mock(RegisterService::class);
        $facebookClientFactory = \Mockery::mock(FaceBookClientFactory::class);
        $this->facebookClient = \Mockery::mock(Facebook::class);
        $facebookClientFactory->shouldReceive('getFacebookClient')->once()->andReturn($this->facebookClient);
        $this->userService = \Mockery::mock(UserService::class);

        $this->facebookProvider = new FacebookProvider($facebookClientFactory,  $this->registerService, $this->userService);
    }

    /**
     * Tests that if the user does not exists in our database that we create them via register service
     */
    public function testUserNotFound()
    {
        $this->userService->shouldReceive('findByFacebookUserId')->with('324323423')->once()->andReturnNull();
        $this->userService->shouldReceive('findUserByEmail')->with('<EMAIL>')->once()->andReturnNull();

        $token = '<PASSWORD>';
<commit_msg>Took out unnecessary code.<commit_after><?php

namespace Test\CoreBundle\Security\Provider;

use CoreBundle\Entity\User;
use CoreBundle\Exception\ProgrammerException;
use CoreBundle\Factory\FaceBookClientFactory;
use CoreBundle\Security\Provider\FacebookProvider;
use CoreBundle\Service\User\RegisterService;
use CoreBundle\Service\User\UserService;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Facebook;
use Facebook\FacebookResponse;
use Facebook\GraphNodes\GraphUser;
use Mockery\Mock;
use PHPUnit\Framework\Assert;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Tests\BaseTestCase;

class FacebookProviderTest extends BaseTestCase
{
    /**
     * @var UserService|Mock
     */
    private $userService;

    /**
     * @var RegisterService|Mock
     */
    private $registerService;

    /**
     * @var Facebook|Mock
     */
    protected $facebookClient;

    /**
     * @var FacebookProvider
     */
    protected $facebookProvider;


    protected function setUp()
    {
        parent::setUp();
        $this->registerService = \Mockery::mock(RegisterService::class);
        $facebookClientFactory = \Mockery::mock(FaceBookClientFactory::class);
        $this->facebookClient = \Mockery::mock(Facebook::class);
        $facebookClientFactory->shouldReceive('getFacebookClient')->once()->andReturn($this->facebookClient);
        $this->userService = \Mockery::mock(UserService::class);

        $this->facebookProvider = new FacebookProvider($facebookClientFactory,  $this->registerService, $this->userService);
    }

    /**
     * Tests that if the user does not exists in our database that we create them via register service
     */
    public function testUserNotFound()
    {
        $this->userService->shouldReceive('findByFacebookUserId')->with('324323423')->once()->andReturnNull();
        $this->userService->shouldReceive('findUserByEmail')->with('<EMAIL>')->once()->andReturnNull();

        $token = '<PASSWORD>';

{'fraction_non_alphanumeric': 0.12464046021093, 'fraction_numerical': 0.004314477468839885, 'mean_word_length': 4.2293233082706765, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5105466', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1087, 'n_words': 199}