mirror of
https://github.com/justinrainbow/json-schema.git
synced 2025-05-01 12:08:02 +02:00
* Split $objectDefinition into $schema and $properties (#411) Object validation attempts to use a single variable to store both the object definition, and its properties. This causes validation to be incomplete where "properties" is not set, but "additionalProperties" is. This commit fixes both bugs in issue #353. * Issue-414: Allow The Option of T or space for Date time. (#415) * Testcase for minProperties with properties defined (#416) + Fix Test * Tweak phpdocumentor dependency to avoid install conflicts (#421) * [BUGFIX] Cast empty schema arrays to object (#409) * Cast root to object * Use function_exists to allow polyfill compatibility * Move array->object conversion to SchemaConstraint & SchemaStorage Fixes issue #408 * fix bug when applying defaults for array items when the schema is for (#405) all items and add support for minItems when applying defaults * [BUGFIX] Split "uri" format into "uri" & "uri-reference", fix meta-schema bug (#419) * Split "uri" format into "uri" and "uri-reference" * Correct format for id & $ref in draft-03/04 meta-schemas See https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues/177#issuecomment-293051367
76 lines
2.5 KiB
PHP
76 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace JsonSchema\Tests;
|
|
|
|
use JsonSchema\Rfc3339;
|
|
|
|
class Rfc3339Test extends \PHPUnit_Framework_TestCase
|
|
{
|
|
/**
|
|
* @param string $string
|
|
* @param \DateTime|null $expected
|
|
* @dataProvider provideValidFormats
|
|
*/
|
|
public function testCreateFromValidString($string, \DateTime $expected)
|
|
{
|
|
$actual = Rfc3339::createFromString($string);
|
|
|
|
$this->assertInstanceOf('DateTime', $actual);
|
|
$this->assertEquals($expected->format('U.u'), $actual->format('U.u'));
|
|
}
|
|
|
|
/**
|
|
* @param string $string
|
|
* @dataProvider provideInvalidFormats
|
|
*/
|
|
public function testCreateFromInvalidString($string)
|
|
{
|
|
$this->assertNull(Rfc3339::createFromString($string), sprintf('String "%s" should not be converted to DateTime', $string));
|
|
}
|
|
|
|
public function provideValidFormats()
|
|
{
|
|
return array(
|
|
array(
|
|
'2000-05-01T12:12:12Z',
|
|
\DateTime::createFromFormat('Y-m-d\TH:i:s', '2000-05-01T12:12:12', new \DateTimeZone('UTC'))
|
|
),
|
|
array(
|
|
'2000-05-01T12:12:12+0100',
|
|
\DateTime::createFromFormat('Y-m-d\TH:i:sP', '2000-05-01T12:12:12+01:00')
|
|
),
|
|
array(
|
|
'2000-05-01T12:12:12+01:00',
|
|
\DateTime::createFromFormat('Y-m-d\TH:i:sP', '2000-05-01T12:12:12+01:00')
|
|
),
|
|
array(
|
|
'2000-05-01T12:12:12.123456Z',
|
|
\DateTime::createFromFormat('Y-m-d\TH:i:s.u', '2000-05-01T12:12:12.123456', new \DateTimeZone('UTC'))
|
|
),
|
|
array(
|
|
'2000-05-01T12:12:12.123Z',
|
|
\DateTime::createFromFormat('Y-m-d\TH:i:s.u', '2000-05-01T12:12:12.123000', new \DateTimeZone('UTC'))
|
|
),
|
|
array(
|
|
'2000-05-01 12:12:12.123Z',
|
|
\DateTime::createFromFormat('Y-m-d H:i:s.u', '2000-05-01 12:12:12.123000', new \DateTimeZone('UTC'))
|
|
),
|
|
array(
|
|
'2000-05-01 12:12:12.123456Z',
|
|
\DateTime::createFromFormat('Y-m-d H:i:s.u', '2000-05-01 12:12:12.123456', new \DateTimeZone('UTC'))
|
|
)
|
|
);
|
|
}
|
|
|
|
public function provideInvalidFormats()
|
|
{
|
|
return array(
|
|
array('1999-1-11T00:00:00Z'),
|
|
array('1999-01-11T00:00:00+100'),
|
|
array('1999-01-11T00:00:00+1:00'),
|
|
array('1999-01-01 00:00:00Z'),
|
|
array('1999-1-11 00:00:00Z')
|
|
);
|
|
}
|
|
}
|