<commit_before><?php
/**
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @copyright     Copyright (c) <NAME> <<EMAIL>>
 * @link          http://cakephp.org CakePHP(tm) Project
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

namespace Interval;

use Cake\Chronos\ChronosInterval;
use DateInterval;
use TestCase;

class IntervalToStringTest extends TestCase
{
    public function testZeroInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 0, 0, 0);
        $this->assertEquals('PT0S', (string)$ci);
    }

    public function testYearInterval()
    {
        $ci = new ChronosInterval();
        $this->assertEquals('P1Y', (string)$ci);
    }

    public function testMonthInterval()
    {
        $ci = new ChronosInterval(0, 1);
        $this->assertEquals('P1M', (string)$ci);
    }

    public function testWeekInterval()
    {
        $ci = new ChronosInterval(0, 0, 1);
        $this->assertEquals('P7D', (string)$ci);
    }

    public function testDayInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 1);
        $this->assertEquals('P1D', (string)$ci);
    }

    public function testMixedDateInterval()
    {
        $ci = new ChronosInterval(1, 2, 0, 3);
        $this->assertEquals('P1Y2M3D', (string)$ci);
    }

    public function testHourInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 1);
        $this->assertEquals('PT1H', (string)$ci);
    }

    public function testMinuteInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 0, 1);
        $this->assertEquals('PT1M', (string)$ci);
    }

    public function testSecondInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 0, 0, 1);
        $this->assertEquals('PT1S', (string)$ci);
    }

    public function testMixedTimeInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 1, 2, 3);
        $this->assertEquals('PT1H2M3S', (string)$ci);
    }

    public function testMixedDateAndTimeInterval()
    {
        $ci = new ChronosInterval(1, 2, 0, 3, 4, 5, 6);
        $this->assertEquals('P1Y2M3DT4H5M6S', (string)$ci);
    }

    public function testCreatingInstanceEquals()
    {
        $ci = new ChronosInterval(1, 2, 0, 3, 4, 5, 6);
        $this->assertEquals(
            $ci,
            ChronosInterval::instance(new DateInterval((string)$ci))
        );
    }

    public function testNegativeInterval()
    {
        $ci = new ChronosInterval(1, 2, 0, 3, 4, 5, 6);
        $ci->invert = 1;
        $this->assertEquals('-P1Y2M3DT4H5M6S', (string) $ci);
    }
}<commit_msg>Fix CS.<commit_after><?php
/**
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @copyright     Copyright (c) <NAME> <<EMAIL>>
 * @link          http://cakephp.org CakePHP(tm) Project
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

namespace Interval;

use Cake\Chronos\ChronosInterval;
use DateInterval;
use TestCase;

class IntervalToStringTest extends TestCase
{
    public function testZeroInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 0, 0, 0);
        $this->assertEquals('PT0S', (string)$ci);
    }

    public function testYearInterval()
    {
        $ci = new ChronosInterval();
        $this->assertEquals('P1Y', (string)$ci);
    }

    public function testMonthInterval()
    {
        $ci = new ChronosInterval(0, 1);
        $this->assertEquals('P1M', (string)$ci);
    }

    public function testWeekInterval()
    {
        $ci = new ChronosInterval(0, 0, 1);
        $this->assertEquals('P7D', (string)$ci);
    }

    public function testDayInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 1);
        $this->assertEquals('P1D', (string)$ci);
    }

    public function testMixedDateInterval()
    {
        $ci = new ChronosInterval(1, 2, 0, 3);
        $this->assertEquals('P1Y2M3D', (string)$ci);
    }

    public function testHourInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 1);
        $this->assertEquals('PT1H', (string)$ci);
    }

    public function testMinuteInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 0, 1);
        $this->assertEquals('PT1M', (string)$ci);
    }

    public function testSecondInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 0, 0, 1);
        $this->assertEquals('PT1S', (string)$ci);
    }

    public function testMixedTimeInterval()
    {
        $ci = new ChronosInterval(0, 0, 0, 0, 1, 2, 3);
        $this->assertEquals('PT1H2M3S', (string)$ci);
    }

    public function testMixedDateAndTimeInterval()
    {
        $ci = new ChronosInterval(1, 2, 0, 3, 4, 5, 6);
        $this->assertEquals('P1Y2M3DT4H5M6S', (string)$ci);
    }

    public function testCreatingInstanceEquals()
    {
        $ci = new ChronosInterval(1, 2, 0, 3, 4, 5, 6);
        $this->assertEquals(
            $ci,
            ChronosInterval::instance(new DateInterval((string)$ci))
        );
    }

    public function testNegativeInterval()
    {
        $ci = new ChronosInterval(1, 2, 0, 3, 4, 5, 6);
        $ci->invert = 1;
        $this->assertEquals('-P1Y2M3DT4H5M6S', (string)$ci);
    }
}
{'fraction_non_alphanumeric': 0.14866079453532266, 'fraction_numerical': 0.03343519683623944, 'mean_word_length': 2.6461336828309308, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6026988', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1801, 'n_words': 436}