<commit_before><?php

namespace Lyrixx\Twitter\Tests;

use Guzzle\Http\Client;
use Guzzle\Plugin\Mock\MockPlugin;
use Lyrixx\Twitter\Twitter;

/**
 * TwitterTest.
 *
 * All results and fixture values come from
 * https://dev.twitter.com/docs/auth/creating-signature
 *
 * @author <NAME> <<EMAIL>>
 */
class TwitterTest extends \PHPUnit_Framework_TestCase
{
    private $twitter;
    private $mockPlugin;
    private $logger;

    public function setUp()
    {
        $consumerKey = 'xvz1evFS4wEEPTGEFPHBog';
        $accessToken = '<KEY>';
        $consumerSecret = '<KEY>';
        $tokenSecret = '<KEY>';

        $this->mockPlugin = new MockPlugin();
        $client = new Client();
        $client->addSubscriber($this->mockPlugin);

        $this->logger = $this->getMock('Psr\Log\LoggerInterface');

        $this->twitter = new Twitter($consumerKey, $accessToken, $consumerSecret, $tokenSecret, null, null, $client, $this->logger);
    }

    public function testQueryWith200Response()
    {
        $this->mockPlugin->addResponse($this->mockPlugin->getMockFile(__DIR__.'/fixtures/GET_200_user_timeline.json'));

        $this->logger
            ->expects($this->never())
            ->method('error')
        ;

        $response = $this->twitter->query('GET', 'statuses/user_timeline');

        $this->assertInstanceOf('Guzzle\Http\Message\Response', $response);
        $tweets = json_decode($response->getBody(), true);

        $this->assertCount(20, $tweets);
    }

    /**
     * @expectedException Lyrixx\Twitter\Exception\ApiClientException
     * @expectedExceptionMessage The request in not valid (status code: "401", reason phrase: "Unauthorized").
     */
    public function testQueryWith401Response()
    {<commit_msg>Fixed tests<commit_after><?php

namespace Lyrixx\Twitter\Tests;

use Guzzle\Http\Client;
use Guzzle\Plugin\Mock\MockPlugin;
use Lyrixx\Twitter\Twitter;

/**
 * TwitterTest.
 *
 * All results and fixture values come from
 * https://dev.twitter.com/docs/auth/creating-signature
 *
 * @author <NAME> <<EMAIL>>
 */
class TwitterTest extends \PHPUnit_Framework_TestCase
{
    private $twitter;
    private $mockPlugin;
    private $logger;

    public function setUp()
    {
        $consumerKey = 'xvz1evFS4wEEPTGEFPHBog';
        $accessToken = '<KEY>';
        $consumerSecret = '<KEY>';
        $tokenSecret = '<KEY>';

        $this->mockPlugin = new MockPlugin();
        $client = new Client();
        $client->addSubscriber($this->mockPlugin);

        $this->logger = $this->getMock('Psr\Log\LoggerInterface');

        $this->twitter = new Twitter($consumerKey, $accessToken, $consumerSecret, $tokenSecret, null, null, $client, $this->logger);
    }

    public function testQueryWith200Response()
    {
        $this->mockPlugin->addResponse($this->mockPlugin->getMockFile(__DIR__.'/fixtures/GET_200_user_timeline.json'));

        $this->logger
            ->expects($this->never())
            ->method('error')
        ;

        $response = $this->twitter->query('GET', 'statuses/user_timeline');

        $this->assertInstanceOf('Guzzle\Http\Message\Response', $response);
        $tweets = json_decode($response->getBody(), true);

        $this->assertCount(20, $tweets);
    }

    /**
     * @expectedException Lyrixx\Twitter\Exception\ApiClientException
     * @expectedExceptionMessage The request is not valid (status code: "401", reason phrase: "Unauthorized").
     */
    public function testQueryWith401Response()
    {
{'fraction_non_alphanumeric': 0.14802065404475043, 'fraction_numerical': 0.009179575444635685, 'mean_word_length': 3.191105769230769, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 55, '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': '1756204', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1025, 'n_words': 191}