<commit_before><?php

namespace Recca0120\LaravelTracy\Tests\Panels;

use Mockery as m;
use PHPUnit\Framework\TestCase;
use Recca0120\LaravelTracy\Panels\AuthPanel;

class AuthPanelTest extends TestCase
{
    protected function tearDown()
    {
        parent::tearDown();
        m::close();
    }

    public function testRenderFromGuard()
    {
        $panel = new AuthPanel(
            $template = m::mock('Recca0120\LaravelTracy\Template')
        );
        $panel->setLaravel(
            $laravel = m::mock('Illuminate\Contracts\Foundation\Application, ArrayAccess')
        );

        $laravel->shouldReceive('offsetExists')->once()->with('sentinel')->andReturn(false);

        $laravel->shouldReceive('offsetGet')->once()->with('session')->andReturn(
            $sessionManager = m::mock('Illuminate\Session\SessionManager')
        );
        $laravel->shouldReceive('offsetGet')->once()->with('auth')->andReturn(
            $auth = m::mock('Illuminate\Contracts\Auth\Guard')
        );
        $auth->shouldReceive('getName')->once()->andReturn($name = 'foo');
        $sessionManager->shouldReceive('has')->once()->with($name)->andReturn(true);
        $auth->shouldReceive('user')->once()->andReturn(
            $user = m::mock('stdClass')
        );
        $user->shouldReceive('toArray')->once()->andReturn($rows = ['username' => 'foo']);
        $user->shouldReceive('getAuthIdentifier')->once()->andReturn($id = 1);

        $template->shouldReceive('setAttributes')->once()->with([
            'id' => 'foo',
            'rows' => [
                'username' => 'foo',
            ],
        ]);
        $template->shouldReceive('render')->twice()->with(m::type('string'))->andReturn($content = 'foo');

        $this->assertSame($content, $panel->getTab());
        $this->assertSame($content, $panel->getPanel());
    }

    public function testRenderFromSentinel()
    {
        $panel = new AuthPanel(<commit_msg>get user directly from auth->user()<commit_after><?php

namespace Recca0120\LaravelTracy\Tests\Panels;

use Mockery as m;
use PHPUnit\Framework\TestCase;
use Recca0120\LaravelTracy\Panels\AuthPanel;

class AuthPanelTest extends TestCase
{
    protected function tearDown()
    {
        parent::tearDown();
        m::close();
    }

    public function testRenderFromGuard()
    {
        $panel = new AuthPanel(
            $template = m::mock('Recca0120\LaravelTracy\Template')
        );
        $panel->setLaravel(
            $laravel = m::mock('Illuminate\Contracts\Foundation\Application, ArrayAccess')
        );

        $laravel->shouldReceive('offsetExists')->once()->with('sentinel')->andReturn(false);

        $laravel->shouldReceive('offsetGet')->once()->with('auth')->andReturn(
            $auth = m::mock('Illuminate\Contracts\Auth\Guard')
        );

        $auth->shouldReceive('user')->once()->andReturn(
            $user = m::mock('stdClass')
        );
        $user->shouldReceive('toArray')->once()->andReturn($rows = ['username' => 'foo']);
        $user->shouldReceive('getAuthIdentifier')->once()->andReturn($id = 1);

        $template->shouldReceive('setAttributes')->once()->with([
            'id' => 'foo',
            'rows' => [
                'username' => 'foo',
            ],
        ]);
        $template->shouldReceive('render')->twice()->with(m::type('string'))->andReturn($content = 'foo');

        $this->assertSame($content, $panel->getTab());
        $this->assertSame($content, $panel->getPanel());
    }

    public function testRenderFromSentinel()
    {
        $panel = new AuthPanel(
{'fraction_non_alphanumeric': 0.18493723849372384, 'fraction_numerical': 0.007252440725244073, 'mean_word_length': 2.885157096424702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 81, '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': '643490', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1009, 'n_words': 133}