<commit_before><?php

namespace Alchemy\Rest\Tests\Request\DateParser;

use Alchemy\Rest\Request\DateParser\FormatDateParser;

class FormatDateParserTest extends \PHPUnit_Framework_TestCase
{

    public function getInvalidDates()
    {
        return array(
            array('hfjdsfjds'),
            array(null),
            array(0),
            array(false),
            array(''),
            array(123.23)
        );
    }

    /**
     * @dataProvider getInvalidDates
     */
    public function testParseInvalidDateReturnsNull($date)
    {
        $parser = new FormatDateParser('UTC', 'Y-m-d H:i:s');

        $this->assertNull($parser->parseDate($date));
    }

    public function testParseReturnsCorrectDate()
    {
        // Using current timezone is required as this format has no TZ info
        $parser = new FormatDateParser(date_default_timezone_get(), 'Y-m-d H:i:s');
        $date = $parser->parseDate('2015-08-01 15:25:30');

        $this->assertEquals(date_default_timezone_get(), $date->getTimezone()->getName());
        $this->assertEquals('1438435530', $date->getTimestamp());
    }

    public function testParseReturnsDateWithCorrectTimezone()
    {
        $parser = new FormatDateParser('Europe/Paris', 'Y-m-d H:i:s');
        $this->assertEquals('Europe/Paris', $parser->parseDate('2015-08-01 15:25:30')->getTimezone()->getName());

        $parser = new FormatDateParser('Europe/Moscow', 'Y-m-d H:i:s');
        $this->assertEquals('Europe/Moscow', $parser->parseDate('2015-08-01 15:25:30')->getTimezone()->getName());

        $parser = new FormatDateParser('UTC', 'Y-m-d H:i:s');
        $this->assertEquals('UTC', $parser->parseDate('2015-08-01 15:25:30')->getTimezone()->getName());
    }
}<commit_msg>Fix failing test<commit_after><?php

namespace Alchemy\Rest\Tests\Request\DateParser;

use Alchemy\Rest\Request\DateParser\FormatDateParser;

class FormatDateParserTest extends \PHPUnit_Framework_TestCase
{

    public function getInvalidDates()
    {
        return array(
            array('hfjdsfjds'),
            array(null),
            array(0),
            array(false),
            array(''),
            array(123.23)
        );
    }

    /**
     * @dataProvider getInvalidDates
     */
    public function testParseInvalidDateReturnsNull($date)
    {
        $parser = new FormatDateParser('UTC', 'Y-m-d H:i:s');

        $this->assertNull($parser->parseDate($date));
    }

    public function testParseReturnsCorrectDate()
    {
        // Using current timezone is required as this format has no TZ info
        $parser = new FormatDateParser('UTC', 'Y-m-d H:i:s');
        $date = $parser->parseDate('2015-08-01 15:25:30');

        $this->assertEquals('UTC', $date->getTimezone()->getName());
        $this->assertEquals('1438442730', $date->getTimestamp());
    }

    public function testParseReturnsDateWithCorrectTimezone()
    {
        $parser = new FormatDateParser('Europe/Paris', 'Y-m-d H:i:s');
        $this->assertEquals('Europe/Paris', $parser->parseDate('2015-08-01 15:25:30')->getTimezone()->getName());

        $parser = new FormatDateParser('Europe/Moscow', 'Y-m-d H:i:s');
        $this->assertEquals('Europe/Moscow', $parser->parseDate('2015-08-01 15:25:30')->getTimezone()->getName());

        $parser = new FormatDateParser('UTC', 'Y-m-d H:i:s');
        $this->assertEquals('UTC', $parser->parseDate('2015-08-01 15:25:30')->getTimezone()->getName());
    }
}
{'fraction_non_alphanumeric': 0.16564952048823017, 'fraction_numerical': 0.041848299912816043, 'mean_word_length': 3.0257309941520467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '2496401', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1040, 'n_words': 172}