Skip to content

Commit 8d83413

Browse files
created add, delete, update and read files for functional process testing in src/view, modifie Crudtest a bit
1 parent 41a5be5 commit 8d83413

6 files changed

Lines changed: 35 additions & 5 deletions

File tree

Test/Functional/CrudTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ protected function setUp()
3939
public function testItCanCreateReportUsingPostRequest()
4040
{
4141
$postData = $this->getPostData(['add' => true]);
42-
$response = $this->client->post("http://localhost/bug_tracking_app/src/add.php", $postData);
43-
42+
$response = $this->client->post("http://localhost/sand_box/bug_tracking_app/Src/View/add.php", $postData);
4443
$response = json_decode($response, true);
4544
self::assertEquals(200, $response['statusCode']);
4645

@@ -74,9 +73,10 @@ public function testItCanUpdateReportUsingPostRequest(BugReport $bugReport)
7473
'link' => 'https://updated.com',
7574
'report_id' => $bugReport->getId()
7675
]);
77-
$response = $this->client->post("http://localhost/bug_tracking_app/src/update.php", $postData);
76+
$response = $this->client->post("http://localhost/sand_box/bug_tracking_app/src/View/update.php", $postData);
7877

7978
$response = json_decode($response, true);
79+
var_dump($response);die();
8080
self::assertEquals(200, $response['statusCode']);
8181

8282
/** @var BugReport $result */
@@ -100,7 +100,7 @@ public function testItCanDeleteReportUsingPostRequest(BugReport $bugReport)
100100
'delete' => true,
101101
'report_id' => $bugReport->getId()
102102
];
103-
$response = $this->client->post("http://localhost/bug_tracking_app/src/delete.php", $postData);
103+
$response = $this->client->post("http://localhost/sand_box/bug_tracking_app/src/View/delete.php", $postData);
104104

105105
$response = json_decode($response, true);
106106
self::assertEquals(200, $response['statusCode']);

src/Repository/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function findOneBy (string $field, $value): ?object
3737

3838
public function findBy (array $criteria)
3939
{
40-
$this->queryBuilder->table(static::$table);
40+
$this->queryBuilder->table(static::$table)->select();
4141
foreach ($criteria as $criterion){
4242
$this->queryBuilder->where(...$criterion);
4343
}

src/View/add.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
require_once __DIR__.'/../../vendor/autoload.php';
4+
use App\Entity\BugReport;
5+
use App\Repository\BugReportRepository;
6+
use App\Helpers\DbQueryBuilderFactory;
7+
use App\Database\QueryBuilder;
8+
9+
if(isset($_POST, $_POST['add']))
10+
{
11+
$reportType = $_POST['report_type'];
12+
$email = $_POST['email'];
13+
$link = $_POST['link'];
14+
$message = $_POST['message'];
15+
16+
$bugReport = new BugReport;
17+
$bugReport->setReportType($reportType);
18+
$bugReport->setEmail($email);
19+
$bugReport->setLink($link);
20+
$bugReport->setMessage($message);
21+
22+
/** @var QueryBuilder $queryBuilder */
23+
$queryBuilder = DbQueryBuilderFactory::make();
24+
/** @var BugReportRepository $repository */
25+
$repository = new BugReportRepository($queryBuilder);
26+
$newReport = $repository->create($bugReport);
27+
}

src/View/delete.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

src/View/read.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

src/View/update.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

0 commit comments

Comments
 (0)