Skip to content
This repository was archived by the owner on Sep 26, 2024. It is now read-only.

Commit 66b4cdc

Browse files
minor changes
1 parent 11753c6 commit 66b4cdc

File tree

4 files changed

+153
-10
lines changed

4 files changed

+153
-10
lines changed

.env.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
APP_ENV=prod
1+
APP_ENV=dev
22
APP_SECRET=916b65dc4449ea2036c5fb225c4df51b
33
DATABASE_URL=mysql://user:[email protected]:3306/db_name
4+
DATABASE_URL_TEST=mysql://user:[email protected]:3306/db_name_test

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# code-challenge
1+
# Code challenge
22

33
## Requirements
44
* mysql 5.7
5-
* php 7
5+
* php 7.2
66

77
## Installing
88

@@ -24,7 +24,6 @@ $ composer install
2424
Adjust DB credentials
2525
```bash
2626
$ vim .env
27-
$ vim config/packages/test/doctrine.yaml
2827

2928
```
3029

@@ -94,7 +93,7 @@ Connection: close
9493
X-Powered-By: PHP/7.2.9
9594
Cache-Control: no-cache, private
9695
Date: Thu, 20 Sep 2018 05:58:46 GMT
97-
Location: http://127.0.0.1:8000/api/orders/36
96+
Location: http://127.0.0.1:8000/api/orders/26 <--
9897
Allow: POST
9998
Content-Type: application/json
10099
```
@@ -173,14 +172,13 @@ Allow: PATCH, GET, POST
173172

174173

175174
## TODO:
176-
- [ ] Dockerize the project
177-
- [ ] Use [NelmioApiDocBundle](https://github.com/nelmio/NelmioApiDocBundle) for generating api
178-
- [ ] Implement GET /api/orders/ method
175+
- [ ] Use [NelmioApiDocBundle](https://github.com/nelmio/NelmioApiDocBundle) for generating api (~3 Hours)
176+
- [ ] Implement GET /api/orders/ method (~1.5 Hours)
179177
- [ ] add properties Order::$createdAt, Order::$updatedAt.
180178
- [ ] filter elements by initial creation (not older than 30 days)
181179
- [ ] filter elements by service
182180
- [ ] filter elements by region
183-
- [ ] Implement GET /api/cities/ method <sup>*</sup>
181+
- [ ] Implement GET /api/cities/ method <sup>*</sup> (~0.5 Hours)
184182

185183
<sup>*</sup> - Instead of returning list of available cities and zip codes (that can be quite long), extra query could be used.
186184

@@ -189,6 +187,6 @@ Allow: PATCH, GET, POST
189187
* [ ] **Order::$executionDate:**
190188
Possible values for Order::$executionDate property could be described as relation to new entity.
191189
* [ ] **Hide specific Entities' fields from exposing:**
192-
Exclusion policies could be used for that purpose.
190+
Exclusion policies could be used for that purpose. (~1-2 Hours)
193191
* [ ] Do something with **deprecation notice** in test. Currently cannot be fixed because of [that](https://github.com/symfony/symfony/issues/28119).
194192

src/Controller/OrderController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public function editAction(int $id)
138138
OrderType::class,
139139
$order,
140140
[
141+
'method' => 'PATCH',
141142
'action' => $this->generateUrl('app_api_order_patch', ['id' => $order->getId()]),
142143
]
143144
);

tests/functional/Controller/OrderControllerTest.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,149 @@ public function testGetFailure()
443443
);
444444
}
445445

446+
public function testEditAction()
447+
{
448+
$order = $this->getOrder();
449+
$this->client->request('GET', "/api/orders/{$order->getId()}/edit");
450+
$response = $this->client->getResponse();
451+
452+
$this->assertEquals(200, $response->getStatusCode());
453+
454+
$json = $response->getContent();
455+
$this->assertJson($json);
456+
$data = json_decode($json, 1);
457+
458+
$this->assertArraySubset(
459+
[
460+
'form' => [
461+
'vars' => [
462+
'name' => 'order',
463+
'errors' => [
464+
'form' => [
465+
'children' => [
466+
'description' => [],
467+
'title' => [],
468+
'executionDate' => [],
469+
'service' => [],
470+
'city' => [],
471+
],
472+
],
473+
],
474+
'method' => 'PATCH',
475+
'action' => "/api/orders/{$order->getId()}",
476+
],
477+
'children' => [
478+
'description' => [
479+
'vars' => [
480+
'value' => $order->getDescription(),
481+
'name' => 'description',
482+
],
483+
],
484+
'title' => [
485+
'vars' => [
486+
'value' => $order->getTitle(),
487+
'name' => 'title',
488+
],
489+
],
490+
'executionDate' => [
491+
'vars' => [
492+
'value' => $order->getExecutionDate(),
493+
'name' => 'executionDate',
494+
'choices' => [
495+
0 => [
496+
'label' => 'Zeitnah',
497+
'value' => '10',
498+
],
499+
1 => [
500+
'label' => 'Innerhalb der nächsten 30 Tage',
501+
'value' => '20',
502+
],
503+
2 => [
504+
'label' => 'In den nächsten 3 Monaten',
505+
'value' => '23',
506+
],
507+
3 => [
508+
'label' => 'In 3 bis 6 Monaten',
509+
'value' => '25',
510+
],
511+
4 => [
512+
'label' => 'In mehr als 6 Monaten',
513+
'value' => '27',
514+
],
515+
5 => [
516+
'label' => 'Wunschtermin: Bitte Datum wählen',
517+
'value' => '30',
518+
],
519+
],
520+
],
521+
],
522+
'service' => [
523+
'vars' => [
524+
'value' => $order->getService()->getId(),
525+
'name' => 'service',
526+
'choices' => [
527+
108140 => [
528+
'label' => 'Kellersanierung',
529+
'value' => '108140',
530+
],
531+
402020 => [
532+
'label' => 'Holzdielen schleifen',
533+
'value' => '402020',
534+
],
535+
411070 => [
536+
'label' => 'Fensterreinigung',
537+
'value' => '411070',
538+
],
539+
802030 => [
540+
'label' => 'Abtransport, Entsorgung und Entrümpelung',
541+
'value' => '802030',
542+
],
543+
804040 => [
544+
'label' => 'Sonstige Umzugsleistungen',
545+
'value' => '804040',
546+
],
547+
],
548+
],
549+
],
550+
'city' => [
551+
'vars' => [
552+
'value' => $order->getCity()->getZip(),
553+
'name' => 'city',
554+
'choices' => [
555+
10115 => [
556+
'label' => 'Berlin',
557+
'value' => '10115',
558+
],
559+
21521 => [
560+
'label' => 'Hamburg',
561+
'value' => '21521',
562+
],
563+
32457 => [
564+
'label' => 'Porta Westfalica',
565+
'value' => '32457',
566+
],
567+
'01623' => [
568+
'label' => 'Lommatzsch',
569+
'value' => '01623',
570+
],
571+
'06895' => [
572+
'label' => 'Bülzig',
573+
'value' => '06895',
574+
],
575+
'01612' => [
576+
'label' => 'Diesbar-Seußlitz',
577+
'value' => '01612',
578+
],
579+
],
580+
],
581+
],
582+
],
583+
],
584+
],
585+
$data
586+
);
587+
}
588+
446589
/**
447590
* @return City
448591
*/

0 commit comments

Comments
 (0)