<commit_before><?php

namespace Hodor\JobQueue\JobOptions;

use DateTime;
use Exception;
use Hodor\JobQueue\Config;
use PHPUnit_Framework_TestCase;

/**
 * @coversDefaultClass Hodor\JobQueue\JobOptions\Validator
 */
class ValidatorTest extends PHPUnit_Framework_TestCase
{
    /**
     * @expectedException \Exception
     */
    public function testUnknownOptionThrowsAnException()
    {
        $this->generateValidator()->validateJobOptions(['made_up' => 'option']);
    }

    /**
     * @expectedException \Exception
     */
    public function testUnknownQueueNameThrowsAnException()
    {
        $this->generateValidator()->validateJobOptions(['queue_name' => 'made_up_queue']);
    }

    public function testKnownQueueNameCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['queue_name' => 'queue_a']);
    }

    /**
     * @expectedException \Exception
     */
    public function testRunAfterThrowsAnExceptionIfItIsNotADateTimeObject()
    {
        $this->generateValidator()->validateJobOptions(['run_after' => '2015-12-12']);
    }

    public function testRunAfterCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['run_after' => new DateTime()]);
    }

    /**
     * @expectedException \Exception
     */
    public function testJobRankThrowsAnExceptionIfANonIntegerIsPassedIn()
    {
        $this->generateValidator()->validateJobOptions(['job_rank' => 'abc']);
    }

    /**
     * @expectedException \Exception
     */
    public function testJobRankThrowsAnExceptionIfAnOutOfRangeRankIsUsed()
    {
        $this->generateValidator()->validateJobOptions(['job_rank' => 25]);
    }

    public function testJobRankCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['job_rank' => 5]);
    }

    /**
     * @expectedException \Exception
     */
    public function testMutexIdThrowsAnExceptionIfMutexIsNotAScalar()
    {
        $this->generateValidator()->validateJobOptions(['mutex_id' => new \stdClass()]);
    }

    /**
     * @expectedException \Exception
     */
    public function testMutexIdThrowsAnExceptionIfMutexIsEmpty()
    {
        $this->generateValidator()->validateJobOptions(['mutex_id' => '']);
    }

    public function testMutexIdCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['mutex_id' => 'yay']);
    }
<commit_msg>Add @covers notations for JobOptions validator<commit_after><?php

namespace Hodor\JobQueue\JobOptions;

use DateTime;
use Exception;
use Hodor\JobQueue\Config;
use PHPUnit_Framework_TestCase;

/**
 * @coversDefaultClass Hodor\JobQueue\JobOptions\Validator
 */
class ValidatorTest extends PHPUnit_Framework_TestCase
{
    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateOptionsAreKnown
     * @expectedException \Exception
     */
    public function testUnknownOptionThrowsAnException()
    {
        $this->generateValidator()->validateJobOptions(['made_up' => 'option']);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateOptionsAreKnown
     * @covers ::validateQueueName
     * @expectedException \Exception
     */
    public function testUnknownQueueNameThrowsAnException()
    {
        $this->generateValidator()->validateJobOptions(['queue_name' => 'made_up_queue']);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateQueueName
     */
    public function testKnownQueueNameCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['queue_name' => 'queue_a']);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateRunAfter
     * @expectedException \Exception
     */
    public function testRunAfterThrowsAnExceptionIfItIsNotADateTimeObject()
    {
        $this->generateValidator()->validateJobOptions(['run_after' => '2015-12-12']);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateRunAfter
     */
    public function testRunAfterCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['run_after' => new DateTime()]);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateJobRank
     * @expectedException \Exception
     */
    public function testJobRankThrowsAnExceptionIfANonIntegerIsPassedIn()
    {
        $this->generateValidator()->validateJobOptions(['job_rank' => 'abc']);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateJobRank
     * @expectedException \Exception
     */
    public function testJobRankThrowsAnExceptionIfAnOutOfRangeRankIsUsed()
    {
        $this->generateValidator()->validateJobOptions(['job_rank' => 25]);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateJobRank
     */
    public function testJobRankCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['job_rank' => 5]);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateMutexId
     * @expectedException \Exception
     */
    public function testMutexIdThrowsAnExceptionIfMutexIsNotAScalar()
    {
        $this->generateValidator()->validateJobOptions(['mutex_id' => new \stdClass()]);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateMutexId
     * @expectedException \Exception
     */
    public function testMutexIdThrowsAnExceptionIfMutexIsEmpty()
    {
        $this->generateValidator()->validateJobOptions(['mutex_id' => '']);
    }

    /**
     * @covers ::__construct
     * @covers ::validateJobOptions
     * @covers ::validateMutexId
     */
    public function testMutexIdCanValidateWithoutAnException()
    {
        $this->generateValidator()->validateJobOptions(['mutex_id' => 'yay']);
    }

{'fraction_non_alphanumeric': 0.1310107948969578, 'fraction_numerical': 0.003598298985933922, 'mean_word_length': 3.3741058655221745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, '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': '2270827', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1697, 'n_words': 247}