<commit_before><?php

namespace NavJobs\LaravelApi\Test\Integration;

class EagerLoadTest extends TestCase
{
    /**
 * @test
 */
    public function it_correctly_parses_a_string_of_includes()
    {
        $transformer = new TestTransformer();
        $array = $transformer->getEagerLoads('characters,books,publisher');

        $expectedArray = [
            'characters',
            'publisher'
        ];

        $this->assertEquals($expectedArray, $array);
    }

    /**
     * @test
     */
    public function it_correctly_parses_an_array_of_includes()
    {
        $transformer = new TestTransformer();
        $array = $transformer->getEagerLoads(['characters', 'books', 'publisher']);

        $expectedArray = [
            'characters',
            'publisher'
        ];

        $this->assertEquals($expectedArray, $array);
    }

    /**
     * @test
     */
    public function it_returns_nothing_when_no_matches()
    {
        $transformer = new TestTransformer();
        $array = $transformer->getEagerLoads('papers, books,staplers');
        $expectedArray = [];

        $this->assertEquals($expectedArray, $array);
    }
}<commit_msg>Adding tests to check that transformers properly validate passed parameters.<commit_after><?php

namespace NavJobs\LaravelApi\Test\Integration;

use League\Fractal\ParamBag;

class TransformerTest extends TestCase
{
    /**
 * @test
 */
    public function it_correctly_parses_a_string_of_eager_load_includes()
    {
        $transformer = new TestTransformer();
        $array = $transformer->getEagerLoads('characters,books,publisher');

        $expectedArray = [
            'characters',
            'publisher'
        ];

        $this->assertEquals($expectedArray, $array);
    }

    /**
     * @test
     */
    public function it_correctly_parses_an_array_of_eager_load_includes()
    {
        $transformer = new TestTransformer();
        $array = $transformer->getEagerLoads(['characters', 'books', 'publisher']);

        $expectedArray = [
            'characters',
            'publisher'
        ];

        $this->assertEquals($expectedArray, $array);
    }

    /**
     * @test
     */
    public function it_returns_nothing_when_no_eager_load_matches()
    {
        $transformer = new TestTransformer();
        $array = $transformer->getEagerLoads('papers, books,staplers');
        $expectedArray = [];

        $this->assertEquals($expectedArray, $array);
    }

    /**
     * @test
     */
    public function it_accepts_valid_parameters()
    {
        $transformer = new TestTransformer();
        $valid = $transformer->validateParameters(new ParamBag([
            'limit' => [
                '1' => '1'
            ],
            'order' => [
                'created_at' => 'desc'
            ]
        ]));

        $this->assertEquals(true, $valid);
    }

    /**
     * @test
     * @expectedException NavJobs\LaravelApi\Exceptions\InvalidParameters
     */
    public function it_throws_an_exception_for_invalid_parameters()
    {
        $transformer = new TestTransformer();
        $transformer->validateParameters(new ParamBag([
            'not-valid' => [
                '1' => '1'
            ]
        ]));
    }
}
{'fraction_non_alphanumeric': 0.12872208436724566, 'fraction_numerical': 0.0012406947890818859, 'mean_word_length': 2.2542885973763873, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '4025989', 'n_tokens_mistral': 957, 'n_tokens_neox': 929, 'n_words': 143}