<commit_before><?php

namespace Stuart\Tests\Repository;

class JobRepositoryTest extends \PHPUnit_Framework_TestCase
{

}<commit_msg>add job repository tests<commit_after><?php

namespace Stuart\Tests\Repository;

use Stuart\Converters\JobToJson;
use Stuart\Infrastructure\ApiResponse;
use Stuart\Repository\JobRepository;
use Stuart\Tests\Mock;

class JobRepositoryTest extends \PHPUnit_Framework_TestCase
{
    private $httpClient;
    private $jobRepository;
    private $mock;

    public function setUp()
    {
        $this->httpClient = \Phake::mock(\Stuart\Infrastructure\HttpClient::class);
        $this->jobRepository = new JobRepository($this->httpClient);
        $this->mock = new Mock();

        \Phake::when($this->httpClient)->performGet(\Phake::anyParameters())->thenReturn(
            new ApiResponse(200, $this->mock->to_json_response())
        );

        \Phake::when($this->httpClient)->performPost(\Phake::anyParameters())->thenReturn(
            new ApiResponse(200, $this->mock->to_json_response())
        );
    }

    public function test_it_creates_a_job_with_correct_parameters()
    {
        $job = $this->mock->job();
        $this->jobRepository->save($job);
        \Phake::verify($this->httpClient)->performPost(JobToJson::convert($job), '/v2/jobs');
    }

    public function test_it_gets_a_job_with_correct_parameters()
    {
        $sampleJobId = 123;
        $this->jobRepository->get($sampleJobId);
        \Phake::verify($this->httpClient)->performGet('/v2/jobs/' . $sampleJobId);
    }


    public function test_create_a_job_returns_a_job()
    {
        self::assertNotNull($this->jobRepository->get(123));
    }

    public function test_get_a_job_returns_a_job()
    {
        self::assertNotNull($this->jobRepository->save($this->mock->job()));
    }
}
{'fraction_non_alphanumeric': 0.144358407079646, 'fraction_numerical': 0.007743362831858407, 'mean_word_length': 3.6987012987012986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '6608711', 'n_tokens_mistral': 558, 'n_tokens_neox': 541, 'n_words': 74}