<commit_before><?php

namespace Buzz\History;

use Buzz\Message;

include __DIR__.'/../../../bootstrap/unit.php';

$t = new \LimeTest(2);

$request1 = new Message\Request();
$request1->setContent('request1');
$request2 = new Message\Request();
$request2->setContent('request2');
$request3 = new Message\Request();
$request3->setContent('request3');

$response1 = new Message\Response();
$response1->setContent('response1');
$response2 = new Message\Response();
$response2->setContent('response2');
$response3 = new Message\Response();
$response3->setContent('response3');

// ->record() ->getLast()
$t->diag('->record() ->getLast()');

$journal = new Journal();
$journal->setLimit(2);
$journal->record($request1, $response1);
$journal->record($request2, $response2);
$journal->record($request3, $response3);

$t->is(count($journal), 2, '->record() respects the set limit');
$t->is($journal->getLast()->getRequest()->getContent(), 'request3', '->getLast() returns the last entry');<commit_msg>Converted Journal tests to PHPUnit.<commit_after><?php

namespace Buzz\History;

use Buzz\Message;

require_once __DIR__.'/../../../lib/Buzz/ClassLoader.php';
\Buzz\ClassLoader::register();

require_once 'PHPUnit/Framework/TestCase.php';

class JournalTest extends \PHPUnit_Framework_TestCase
{
  protected $request1;
  protected $request2;
  protected $request3;

  protected $response1;
  protected $response2;
  protected $response3;

  public function setUp()
  {
    $this->request1 = new Message\Request();
    $this->request1->setContent('request1');
    $this->request2 = new Message\Request();
    $this->request2->setContent('request2');
    $this->request3 = new Message\Request();
    $this->request3->setContent('request3');

    $this->response1 = new Message\Response();
    $this->response1->setContent('response1');
    $this->response2 = new Message\Response();
    $this->response2->setContent('response2');
    $this->response3 = new Message\Response();
    $this->response3->setContent('response3');
  }

  public function testRecordEnforcesLimit()
  {
    $journal = new Journal();
    $journal->setLimit(2);

    $journal->record($this->request1, $this->response1);
    $journal->record($this->request2, $this->response2);
    $journal->record($this->request3, $this->response3);

    $this->assertEquals(count($journal), 2);
  }

  public function testGetLastReturnsTheLastEntry()
  {
    $journal = new Journal();

    $journal->record($this->request1, $this->response1);
    $journal->record($this->request2, $this->response2);

    $this->assertEquals($journal->getLast()->getRequest(), $this->request2);
  }
}
{'fraction_non_alphanumeric': 0.19399011030810193, 'fraction_numerical': 0.024724229745150247, 'mean_word_length': 5.188235294117647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, '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': '952830', 'n_tokens_mistral': 825, 'n_tokens_neox': 809, 'n_words': 145}