<commit_before><?php
/**
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */

/**
 * @namespace
 */
namespace Bluz\Tests\Auth;

use Bluz\Tests\Fixtures\Models\Auth\Table;
use Bluz\Tests\TestCase;
use Bluz\Tests\Fixtures\Models\UserAdmin;

/**
 * AuthTest
 *
 * @package  Bluz\Tests\Auth
 *
 * @author   <NAME>
 * @created  12.08.2014 11:12
 */
class AuthTest extends TestCase
{
    /**
     * Test Auth works with Identity
     *
     * @covers \Bluz\Auth\Auth::setIdentity
     * @covers \Bluz\Auth\Auth::getIdentity
     */
    public function testAuthIdentity()
    {
        $auth = $this->getApp()->getAuth();

        $adminIdentity = new UserAdmin();

        $auth->setIdentity($adminIdentity);

        $this->assertEquals($adminIdentity, $auth->getIdentity());
    }

    /**
     * Test Auth Identity clear
     *
     * @covers \Bluz\Auth\Auth::clearIdentity
     */
    public function testAuthClearIdentity()
    {
        $auth = $this->getApp()->getAuth();

        $adminIdentity = new UserAdmin();

        $auth->setIdentity($adminIdentity);
        $auth->clearIdentity();

        $this->assertNull($auth->getIdentity());
    }

    /**
     * Test get Auth\Row
     */
    public function testGetAuthRow()
    {
        $authRow = Table::getInstance()->getAuthRow(Table::PROVIDER_EQUALS, 'admin');

        $this->assertInstanceOf('\Bluz\Auth\AbstractRow', $authRow);
    }
}<commit_msg>Added test for check user agent<commit_after><?php
/**
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */

/**
 * @namespace
 */
namespace Bluz\Tests\Auth;

use Bluz\Tests\Fixtures\Models\Auth\Table;
use Bluz\Tests\TestCase;
use Bluz\Tests\Fixtures\Models\UserAdmin;

/**
 * AuthTest
 *
 * @package  Bluz\Tests\Auth
 *
 * @author   <NAME>
 * @created  12.08.2014 11:12
 */
class AuthTest extends TestCase
{
    /**
     * Test Auth works with Identity
     *
     * @covers \Bluz\Auth\Auth::setIdentity
     * @covers \Bluz\Auth\Auth::getIdentity
     */
    public function testAuthIdentity()
    {
        $auth = $this->getApp()->getAuth();

        $adminIdentity = new UserAdmin();

        $auth->setIdentity($adminIdentity);

        $this->assertEquals($adminIdentity, $auth->getIdentity());
    }

    /**
     * Test Auth Identity clear
     *
     * @covers \Bluz\Auth\Auth::clearIdentity
     */
    public function testAuthClearIdentity()
    {
        $auth = $this->getApp()->getAuth();

        $adminIdentity = new UserAdmin();

        $auth->setIdentity($adminIdentity);
        $auth->clearIdentity();

        $this->assertNull($auth->getIdentity());
    }

    /**
     * Test Auth Identity clear
     *
     * @covers \Bluz\Auth\Auth::getIdentity
     * @covers \Bluz\Auth\Auth::clearIdentity
     */
    public function testAuthClearIdentityWithWrongUserAgent()
    {
        $auth = $this->getApp()->getAuth();

        $adminIdentity = new UserAdmin();

        $auth->setIdentity($adminIdentity);

        $_SERVER['HTTP_USER_AGENT'] = uniqid('agent:');

        $this->assertNull($auth->getIdentity());
    }

    /**
     * Test get Auth\Row
     */
    public function testGetAuthRow()
    {
        $authRow = Table::getInstance()->getAuthRow(Table::PROVIDER_EQUALS, 'admin');

        $this->assertInstanceOf('\Bluz\Auth\AbstractRow', $authRow);
    }
}
{'fraction_non_alphanumeric': 0.15775321183149088, 'fraction_numerical': 0.00717060053779504, 'mean_word_length': 2.6077586206896552, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 36, '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': '1179611', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1034, 'n_words': 177}