<commit_before><?php
namespace Respect\Rest\Routines{

use Respect\Rest\Request;
/**
 * @covers Respect\Rest\Routines\UserAgent
 * @author <NAME> <<EMAIL>>
 */
class UserAgentTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var UserAgent
     */
    protected $object;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
            $_SERVER['REQUEST_URI'] = '/';
            $_SERVER['REQUEST_METHOD'] = 'GET';
        $this->object = new UserAgent(array(
            'FIREFOX' => function (){ return 'ff';},
            'InhernetExplorer' => function (){ return 'ie';},
            'a' => function (){ return 'a';},
            'o' => function (){ return 'o';},
            'e' => function (){ return 'e';},
            'u' => function (){ return 'u';},
        ));

    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        unset($this->object);
    }


    /**
     * @covers Respect\Rest\Routines\UserAgent::through
     */
    public function testThrough()
    {global $headers;
        $request = @new Request();
        $params = array();
        $alias = &$this->object;
        $_SERVER['HTTP_USER_AGENT'] = 'FIREFOX';
        $this->assertTrue($alias->when($request, $params));
        $this->assertInstanceOf('Closure', $alias->through($request, $params));
        $this->setUp();
        $_SERVER['HTTP_USER_AGENT'] = 'InhernetExplorer';
        $this->assertTrue($alias->when($request, $params));
        $this->assertInstanceOf('Closure', $alias->through($request, $params));
        $this->setUp();
        $_SERVER['HTTP_USER_AGENT'] = 'CHROME';
        $this->assertFalse($alias->when($request, $params));
        $this->assertNull($alias->through($request, $params));
    }
}
    if (!function_exists(__NAMESPACE__.'\\header')) {
        function header($string, $replace=true, $http_response_code=200)
        {echo "hedaec1 $string\n";
            global $header;
            if (!$replace && isset($header))
                return;

            $header[$string] = $string;
        }
    }
}

namespace Respect\Rest {
    if (!function_exists(__NAMESPACE__.'\\header')) {
        function header($string, $replace=true, $http_response_code=200)
        {echo "hedaec2 $string\n";
            global $header;
            if (!$replace && isset($header))
                return;

            $header[$string] = $string;
        }
    }
}

namespace {
    $header=array('a');
}
<commit_msg>Just to prove the point see:<commit_after><?php
namespace Respect\Rest\Routines;

use Respect\Rest\Request;
/**
 * @covers Respect\Rest\Routines\UserAgent
 * @author <NAME> <<EMAIL>>
 */
class UserAgentTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var UserAgent
     */
    protected $object;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
            $_SERVER['REQUEST_URI'] = '/';
            $_SERVER['REQUEST_METHOD'] = 'GET';
        $this->object = new UserAgent(array(
            'FIREFOX' => function (){ return 'ff';},
            'InhernetExplorer' => function (){ return 'ie';},
            'a' => function (){ return 'a';},
            'o' => function (){ return 'o';},
            'e' => function (){ return 'e';},
            'u' => function (){ return 'u';},
        ));

    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        unset($this->object);
    }


    /**
     * @covers Respect\Rest\Routines\UserAgent::through
     */
    public function testThrough()
    {global $headers;
        $request = @new Request();
        $params = array();
        $alias = &$this->object;
        $_SERVER['HTTP_USER_AGENT'] = 'FIREFOX';
        $this->assertTrue($alias->when($request, $params));
        $this->assertInstanceOf('Closure', $alias->through($request, $params));

        $_SERVER['HTTP_USER_AGENT'] = 'InhernetExplorer';
        $this->assertTrue($alias->when($request, $params));
        $this->assertInstanceOf('Closure', $alias->through($request, $params));

        $_SERVER['HTTP_USER_AGENT'] = 'CHROME';
        $this->assertFalse($alias->when($request, $params));
        $this->assertNull($alias->through($request, $params));
    }
}

{'fraction_non_alphanumeric': 0.16810344827586207, 'fraction_numerical': 0.0017241379310344827, 'mean_word_length': 2.4125, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, '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': '6642697', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1373, 'n_words': 299}