<commit_before><?php

namespace ScottRobertson\Premailer;

use ScottRobertson\Premailer\Response;
use Mockery;

class ResponseTest extends TestCase
{
  public function testDownloadHtml()
  {
    $expectedResponse = 'response';
    $data = [
      'documents' => [
        'html' => 'http://example.com'
      ]
    ];

    $mockGuzzle = Mockery::mock('\GuzzleHttp\Client')
      ->shouldReceive('get')
      ->once()
      ->with($data['documents']['html'])
      ->andReturn(Mockery::self())
      ->shouldReceive('getBody')
      ->once()
      ->andReturn($expectedResponse)
      ->mock();

    $response = new Response($data, $mockGuzzle);
    $this->assertEquals(
      $expectedResponse,
      $response->downloadHtml()
    );
  }

  public function testDownloadText()
  {
    $expectedResponse = 'response';
    $data = [
      'documents' => [
        'text' => 'http://example.com'
      ]
    ];

    $mockGuzzle = Mockery::mock('\GuzzleHttp\Client')
      ->shouldReceive('get')
      ->once()
      ->with($data['documents']['text'])
      ->andReturn(Mockery::self())
      ->shouldReceive('getBody')
      ->once()
      ->andReturn($expectedResponse)
      ->mock();

    $response = new Response($data, $mockGuzzle);
    $this->assertEquals(
      $expectedResponse,
      $response->downloadText()
    );
  }

  /**
   * @expectedExceptionMessage Get failed
   * @expectedException ScottRobertson\Premailer\Exception\Request
   */
  public function testDownload_Fail()
  {
    $expectedResponse = 'response';
    $data = [
      'documents' => [
        'text' => 'http://example.com'
      ]
    ];

    $mockGuzzle = Mockery::mock('\GuzzleHttp\Client')
      ->shouldReceive('get')
      ->once()
      ->with($data['documents']['text'])
      ->andThrow(new \Exception('Get failed'))
      ->mock();

    $response = new Response($data, $mockGuzzle);<commit_msg>Updates test to work with new code changes<commit_after><?php

namespace ScottRobertson\Premailer;

use ScottRobertson\Premailer\Response;
use Mockery;

class ResponseTest extends TestCase
{
  public function testDownloadHtml()
  {
    $expectedResponse = 'response';
    $data = [
      'documents' => [
        'html' => 'http://example.com'
      ]
    ];

    $mockGuzzle = Mockery::mock('\GuzzleHttp\Client')
      ->shouldReceive('get')
      ->once()
      ->with($data['documents']['html'])
      ->andReturn(Mockery::self())
      ->shouldReceive('getBody')
      ->once()
      ->andReturn($expectedResponse)
      ->mock();

    $response = new Response($data, $mockGuzzle);
    $this->assertEquals(
      $expectedResponse,
      $response->downloadHtml()
    );
  }

  public function testDownloadText()
  {
    $expectedResponse = 'response';
    $data = [
      'documents' => [
        'text' => 'http://example.com'
      ]
    ];

    $mockGuzzle = Mockery::mock('\GuzzleHttp\Client')
      ->shouldReceive('get')
      ->once()
      ->with($data['documents']['txt'])
      ->andReturn(Mockery::self())
      ->shouldReceive('getBody')
      ->once()
      ->andReturn($expectedResponse)
      ->mock();

    $response = new Response($data, $mockGuzzle);
    $this->assertEquals(
      $expectedResponse,
      $response->downloadText()
    );
  }

  /**
   * @expectedExceptionMessage Get failed
   * @expectedException ScottRobertson\Premailer\Exception\Request
   */
  public function testDownload_Fail()
  {
    $expectedResponse = 'response';
    $data = [
      'documents' => [
        'text' => 'http://example.com'
      ]
    ];

    $mockGuzzle = Mockery::mock('\GuzzleHttp\Client')
      ->shouldReceive('get')
      ->once()
      ->with($data['documents']['txt'])
      ->andThrow(new \Exception('Get failed'))
      ->mock();

    $response = new Response($data, $mockGuzzle);
{'fraction_non_alphanumeric': 0.1750593197996309, 'fraction_numerical': 0.0, 'mean_word_length': 2.734251968503937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7383970', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1144, 'n_words': 186}