<commit_before><?php
declare(strict_types=1);

namespace BugReportTest\Command;

use BugReport\Command\BugReport;
use Github\Api\ApiInterface;
use Github\Client;
use Github\ResultPagerInterface;
use Mockery;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class BugReportTest extends TestCase
{
    use MockeryPHPUnitIntegration;

    /**
     * @var InputInterface
     */
    private $input;

    /**
     * @var OutputInterface
     */
    private $output;

    /**
     * @var Client
     */
    private $client;

    /**
     * @var ResultPagerInterface
     */
    private $pager;

    /**
     * @var ApiInterface
     */
    private $issueApi;

    public function setup()
    {
        $this->input = Mockery::mock(InputInterface::class);
        $this->output = Mockery::mock(OutputInterface::class);

        $this->client = Mockery::mock(Client::class);
        $this->pager = Mockery::mock(ResultPagerInterface::class);
        $this->issueApi = Mockery::mock(ApiInterface::class);

        $this->client->shouldReceive()
            ->issue()
            ->andReturn($this->issueApi);
    }

    /**
     * @test
     */
    public function it_executes_for_a_provided_dependency()
    {
        $this->input->shouldReceive()
            ->getArgument('dependency')
            ->once()
            ->andReturn('mockery/mockery');

        $this->output->shouldReceive()
            ->writeln(Mockery::any());

        $params = [
            'mockery',
            'mockery',
            ['state' => 'open'],
        ];

        $issues = include __DIR__ . '/../fixtures/issues_mockery_all.php';

        $this->pager->shouldReceive()
            ->fetchAll($this->issueApi, 'all', $params)
            ->once()
            ->andReturn($issues);

        $command = new BugReportTestCommand('bugreport', null, $this->client, $this->pager);
        $command->execute($this->input, $this->output);
    }

    /**
     * @test
     */
    public function it_executes_for_an_existing_composer_lock_file()
    {
        $this->input->shouldReceive()
            ->getArgument('dependency')
            ->once()
            ->andReturnNull();

        $this->output->shouldReceive()
            ->writeln(Mockery::any());

        $command = new BugReportTestCommand('bugreport', getcwd() . '/tests/fixtures/composer.lock', $this->client, $this->pager);

        $command->execute($this->input, $this->output);<commit_msg>Expecting 50 calls for the pager<commit_after><?php
declare(strict_types=1);

namespace BugReportTest\Command;

use BugReport\Command\BugReport;
use Github\Api\ApiInterface;
use Github\Client;
use Github\ResultPagerInterface;
use Mockery;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class BugReportTest extends TestCase
{
    use MockeryPHPUnitIntegration;

    /**
     * @var InputInterface
     */
    private $input;

    /**
     * @var OutputInterface
     */
    private $output;

    /**
     * @var Client
     */
    private $client;

    /**
     * @var ResultPagerInterface
     */
    private $pager;

    /**
     * @var ApiInterface
     */
    private $issueApi;

    public function setup()
    {
        $this->input = Mockery::mock(InputInterface::class);
        $this->output = Mockery::mock(OutputInterface::class);

        $this->client = Mockery::mock(Client::class);
        $this->pager = Mockery::mock(ResultPagerInterface::class);
        $this->issueApi = Mockery::mock(ApiInterface::class);

        $this->client->shouldReceive()
            ->issue()
            ->andReturn($this->issueApi);
    }

    /**
     * @test
     */
    public function it_executes_for_a_provided_dependency()
    {
        $this->input->shouldReceive()
            ->getArgument('dependency')
            ->once()
            ->andReturn('mockery/mockery');

        $this->output->shouldReceive()
            ->writeln(Mockery::any());

        $params = [
            'mockery',
            'mockery',
            ['state' => 'open'],
        ];

        $issues = include __DIR__ . '/../fixtures/issues_mockery_all.php';

        $this->pager->shouldReceive()
            ->fetchAll($this->issueApi, 'all', $params)
            ->once()
            ->andReturn($issues);

        $command = new BugReportTestCommand('bugreport', null, $this->client, $this->pager);
        $command->execute($this->input, $this->output);
    }

    /**
     * @test
     */
    public function it_executes_for_an_existing_composer_lock_file()
    {
        $this->input->shouldReceive()
            ->getArgument('dependency')
            ->once()
            ->andReturnNull();

        $this->output->shouldReceive()
            ->writeln(Mockery::any());

        $this->pager->shouldReceive()
            ->fetchAll($this->issueApi, 'all', Mockery::type('array'))
            ->times(50)
            ->andReturn([]);

        $command = new BugReportTestCommand('bugreport', getcwd() . '/tests/fixtures/composer.lock', $this->client, $this->pager);

        $command->execute($this->input, $this->output);
{'fraction_non_alphanumeric': 0.15354330708661418, 'fraction_numerical': 0.0011248593925759281, 'mean_word_length': 2.3873015873015873, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7198182', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1541, 'n_words': 242}