<commit_before><?php

namespace Tests\IliosApiBundle\Endpoints;

use Ilios\CoreBundle\Entity\OfferingInterface;
use Symfony\Component\HttpFoundation\Response;
use Tests\CoreBundle\DataLoader\CourseData;
use Tests\CoreBundle\DataLoader\IlmSessionData;
use Tests\CoreBundle\DataLoader\LearningMaterialData;
use Tests\CoreBundle\DataLoader\OfferingData;
use Tests\CoreBundle\DataLoader\SessionDescriptionData;
use Tests\CoreBundle\DataLoader\SessionTypeData;
use Tests\IliosApiBundle\AbstractEndpointTest;
use DateTime;

/**
 * UsereventTest API endpoint Test.
 * @group api_1
 */
class UsereventTest extends AbstractEndpointTest
{
    /**
     * @inheritdoc
     */
    protected function getFixtures()
    {
        return [
            'Tests\CoreBundle\Fixture\LoadOfferingData',
            'Tests\CoreBundle\Fixture\LoadIlmSessionData',
            'Tests\CoreBundle\Fixture\LoadUserData',
            'Tests\CoreBundle\Fixture\LoadSessionData',
            'Tests\CoreBundle\Fixture\LoadSessionDescriptionData',
            'Tests\CoreBundle\Fixture\LoadLearningMaterialData',
            'Tests\CoreBundle\Fixture\LoadCourseLearningMaterialData',
            'Tests\CoreBundle\Fixture\LoadSessionLearningMaterialData',
        ];
    }

    public function testGetEvents()
    {
        $offerings = $this->container->get(OfferingData::class)->getAll();
        $sessionTypes = $this->container->get(SessionTypeData::class)->getAll();
        $learningMaterials = $this->container->get(LearningMaterialData::class)->getAll();
        $sessionDescriptions = $this->container->get(SessionDescriptionData::class)->getAll();
        $ilmSessions = $this->container->get(IlmSessionData::class)->getAll();
        $courses = $this->container->get(CourseData::class)->getAll();

        $userId = 2;<commit_msg>test attached user materials on user events.<commit_after><?php

namespace Tests\IliosApiBundle\Endpoints;

use Ilios\CoreBundle\Entity\OfferingInterface;
use Symfony\Component\HttpFoundation\Response;
use Tests\CoreBundle\DataLoader\CourseData;
use Tests\CoreBundle\DataLoader\IlmSessionData;
use Tests\CoreBundle\DataLoader\LearningMaterialData;
use Tests\CoreBundle\DataLoader\OfferingData;
use Tests\CoreBundle\DataLoader\SessionDescriptionData;
use Tests\CoreBundle\DataLoader\SessionTypeData;
use Tests\IliosApiBundle\AbstractEndpointTest;
use DateTime;

/**
 * UsereventTest API endpoint Test.
 * @group api_1
 */
class UsereventTest extends AbstractEndpointTest
{
    /**
     * @inheritdoc
     */
    protected function getFixtures()
    {
        return [
            'Tests\CoreBundle\Fixture\LoadOfferingData',
            'Tests\CoreBundle\Fixture\LoadIlmSessionData',
            'Tests\CoreBundle\Fixture\LoadUserData',
            'Tests\CoreBundle\Fixture\LoadSessionData',
            'Tests\CoreBundle\Fixture\LoadSessionDescriptionData',
            'Tests\CoreBundle\Fixture\LoadLearningMaterialData',
            'Tests\CoreBundle\Fixture\LoadCourseLearningMaterialData',
            'Tests\CoreBundle\Fixture\LoadSessionLearningMaterialData',
        ];
    }

    public function testAttachedUserMaterials()
    {
        $userId = 5;
        $events = $this->getEvents($userId, 0, 100000000000);
        $lms = $events[0]['learningMaterials'];

        $this->assertEquals(10, count($lms));

        $this->assertEquals(13, count($lms[0]));
        $this->assertEquals('1', $lms[0]['id']);
        $this->assertEquals('1', $lms[0]['session']);
        $this->assertEquals('1', $lms[0]['course']);
        $this->assertTrue($lms[0]['required']);
        $this->assertStringStartsWith('firstlm', $lms[0]['title']);
        $this->assertEquals('desc1', $lms[0]['description']);
        $this->assertEquals('author1', $lms[0]['originalAuthor']);
        $this->assertEquals('citation1', $lms[0]['citation']);
        $this->assertEquals('citation', $lms[0]['mimetype']);
        $this->assertEquals('session1Title', $lms[0]['sessionTitle']);
        $this->assertEquals('firstCourse', $lms[0]['courseTitle']);
        $this->assertEquals(0, count($lms[0]['instructors']));
        $this->assertFalse($lms[0]['isBlanked']);

        $this->assertEquals(13, count($lms[1]));
        $this->assertFalse($lms[1]['isBlanked']);

        $this->assertEquals(13, count($lms[2]));
        $this->assertFalse($lms[2]['isBlanked']);

        $this->assertEquals(14, count($lms[3]));
        $this->assertFalse($lms[3]['isBlanked']);

        $this->assertEquals(15, count($lms[4]));
        $this->assertFalse($lms[4]['isBlanked']);

        $this->assertEquals(7, count($lms[5]));
        $this->assertEquals('6', $lms[5]['id']);
        $this->assertEquals('1', $lms[5]['course']);
        $this->assertEquals('sixthlm', $lms[5]['title']);
        $this->assertEquals('firstCourse', $lms[5]['courseTitle']);
        $this->assertEmpty($lms[5]['instructors']);
        $this->assertNotEmpty($lms[5]['startDate']);
        $this->assertTrue($lms[5]['isBlanked']);

        $this->assertEquals(15, count($lms[6]));
        $this->assertNotEmpty($lms[6]['endDate']);
        $this->assertFalse($lms[6]['isBlanked']);

        $this->assertEquals(7, count($lms[7]));
        $this->assertNotEmpty($lms[7]['endDate']);
        $this->assertTrue($lms[7]['isBlanked']);

        $this->assertEquals(16, count($lms[8]));
        $this->assertNotEmpty($lms[8]['startDate']);
        $this->assertNotEmpty($lms[8]['endDate']);
        $this->assertFalse($lms[8]['isBlanked']);

        $this->assertEquals(8, count($lms[9]));
        $this->assertNotEmpty($lms[9]['startDate']);
        $this->assertNotEmpty($lms[9]['endDate']);
        $this->assertTrue($lms[9]['isBlanked']);
    }

    public function testGetEvents()
    {
        $offerings = $this->container->get(OfferingData::class)->getAll();
        $sessionTypes = $this->container->get(SessionTypeData::class)->getAll();
        $sessionDescriptions = $this->container->get(SessionDescriptionData::class)->getAll();
        $ilmSessions = $this->container->get(IlmSessionData::class)->getAll();
        $courses = $this->container->get(CourseData::class)->getAll();

        $userId = 2;
{'fraction_non_alphanumeric': 0.1729957805907173, 'fraction_numerical': 0.014930217461863031, 'mean_word_length': 3.8565799842395587, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '1209224', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1823, 'n_words': 211}