<commit_before><?php
namespace Dyvelop\ICalCreatorBundle\Tests\Component;

use Dyvelop\ICalCreatorBundle\Component\Calendar;
use Dyvelop\ICalCreatorBundle\Tests\CalendarTestCase;

/**
 * Tests for calendar component
 *
 * @package Dyvelop\ICalCreatorBundle\Tests
 * @author  <NAME> <<EMAIL>>
 */
class CalendarTest extends CalendarTestCase
{

    /**
     * Testing initiating calendar
     *
     * @param array $config Calendar config
     *
     * @dataProvider getCalendarConfigTestData
     */
    public function testInit(array $config)
    {
        $calendar = new Calendar($config);
        $this->assertCalendarConfigs($config, $calendar);
    }


    /**
     * Testing getter for content type
     *
     * @param array  $config      Calendar config
     * @param string $contentType Expected content type
     *
     * @dataProvider getCalendarContentTypeTestData
     */
    public function testGetContentType(array $config, $contentType)
    {
        $calendar = new Calendar($config);
        $this->assertEquals($contentType, $calendar->getContentType());
    }


    /**
     * Test creating new event for calendar
     */
    public function testNewEvent()
    {
        $calendar = new Calendar();
        $this->assertEmpty($calendar->getComponent('vevent'));

        $event = $calendar->newEvent();
        $this->assertInstanceOf('vevent', $event);
        $this->assertEquals($event, $calendar->getComponent('vevent'));
    }


    /**
     * Test setter for timezone
     *
     * @param string $timezone
     *
     * @dataProvider getCalendarTimezoneTestData
     */
    public function testSetTimezone($timezone)
    {
        $calendar = new Calendar();
        $reflection = new \ReflectionObject($calendar);
        $attribute = $reflection->getProperty('timezone');
        $attribute->setAccessible(true);

        // check timezone values before setting
        $this->assertEmpty($attribute->getValue($calendar));
        $this->assertEmpty($calendar->getConfig('TZID'));
        $this->assertFalse($calendar->getProperty('X-WR-TIMEZONE'));
        $this->assertFalse($calendar->getComponent('vtimezone'));

        // check timezone values after setting
        $calendar->setTimezone($timezone);
        $this->assertEquals($timezone, $attribute->getValue($calendar));
        $this->assertEquals($timezone, $calendar->getConfig('TZID'));
        $this->assertContains($timezone, $calendar->getProperty('X-WR-TIMEZONE'));

        // check timezone component
        $calendar->createCalendar();
        $this->assertInstanceOf('vtimezone', $calendar->getComponent('vtimezone'));
    }


    /**
     * Get calendar test config
     *
     * @return array
     */
    public function getCalendarContentTypeTestData()
    {
        return array(
            array(array('format' => 'iCal'), 'text/calendar'),
            array(array('format' => 'xCal'), 'application/calendar+xml'),
        );
    }


    /**
     * Get calendar timezone test data
     *
     * @return array
     */
    public function getCalendarTimezoneTestData()
    {
        return array(
            array('America/Chicago'),
            array('Europe/Berlin'),
        );
    }
}<commit_msg>change timezone test data<commit_after><?php
namespace Dyvelop\ICalCreatorBundle\Tests\Component;

use Dyvelop\ICalCreatorBundle\Component\Calendar;
use Dyvelop\ICalCreatorBundle\Tests\CalendarTestCase;

/**
 * Tests for calendar component
 *
 * @package Dyvelop\ICalCreatorBundle\Tests
 * @author  <NAME> <<EMAIL>>
 */
class CalendarTest extends CalendarTestCase
{

    /**
     * Testing initiating calendar
     *
     * @param array $config Calendar config
     *
     * @dataProvider getCalendarConfigTestData
     */
    public function testInit(array $config)
    {
        $calendar = new Calendar($config);
        $this->assertCalendarConfigs($config, $calendar);
    }


    /**
     * Testing getter for content type
     *
     * @param array  $config      Calendar config
     * @param string $contentType Expected content type
     *
     * @dataProvider getCalendarContentTypeTestData
     */
    public function testGetContentType(array $config, $contentType)
    {
        $calendar = new Calendar($config);
        $this->assertEquals($contentType, $calendar->getContentType());
    }


    /**
     * Test creating new event for calendar
     */
    public function testNewEvent()
    {
        $calendar = new Calendar();
        $this->assertEmpty($calendar->getComponent('vevent'));

        $event = $calendar->newEvent();
        $this->assertInstanceOf('vevent', $event);
        $this->assertEquals($event, $calendar->getComponent('vevent'));
    }


    /**
     * Test setter for timezone
     */
    public function testSetTimezone()
    {
        $timezone = 'Europe/Berlin';
        $calendar = new Calendar();
        $reflection = new \ReflectionObject($calendar);
        $attribute = $reflection->getProperty('timezone');
        $attribute->setAccessible(true);

        // check timezone values before setting
        $this->assertEmpty($attribute->getValue($calendar));
        $this->assertEmpty($calendar->getConfig('TZID'));
        $this->assertFalse($calendar->getProperty('X-WR-TIMEZONE'));
        $this->assertFalse($calendar->getComponent('vtimezone'));

        // check timezone values after setting
        $calendar->setTimezone($timezone);
        $this->assertEquals($timezone, $attribute->getValue($calendar));
        $this->assertEquals($timezone, $calendar->getConfig('TZID'));
        $this->assertContains($timezone, $calendar->getProperty('X-WR-TIMEZONE'));

        // check timezone component
        $calendar->createCalendar();
        $this->assertInstanceOf('vtimezone', $calendar->getComponent('vtimezone'));
    }


    /**
     * Get calendar test config
     *
     * @return array
     */
    public function getCalendarContentTypeTestData()
    {
        return array(
            array(array('format' => 'iCal'), 'text/calendar'),
            array(array('format' => 'xCal'), 'application/calendar+xml'),
        );
    }
}
{'fraction_non_alphanumeric': 0.13569321533923304, 'fraction_numerical': 0.0, 'mean_word_length': 2.8072364316905802, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '804841', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1615, 'n_words': 316}