<commit_before><?php

namespace AppBundle\Tests\Controller;

use Ekreative\RedmineLoginBundle\Client\ClientProvider;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class ApiControllerTest extends WebTestCase
{
    public function testServers()
    {
        $client = static::createClient();

        $redmineClient = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock();
        $redmineClient->expects($this->exactly(2))->method('__call')->willReturnOnConsecutiveCalls(
            new Response(200, [], json_encode(['user' => [
                'id' => 1,
                'login' => 'test',
                'firstname' => 'firstname',
                'lastname' => 'lastname',
                'mail' => '<EMAIL>',
                'api_key' => 'test-api-key',
                'created_on' => date('c'),
                'last_login_on' => date('c')
            ]])),
            new Response(200, [], json_encode(['groups' => []]))
        );
        $client->getContainer()->set('ekreative_redmine_login.redmine', $redmineClient);
        $redmineUserClient = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock();
        $redmineUserClient->expects($this->once())->method('__call')->willReturnOnConsecutiveCalls(
            new Response(200, [], json_encode([
                'projects' => [
                    [
                        'id' => 1,
                        'name' => 'Project 1'
                    ],
                    [
                        'id' => 2,
                        'name' => 'Project 2'
                    ]
                ],
                'total_count' => 2
            ]))
        );
        $clientProvider = $this->getMockBuilder(ClientProvider::class)->disableOriginalConstructor()->getMock();
        $clientProvider->method('get')->willReturn($redmineUserClient);
        $client->getContainer()->set('ekreative_redmine_login.client_provider', $clientProvider);

        $client->getContainer()->get('fixture_loader')->load();

        $client->request('GET', '/api/sites', [], [], ['HTTP_X-API-Key' => 'test-api-key']);

        $response = $client->getResponse();

        $this->assertEquals(200, $response->getStatusCode());
        $this->assertEquals('application/json', $response->headers->get('content-type'));
        $sites = json_decode($response->getContent(), true);
        $this->assertInternalType('array', $sites);
        $this->assertArrayHasKey('sites', $sites);

        $this->assertInternalType('array', $sites['sites']);
        $this->assertCount(5, $sites['sites']);
    }
}
<commit_msg>better name for test<commit_after><?php

namespace AppBundle\Tests\Controller;

use Ekreative\RedmineLoginBundle\Client\ClientProvider;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class ApiControllerTest extends WebTestCase
{
    public function testSites()
    {
        $client = static::createClient();

        $redmineClient = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock();
        $redmineClient->expects($this->exactly(2))->method('__call')->willReturnOnConsecutiveCalls(
            new Response(200, [], json_encode(['user' => [
                'id' => 1,
                'login' => 'test',
                'firstname' => 'firstname',
                'lastname' => 'lastname',
                'mail' => '<EMAIL>',
                'api_key' => 'test-api-key',
                'created_on' => date('c'),
                'last_login_on' => date('c')
            ]])),
            new Response(200, [], json_encode(['groups' => []]))
        );
        $client->getContainer()->set('ekreative_redmine_login.redmine', $redmineClient);
        $redmineUserClient = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock();
        $redmineUserClient->expects($this->once())->method('__call')->willReturnOnConsecutiveCalls(
            new Response(200, [], json_encode([
                'projects' => [
                    [
                        'id' => 1,
                        'name' => 'Project 1'
                    ],
                    [
                        'id' => 2,
                        'name' => 'Project 2'
                    ]
                ],
                'total_count' => 2
            ]))
        );
        $clientProvider = $this->getMockBuilder(ClientProvider::class)->disableOriginalConstructor()->getMock();
        $clientProvider->method('get')->willReturn($redmineUserClient);
        $client->getContainer()->set('ekreative_redmine_login.client_provider', $clientProvider);

        $client->getContainer()->get('fixture_loader')->load();

        $client->request('GET', '/api/sites', [], [], ['HTTP_X-API-Key' => 'test-api-key']);

        $response = $client->getResponse();

        $this->assertEquals(200, $response->getStatusCode());
        $this->assertEquals('application/json', $response->headers->get('content-type'));
        $sites = json_decode($response->getContent(), true);
        $this->assertInternalType('array', $sites);
        $this->assertArrayHasKey('sites', $sites);

        $this->assertInternalType('array', $sites['sites']);
        $this->assertCount(5, $sites['sites']);
    }
}

{'fraction_non_alphanumeric': 0.1724331400785487, 'fraction_numerical': 0.007854871890779876, 'mean_word_length': 2.334164588528678, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 115, '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': '4736285', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1429, 'n_words': 189}