<commit_before><?php

declare(strict_types=1);

namespace App\Tests\Endpoints;

use App\Tests\DataLoader\SchoolData;
use App\Tests\ReadWriteEndpointTest;

/**
 * CurriculumInventoryInstitution API endpoint Test.
 * @group api_2
 */
class CurriculumInventoryInstitutionTest extends ReadWriteEndpointTest
{
    protected $testName =  'curriculumInventoryInstitutions';

    /**
     * @inheritdoc
     */
    protected function getFixtures()
    {
        return [
            'App\Tests\Fixture\LoadCurriculumInventoryInstitutionData',
            'App\Tests\Fixture\LoadSchoolData',
        ];
    }

    /**
     * @inheritDoc
     */
    public function putsToTest()
    {
        return [
            'name' => ['name', $this->getFaker()->text(100)],
            'aamcCode' => ['aamcCode', $this->getFaker()->text(10)],
            'addressStreet' => ['addressStreet', $this->getFaker()->text(10)],
            'addressCity' => ['addressCity', $this->getFaker()->text(100)],
            'addressStateOrProvince' => ['addressStateOrProvince', $this->getFaker()->text(50)],
            'addressZipCode' => ['addressZipCode', $this->getFaker()->text(10)],
            'addressCountryCode' => ['addressCountryCode', $this->getFaker()->word],
            'school' => ['school', 3],
        ];
    }

    /**
     * @inheritDoc
     */
    public function readOnlyPropertiesToTest()
    {
        return [
            'id' => ['id', 1, 99],
        ];
    }

    /**
     * @inheritDoc
     */
    public function filtersToTest()
    {
        return [
            'id' => [[0], ['id' => 1]],
            'ids' => [[0, 1], ['id' => [1, 2]]],
            'name' => [[1], ['name' => 'second institution']],
            'aamcCode' => [[1], ['aamcCode' => 14]],
            'addressStreet' => [[1], ['addressStreet' => '221 East']],
            'addressCity' => [[0], ['addressCity' => 'first city']],
            'addressStateOrProvince' => [[1], ['addressStateOrProvince' => 'CA']],
            'addressZipCode' => [[1], ['addressZipCode' => '90210']],
            'addressCountryCode' => [[1], ['addressCountryCode' => 'BC']],
            'school' => [[1], ['school' => 2]],
        ];
    }

    protected function createMany(int $count): array
    {
        $schoolDataLoader = $this->getContainer()->get(SchoolData::class);
        $schools = $schoolDataLoader->createMany($count);
        $savedSchools = $this->postMany('schools', 'schools', $schools);

        $dataLoader = $this->getDataLoader();
        $id = $dataLoader->create()['id'];
        $data = [];
        foreach ($savedSchools as $school) {
            $arr = $dataLoader->create();
            $arr['school'] = (string) $school['id'];
            $arr['id'] = $id;
            $id++;

            $data[] = $arr;
        }

        return $data;<commit_msg>do not send stewards when creating schools in v3 api.<commit_after><?php

declare(strict_types=1);

namespace App\Tests\Endpoints;

use App\Tests\DataLoader\SchoolData;
use App\Tests\ReadWriteEndpointTest;

/**
 * CurriculumInventoryInstitution API endpoint Test.
 * @group api_2
 */
class CurriculumInventoryInstitutionTest extends ReadWriteEndpointTest
{
    protected $testName =  'curriculumInventoryInstitutions';

    /**
     * @inheritdoc
     */
    protected function getFixtures()
    {
        return [
            'App\Tests\Fixture\LoadCurriculumInventoryInstitutionData',
            'App\Tests\Fixture\LoadSchoolData',
        ];
    }

    /**
     * @inheritDoc
     */
    public function putsToTest()
    {
        return [
            'name' => ['name', $this->getFaker()->text(100)],
            'aamcCode' => ['aamcCode', $this->getFaker()->text(10)],
            'addressStreet' => ['addressStreet', $this->getFaker()->text(10)],
            'addressCity' => ['addressCity', $this->getFaker()->text(100)],
            'addressStateOrProvince' => ['addressStateOrProvince', $this->getFaker()->text(50)],
            'addressZipCode' => ['addressZipCode', $this->getFaker()->text(10)],
            'addressCountryCode' => ['addressCountryCode', $this->getFaker()->word],
            'school' => ['school', 3],
        ];
    }

    /**
     * @inheritDoc
     */
    public function readOnlyPropertiesToTest()
    {
        return [
            'id' => ['id', 1, 99],
        ];
    }

    /**
     * @inheritDoc
     */
    public function filtersToTest()
    {
        return [
            'id' => [[0], ['id' => 1]],
            'ids' => [[0, 1], ['id' => [1, 2]]],
            'name' => [[1], ['name' => 'second institution']],
            'aamcCode' => [[1], ['aamcCode' => 14]],
            'addressStreet' => [[1], ['addressStreet' => '221 East']],
            'addressCity' => [[0], ['addressCity' => 'first city']],
            'addressStateOrProvince' => [[1], ['addressStateOrProvince' => 'CA']],
            'addressZipCode' => [[1], ['addressZipCode' => '90210']],
            'addressCountryCode' => [[1], ['addressCountryCode' => 'BC']],
            'school' => [[1], ['school' => 2]],
        ];
    }

    protected function createMany(int $count): array
    {
        $schoolDataLoader = $this->getContainer()->get(SchoolData::class);
        $schools = $schoolDataLoader->createMany($count);
        $schools = array_map(function (array $school) {
            unset($school['stewards']);
            return $school;
        }, $schools);
        $savedSchools = $this->postMany('schools', 'schools', $schools);

        $dataLoader = $this->getDataLoader();
        $id = $dataLoader->create()['id'];
        $data = [];
        foreach ($savedSchools as $school) {
            $arr = $dataLoader->create();
            $arr['school'] = (string) $school['id'];
            $arr['id'] = $id;
            $id++;

            $data[] = $arr;
        }

        return $data;
{'fraction_non_alphanumeric': 0.1909900650907845, 'fraction_numerical': 0.015587529976019185, 'mean_word_length': 2.310090702947846, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 103, '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': '6537036', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1749, 'n_words': 316}