Skip to content

Commit bb698dc

Browse files
written update, delete tests
1 parent 704582e commit bb698dc

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Test/Functional/CrudTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,49 @@ public function testItCanCreateReportUsingPostRequest()
5555
return $bugReport;
5656
}
5757

58+
59+
/** @depends testItCanCreateReportUsingPostRequest
60+
* @param BugReport $bugReport
61+
* @return BugReport
62+
*/
63+
public function testItCanUpdateReportUsingPostRequest(BugReport $bugReport)
64+
{
65+
$postData = $this->getPostData([
66+
'update' => true,
67+
'message' => 'There is an video issue on edison tutorial, please check and fix it',
68+
'link' => 'https://updated.com',
69+
'report_id' => $bugReport->getId()
70+
]);
71+
$this->client->post("http://localhost/bug_tracking_app/src/update.php", $postData);
72+
73+
/** @var BugReport $result */
74+
$result = $this->repository->find($bugReport->getId());
75+
76+
self::assertInstanceOf(BugReport::class, $result);
77+
self::assertSame('https://xyz-link.com', $bugReport->getLink());
78+
self::assertSame( 'There is an video issue on edison tutorial, please check and fix it', $bugReport->getMessage());
79+
80+
return $bugReport;
81+
}
82+
83+
84+
85+
public function testItCanDeleteReportUsingPostRequest(BugReport $bugReport)
86+
{
87+
$postData = [
88+
'delete' => true,
89+
'report_id' => $bugReport->getId()
90+
];
91+
$this->client->post("http://localhost/bug_tracking_app/src/delete.php", $postData);
92+
93+
/** @var BugReport $result */
94+
$result = $this->repository->find($bugReport->getId());
95+
96+
self::assertNull($bugReport);
97+
}
98+
99+
100+
//---------------------------------------------- Internal Methods --------------------------------------------------//
58101
private function getPostData(array $options = []): array
59102
{
60103
return array_merge([

0 commit comments

Comments
 (0)