<commit_before><?php
// Alias the PHPUnit 6.0 ancestor if available, else fall back to legacy ancestor
if (class_exists('\PHPUnit\Framework\TestCase', true) and !class_exists('\PHPUnit_Framework_TestCase', true)) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase', true);
}

/**
 * Test for the core:CardinalitySingle filter.
 */
class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Helper function to run the filter with a given configuration.
     *
     * @param  array $config The filter configuration.
     * @param  array $request The request state.
     * @return array  The state array after processing.
     */
    private static function processFilter(array $config, array $request)
    {
        $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
        $_SERVER['REQUEST_METHOD'] = 'GET';
        $filter = new sspmod_core_Auth_Process_CardinalitySingle($config, null);
        $filter->process($request);
        return $request;
    }

    protected function setUp()
    {
        \SimpleSAML_Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml');
    }

    /**
     * Test singleValued
     */
    public function testSingleValuedUnchanged()
    {
        $config = array(
            'singleValued' => array('eduPersonPrincipalName')
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed");
    }

    /**
     * Test first value extraction
     */
    public function testFirstValue()
    {
        $config = array(
            'firstValue' => array('eduPersonPrincipalName')
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>', '<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Only first value should be returned");
    }

    public function testFirstValueUnchanged()
    {
        $config = array(
            'firstValue' => array('eduPersonPrincipalName')
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed");
    }

    /**
     * Test flattening
     */
    public function testFlatten()
    {
        $config = array(
            'flatten' => array('eduPersonPrincipalName'),
            'flattenWith' => '|',
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>', '<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>|<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Flattened string should be returned");
    }

    public function testFlattenUnchanged()
    {
        $config = array(
            'flatten' => array('eduPersonPrincipalName'),
            'flattenWith' => '|',
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed");
    }

    /**
     * Test abort
     * @expectedException PHPUnit_Framework_Error
     * @expectedExceptionMessageRegExp /REQUEST_URI/
     */
    public function testAbort()
    {
        $config = array(
            'singleValued' => array('eduPersonPrincipalName'),
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>', '<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
    }
}<commit_msg>Remove unused variable<commit_after><?php
// Alias the PHPUnit 6.0 ancestor if available, else fall back to legacy ancestor
if (class_exists('\PHPUnit\Framework\TestCase', true) and !class_exists('\PHPUnit_Framework_TestCase', true)) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase', true);
}

/**
 * Test for the core:CardinalitySingle filter.
 */
class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Helper function to run the filter with a given configuration.
     *
     * @param  array $config The filter configuration.
     * @param  array $request The request state.
     * @return array  The state array after processing.
     */
    private static function processFilter(array $config, array $request)
    {
        $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
        $_SERVER['REQUEST_METHOD'] = 'GET';
        $filter = new sspmod_core_Auth_Process_CardinalitySingle($config, null);
        $filter->process($request);
        return $request;
    }

    protected function setUp()
    {
        \SimpleSAML_Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml');
    }

    /**
     * Test singleValued
     */
    public function testSingleValuedUnchanged()
    {
        $config = array(
            'singleValued' => array('eduPersonPrincipalName')
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed");
    }

    /**
     * Test first value extraction
     */
    public function testFirstValue()
    {
        $config = array(
            'firstValue' => array('eduPersonPrincipalName')
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>', '<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Only first value should be returned");
    }

    public function testFirstValueUnchanged()
    {
        $config = array(
            'firstValue' => array('eduPersonPrincipalName')
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed");
    }

    /**
     * Test flattening
     */
    public function testFlatten()
    {
        $config = array(
            'flatten' => array('eduPersonPrincipalName'),
            'flattenWith' => '|',
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>', '<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>|<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Flattened string should be returned");
    }

    public function testFlattenUnchanged()
    {
        $config = array(
            'flatten' => array('eduPersonPrincipalName'),
            'flattenWith' => '|',
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>'),
            ),
        );
        $result = self::processFilter($config, $request);
        $attributes = $result['Attributes'];
        $expectedData = array('eduPersonPrincipalName' => array('<EMAIL>'));
        $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed");
    }

    /**
     * Test abort
     * @expectedException PHPUnit_Framework_Error
     * @expectedExceptionMessageRegExp /REQUEST_URI/
     */
    public function testAbort()
    {
        $config = array(
            'singleValued' => array('eduPersonPrincipalName'),
        );
        $request = array(
            'Attributes' => array(
                'eduPersonPrincipalName' => array('<EMAIL>', '<EMAIL>'),
            ),
        );
        self::processFilter($config, $request);
    }
}
{'fraction_non_alphanumeric': 0.14122816194162569, 'fraction_numerical': 0.0008369076263207448, 'mean_word_length': 2.4600072385088674, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 95, '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': '3434599', 'n_tokens_mistral': 2552, 'n_tokens_neox': 2492, 'n_words': 529}