Skip to content

Commit b388537

Browse files
committed
fix: #8 nullable
1 parent f5ffbab commit b388537

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/Iteration.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public function create(array $data)
1919
$validator = Validator::getInstance()->make($data, [
2020
'ProjectName' => 'string|required',
2121
'Name' => 'string|required',
22-
'Goal' => 'string',
23-
'Assignee' => 'integer',
24-
'StartAt' => 'date_format:Y-m-d',
25-
'EndAt' => 'date_format:Y-m-d|after:StartAt',
22+
'Goal' => 'nullable|string',
23+
'Assignee' => 'nullable|integer',
24+
'StartAt' => 'nullable|date_format:Y-m-d',
25+
'EndAt' => 'nullable|date_format:Y-m-d|after:StartAt',
2626
]);
2727
if ($validator->fails()) {
2828
// TODO Laravel ValidationException no message

tests/IterationTest.php

+23
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ public function testCreateSuccessWithOnlyRequiredParams()
3030
$this->assertEquals($response['Iteration'], $result);
3131
}
3232

33+
public function testCreateSuccessWithRequiredParamsAndNull()
34+
{
35+
$coreMock = \Mockery::mock(Core::class, [])->makePartial();
36+
37+
$response = json_decode(
38+
file_get_contents($this->dataPath('CreateIterationResponse.json')),
39+
true
40+
)['Response'];
41+
$data = [
42+
'ProjectName' => $this->projectName,
43+
'Name' => $this->faker->title,
44+
'Goal' => null,
45+
];
46+
$coreMock->shouldReceive('request')->times(1)->withArgs([
47+
'CreateIteration',
48+
$data
49+
])->andReturn($response);
50+
51+
$iteration = new Iteration($this->token, $coreMock);
52+
$result = $iteration->create($data);
53+
$this->assertEquals($response['Iteration'], $result);
54+
}
55+
3356
public function testCreateSuccessWithAllParams()
3457
{
3558
$coreMock = \Mockery::mock(Core::class, [])->makePartial();

0 commit comments

Comments
 (0)