<commit_before><?php

namespace Synapse\TestHelper;

use Synapse\Security\SecurityAwareInterface;
use Synapse\User\UserEntity;
use stdClass;

trait SecurityContextMockInjector
{
    /**
     * @var mixed  UserEntity or null to simulate the user not being logged in
     */
    protected $loggedInUserEntity = false;

    public function injectMockSecurityContext(SecurityAwareInterface $injectee)
    {
        $this->setUpMockSecurityContext();

        $injectee->setSecurityContext($this->mocks['securityContext']);
    }

    /**
     * Set up the mock security context
     *
     * `getToken` returns a mocked security token whose getUser method returns a UserEntity.
     * Customize the user returned by overloading getDefaultLoggedInUserEntity.
     */
    protected function setUpMockSecurityContext()
    {
        if (! isset($this->captured)) {
            $this->captured = new stdClass();
        }

        $this->mocks['securityContext'] = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext')
            ->disableOriginalConstructor()
            ->getMock();

        $mockSecurityToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');<commit_msg>Refs #189 - Remove reference to removed method in comment.<commit_after><?php

namespace Synapse\TestHelper;

use Synapse\Security\SecurityAwareInterface;
use Synapse\User\UserEntity;
use stdClass;

trait SecurityContextMockInjector
{
    /**
     * @var mixed  UserEntity or null to simulate the user not being logged in
     */
    protected $loggedInUserEntity = false;

    public function injectMockSecurityContext(SecurityAwareInterface $injectee)
    {
        $this->setUpMockSecurityContext();

        $injectee->setSecurityContext($this->mocks['securityContext']);
    }

    /**
     * Set up the mock security context
     *
     * `getToken` returns a mocked security token whose getUser method returns a UserEntity.
     */
    protected function setUpMockSecurityContext()
    {
        if (! isset($this->captured)) {
            $this->captured = new stdClass();
        }

        $this->mocks['securityContext'] = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext')
            ->disableOriginalConstructor()
            ->getMock();

        $mockSecurityToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
{'fraction_non_alphanumeric': 0.10467521721141912, 'fraction_numerical': 0.0012412081092263137, 'mean_word_length': 3.302491103202847, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, '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': '3310746', 'n_tokens_mistral': 645, 'n_tokens_neox': 634, 'n_words': 144}