Skip to content

Commit

Permalink
chore: Change default datetime format
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Nov 30, 2023
1 parent d6dbaf9 commit 8975cd4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions example/generators/consumer/tests/Service/GeneratorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function testGetMatchers()
'hexadecimal' => $this->matcher->hexadecimal(null),
'uuid' => $this->matcher->uuid(null),
'date' => $this->matcher->date('yyyy-MM-dd', null),
'time' => $this->matcher->time('HH:mm::ss', null),
'datetime' => $this->matcher->datetime("YYYY-MM-D'T'HH:mm:ss", null),
'time' => $this->matcher->time('HH:mm:ss', null),
'datetime' => $this->matcher->datetime("yyyy-MM-dd'T'HH:mm:ss", null),
'string' => $this->matcher->string(null),
'number' => $this->matcher->number(null),
'requestId' => 222,
Expand Down Expand Up @@ -89,8 +89,8 @@ public function testGetMatchers()
$this->assertRegExp('/' . Matcher::HEX_FORMAT . '/', $body['hexadecimal']);
$this->assertRegExp('/' . Matcher::UUID_V4_FORMAT . '/', $body['uuid']);
$this->assertTrue($this->validateDateTime($body['date'], 'Y-m-d'));
$this->assertTrue($this->validateDateTime($body['time'], 'H:i::s'));
$this->assertTrue($this->validateDateTime($body['datetime'], "Y-m-z\TH:i:s"));
$this->assertTrue($this->validateDateTime($body['time'], 'H:i:s'));
$this->assertTrue($this->validateDateTime($body['datetime'], "Y-m-d\TH:i:s"));
$this->assertIsString($body['string']);
$this->assertIsNumeric($body['number']);
$this->assertSame(222, $body['requestId']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"type": "Date"
},
"$.datetime": {
"format": "YYYY-MM-D'T'HH:mm:ss",
"format": "yyyy-MM-dd'T'HH:mm:ss",
"type": "DateTime"
},
"$.decimal": {
Expand Down Expand Up @@ -110,7 +110,7 @@
"type": "RandomString"
},
"$.time": {
"format": "HH:mm::ss",
"format": "HH:mm:ss",
"type": "Time"
},
"$.uuid": {
Expand Down Expand Up @@ -151,7 +151,7 @@
"combine": "AND",
"matchers": [
{
"format": "YYYY-MM-D'T'HH:mm:ss",
"format": "yyyy-MM-dd'T'HH:mm:ss",
"match": "datetime"
}
]
Expand Down Expand Up @@ -210,7 +210,7 @@
"combine": "AND",
"matchers": [
{
"format": "HH:mm::ss",
"format": "HH:mm:ss",
"match": "time"
}
]
Expand Down
2 changes: 1 addition & 1 deletion example/generators/provider/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'hexadecimal' => '20AC',
'uuid' => 'e9d2f3a5-6ecc-4bff-8935-84bb6141325a',
'date' => '1997-12-11',
'time' => '11:01::02',
'time' => '11:01:02',
'datetime' => '1997-07-16T19:20:30',
'string' => 'another string',
'number' => 112.3,
Expand Down
4 changes: 2 additions & 2 deletions example/matchers/consumer/tests/Service/MatchersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function testGetMatchers()
'email' => $this->matcher->email(),
'nullValue' => $this->matcher->nullValue(),
'date' => $this->matcher->date('yyyy-MM-dd', '2015-05-16'),
'time' => $this->matcher->time('HH:mm::ss', '23:59::58'),
'datetime' => $this->matcher->datetime("YYYY-mm-DD'T'HH:mm:ss", '2000-10-31T01:30:00'),
'time' => $this->matcher->time('HH:mm:ss', '23:59::58'),
'datetime' => $this->matcher->datetime("yyyy-MM-dd'T'HH:mm:ss", '2000-10-31T01:30:00'),
'likeString' => $this->matcher->string('some string'),
'equal' => $this->matcher->equal('exact this value'),
'equalArray' => $this->matcher->equal([
Expand Down
4 changes: 2 additions & 2 deletions example/matchers/pacts/matchersConsumer-matchersProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"combine": "AND",
"matchers": [
{
"format": "YYYY-mm-DD'T'HH:mm:ss",
"format": "yyyy-MM-dd'T'HH:mm:ss",
"match": "datetime"
}
]
Expand Down Expand Up @@ -511,7 +511,7 @@
"combine": "AND",
"matchers": [
{
"format": "HH:mm::ss",
"format": "HH:mm:ss",
"match": "time"
}
]
Expand Down
2 changes: 1 addition & 1 deletion example/matchers/provider/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'email' => '[email protected]',
'nullValue' => null,
'date' => '1997-12-11',
'time' => '11:01::02',
'time' => '11:01:02',
'datetime' => '1997-07-16T19:20:30',
'likeString' => 'another string',
'equal' => 'exact this value',
Expand Down
4 changes: 2 additions & 2 deletions src/PhpPact/Consumer/Matcher/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public function date(string $format = 'yyyy-MM-dd', ?string $value = null): arra
/**
* @return array<string, mixed>
*/
public function time(string $format = 'HH:mm::ss', ?string $value = null): array
public function time(string $format = 'HH:mm:ss', ?string $value = null): array
{
if (null === $value) {
return [
Expand All @@ -486,7 +486,7 @@ public function time(string $format = 'HH:mm::ss', ?string $value = null): array
/**
* @return array<string, mixed>
*/
public function datetime(string $format = "YYYY-mm-DD'T'HH:mm:ss", ?string $value = null): array
public function datetime(string $format = "yyyy-MM-dd'T'HH:mm:ss", ?string $value = null): array
{
if (null === $value) {
return [
Expand Down
6 changes: 3 additions & 3 deletions tests/PhpPact/Consumer/Matcher/MatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,9 @@ public function testDateTime()
$expected = [
'value' => '2015-08-06T16:53:10',
'pact:matcher:type' => 'datetime',
'format' => "YYYY-mm-DD'T'HH:mm:ss",
'format' => "yyyy-MM-dd'T'HH:mm:ss",
];
$actual = $this->matcher->datetime("YYYY-mm-DD'T'HH:mm:ss", '2015-08-06T16:53:10');
$actual = $this->matcher->datetime("yyyy-MM-dd'T'HH:mm:ss", '2015-08-06T16:53:10');

$this->assertEquals($expected, $actual);
}
Expand All @@ -697,7 +697,7 @@ public function testRandomDateTime()
$expected = [
'pact:generator:type' => 'DateTime',
'pact:matcher:type' => 'datetime',
'format' => "YYYY-mm-DD'T'HH:mm:ss",
'format' => "yyyy-MM-dd'T'HH:mm:ss",
];
$actual = $this->matcher->datetime();

Expand Down

0 comments on commit 8975cd4

Please sign in to comment.