Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Change default datetime format #373

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 6 additions & 6 deletions tests/PhpPact/Consumer/Matcher/MatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ public function testTime()
$expected = [
'value' => '21:45::31',
'pact:matcher:type' => 'time',
'format' => 'HH:mm::ss',
'format' => 'HH:mm:ss',
];
$actual = $this->matcher->time('HH:mm::ss', '21:45::31');
$actual = $this->matcher->time('HH:mm:ss', '21:45::31');

$this->assertEquals($expected, $actual);
}
Expand All @@ -673,7 +673,7 @@ public function testRandomTime()
$expected = [
'pact:generator:type' => 'Time',
'pact:matcher:type' => 'time',
'format' => 'HH:mm::ss',
'format' => 'HH:mm:ss',
];
$actual = $this->matcher->time();

Expand All @@ -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